Files
desktop/app/utils/constructLastMessageTextByAttachments.ts
rosetta 83f38dc63f 'init'
2026-01-30 05:01:05 +02:00

21 lines
753 B
TypeScript

import { Attachment, AttachmentType } from "../providers/ProtocolProvider/protocol/packets/packet.message";
export const constructLastMessageTextByAttachments = (attachment: string) => {
let attachmentArray : Attachment[] = JSON.parse(attachment);
if(attachmentArray.length <= 0) {
return "[Unsupported message]";
}
let attach = attachmentArray[0];
switch(attach.type) {
case AttachmentType.IMAGE:
return "$a=Photo";
case AttachmentType.MESSAGES:
return "$a=Forwarded messages";
case AttachmentType.FILE:
return "$a=File";
case AttachmentType.AVATAR:
return "$a=Avatar";
default:
return "[Unsupported attachment]";
}
}