21 lines
753 B
TypeScript
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]";
|
|
}
|
|
}
|