Skip to content
Merged
2 changes: 1 addition & 1 deletion packages/web-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"sinon": "^20",
"source-map-support": "^0.5.21",
"ts-node": "^10",
"tsd": "^0.31.1",
"tsd": "^0.32.0",
"typescript": "5.3.3"
},
"tsd": {
Expand Down
18 changes: 13 additions & 5 deletions packages/web-api/src/file-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Logger } from '@slack/logger';

import { ErrorCode, errorWithCode } from './errors';
import type {
FileThreadDestinationArgument,
FileUploadV2,
FileUploadV2Job,
FilesCompleteUploadExternalArguments,
Expand Down Expand Up @@ -200,10 +201,10 @@ export async function getFileDataAsStream(readable: Readable): Promise<Buffer> {

return new Promise((resolve, reject) => {
readable.on('readable', () => {
let chunk: Buffer;
// biome-ignore lint/suspicious/noAssignInExpressions: being terse, this is OK
while ((chunk = readable.read()) !== null) {
let chunk = readable.read();
while (chunk !== null) {
chunks.push(chunk);
chunk = readable.read();
}
});
readable.on('end', () => {
Expand Down Expand Up @@ -240,8 +241,15 @@ export function getAllFileUploadsToComplete(
channel_id,
initial_comment,
};
if (thread_ts) {
toComplete[compareString].thread_ts = upload.thread_ts;
if (thread_ts && channel_id) {
const fileThreadDestinationArgument: FileThreadDestinationArgument = {
channel_id,
thread_ts,
};
toComplete[compareString] = {
...toComplete[compareString],
...fileThreadDestinationArgument,
};
}
if ('token' in upload) {
toComplete[compareString].token = upload.token;
Expand Down