'init'
This commit is contained in:
21
app/utils/constructLastMessageTextByAttachments.ts
Normal file
21
app/utils/constructLastMessageTextByAttachments.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
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]";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user