fix(server): empty mimetype attachments fallback (#11869)

This commit is contained in:
darkskygit
2025-04-22 15:36:35 +00:00
parent 597b27c22f
commit de8c65f4e6
7 changed files with 150 additions and 35 deletions
@@ -492,19 +492,53 @@ export async function createCopilotMessage(
sessionId: string,
content?: string,
attachments?: string[],
blobs?: ArrayBuffer[],
blobs?: File[],
params?: Record<string, string>
): Promise<string> {
const res = await app.gql(
`
mutation createCopilotMessage($options: CreateChatMessageInput!) {
createCopilotMessage(options: $options)
let resp = app
.POST('/graphql')
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
.field(
'operations',
JSON.stringify({
query: `
mutation createCopilotMessage($options: CreateChatMessageInput!) {
createCopilotMessage(options: $options)
}
`,
variables: {
options: { sessionId, content, attachments, blobs: [], params },
},
})
)
.field(
'map',
JSON.stringify(
Array.from<any>({ length: blobs?.length ?? 0 }).reduce(
(acc, _, idx) => {
acc[idx.toString()] = [`variables.options.blobs.${idx}`];
return acc;
},
{}
)
)
);
if (blobs && blobs.length) {
for (const [idx, file] of blobs.entries()) {
resp = resp.attach(
idx.toString(),
Buffer.from(await file.arrayBuffer()),
{
filename: file.name || `file${idx}`,
contentType: file.type || 'application/octet-stream',
}
);
}
`,
{ options: { sessionId, content, attachments, blobs, params } }
);
}
return res.createCopilotMessage;
const res = await resp.expect(200);
return res.body.data.createCopilotMessage;
}
export async function chatWithText(