Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions ee/packages/omnichannel-services/src/OmnichannelTranscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export type MessageData = Pick<
| 'slaData'
| 'priorityData'
> & {
files: ({ name?: string; buffer: Buffer | null; extension?: string } | undefined)[];
files: ({ name?: string; buffer?: Buffer; extension?: string } | undefined)[];
quotes: (Quote | undefined)[];
};

Expand Down Expand Up @@ -230,14 +230,14 @@ export class OmnichannelTranscript extends ServiceClass implements IOmnichannelT
if (!isFileImageAttachment(attachment)) {
this.log.error(`Invalid attachment type ${attachment.type} for file ${attachment.title} in room ${message.rid}!`);
// ignore other types of attachments
files.push({ name: attachment.title, buffer: null });
files.push({ name: attachment.title });
continue;
}

if (!this.worker.isMimeTypeValid(attachment.image_type)) {
this.log.error(`Invalid mime type ${attachment.image_type} for file ${attachment.title} in room ${message.rid}!`);
// ignore invalid mime types
files.push({ name: attachment.title, buffer: null });
files.push({ name: attachment.title });
continue;
}
let file = message.files?.map((v) => ({ _id: v._id, name: v.name })).find((file) => file.name === attachment.title);
Expand All @@ -249,7 +249,7 @@ export class OmnichannelTranscript extends ServiceClass implements IOmnichannelT
if (!fileId) {
this.log.error(`File ${attachment.title} not found in room ${message.rid}!`);
// ignore attachments without file
files.push({ name: attachment.title, buffer: null });
files.push({ name: attachment.title });
continue;
}
file = { _id: fileId, name: attachment.title || 'upload' };
Expand All @@ -258,15 +258,15 @@ export class OmnichannelTranscript extends ServiceClass implements IOmnichannelT
if (!file) {
this.log.warn(`File ${attachment.title} not found in room ${message.rid}!`);
// ignore attachments without file
files.push({ name: attachment.title, buffer: null });
files.push({ name: attachment.title });
continue;
}

const uploadedFile = await Uploads.findOneById(file._id);
if (!uploadedFile) {
this.log.error(`Uploaded file ${file._id} not found in room ${message.rid}!`);
// ignore attachments without file
files.push({ name: file.name, buffer: null });
files.push({ name: file.name });
continue;
}

Expand All @@ -276,7 +276,7 @@ export class OmnichannelTranscript extends ServiceClass implements IOmnichannelT
} catch (e: unknown) {
this.log.error(`Failed to get file ${file._id}`, e);
// Push empty buffer so parser processes this as "unsupported file"
files.push({ name: file.name, buffer: null });
files.push({ name: file.name });

// TODO: this is a NATS error message, even when we shouldn't tie it, since it's the only way we have right now we'll live with it for a while
if ((e as Error).message === 'MAX_PAYLOAD_EXCEEDED') {
Expand Down
Loading