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";
        case AttachmentType.CALL:
            return "$a=Call";
        default:
            return "[Unsupported attachment]";
    }
}  