@@ -27,6 +27,7 @@ export async function getFileUploadJob(
2727 const fileUploadJob : Record < string , unknown > = {
2828 // supplied by user
2929 alt_text : options . alt_text ,
30+ blocks : options . blocks ,
3031 channel_id : options . channels ?? options . channel_id ,
3132 filename : options . filename ?? fileName ,
3233 initial_comment : options . initial_comment ,
@@ -96,8 +97,8 @@ export async function getMultipleFileUploadJobs(
9697 // ensure no omitted properties included in files_upload entry
9798 // these properties are valid only at the top-level, not
9899 // inside file_uploads.
99- const { channel_id, channels, initial_comment, thread_ts } = upload as FileUploadV2 ;
100- if ( channel_id || channels || initial_comment || thread_ts ) {
100+ const { blocks , channel_id, channels, initial_comment, thread_ts } = upload as FileUploadV2 ;
101+ if ( blocks || channel_id || channels || initial_comment || thread_ts ) {
101102 throw errorWithCode (
102103 new Error ( buildInvalidFilesUploadParamError ( ) ) ,
103104 ErrorCode . FileUploadInvalidArgumentsError ,
@@ -107,6 +108,7 @@ export async function getMultipleFileUploadJobs(
107108 // supplied at the top level.
108109 const uploadJobArgs : Record < string , unknown > = {
109110 ...upload ,
111+ blocks : options . blocks ,
110112 channels : options . channels ,
111113 channel_id : options . channel_id ,
112114 initial_comment : options . initial_comment ,
@@ -220,7 +222,7 @@ export async function getFileDataAsStream(readable: Readable): Promise<Buffer> {
220222
221223/**
222224 * Filters through all fileUploads and groups them into jobs for completion
223- * based on combination of channel_id, thread_ts, initial_comment.
225+ * based on combination of channel_id, thread_ts, initial_comment, blocks .
224226 * {@link https://api.slack.com/methods/files.completeUploadExternal files.completeUploadExternal} allows for multiple
225227 * files to be uploaded with a message (`initial_comment`), and as a threaded message (`thread_ts`)
226228 * In order to be grouped together, file uploads must have like properties.
@@ -232,13 +234,14 @@ export function getAllFileUploadsToComplete(
232234) : Record < string , FilesCompleteUploadExternalArguments > {
233235 const toComplete : Record < string , FilesCompleteUploadExternalArguments > = { } ;
234236 for ( const upload of fileUploads ) {
235- const { channel_id, thread_ts, initial_comment, file_id, title } = upload ;
237+ const { blocks , channel_id, thread_ts, initial_comment, file_id, title } = upload ;
236238 if ( file_id ) {
237- const compareString = `:::${ channel_id } :::${ thread_ts } :::${ initial_comment } ` ;
239+ const compareString = `:::${ channel_id } :::${ thread_ts } :::${ initial_comment } ::: ${ JSON . stringify ( blocks ) } ` ;
238240 if ( ! Object . prototype . hasOwnProperty . call ( toComplete , compareString ) ) {
239241 toComplete [ compareString ] = {
240242 files : [ { id : file_id , title } ] ,
241243 channel_id,
244+ blocks,
242245 initial_comment,
243246 } ;
244247 if ( thread_ts && channel_id ) {
@@ -425,7 +428,7 @@ export function buildMultipleChannelsErrorMsg(): string {
425428
426429export function buildInvalidFilesUploadParamError ( ) : string {
427430 return (
428- 'You may supply file_uploads only for a single channel, comment, thread respectively. ' +
429- 'Therefore, please supply any channel_id, initial_comment, thread_ts in the top-layer.'
431+ 'You may supply file_uploads only for a single channel, message, or thread respectively. ' +
432+ 'Therefore, please supply any channel_id, initial_comment or blocks, or thread_ts in the top-layer.'
430433 ) ;
431434}
0 commit comments