feat: adopt createMessage upload api (#6596)

This commit is contained in:
pengx17
2024-04-18 06:55:29 +00:00
parent 10653eccbc
commit 5fc56a20ac
6 changed files with 63 additions and 46 deletions

View File

@@ -64,7 +64,7 @@ class CreateChatMessageInput implements Omit<SubmittedMessage, 'content'> {
attachments!: string[] | undefined;
@Field(() => [GraphQLUpload], { nullable: true })
blobs!: FileUpload[] | undefined;
blobs!: Promise<FileUpload>[] | undefined;
@Field(() => GraphQLJSON, { nullable: true })
params!: Record<string, string> | undefined;
@@ -277,7 +277,7 @@ export class CopilotResolver {
options.attachments = options.attachments || [];
const { workspaceId } = session.config;
for (const blob of options.blobs) {
for (const blob of await Promise.all(options.blobs)) {
const uploaded = await this.storage.handleUpload(user.id, blob);
const link = await this.storage.put(
user.id,
@@ -286,6 +286,7 @@ export class CopilotResolver {
uploaded.buffer
);
options.attachments.push(link);
delete options.blobs;
}
}