Skip to content

Commit

Permalink
fix: Fixed deprecated attributes for MsgModel
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Apr 15, 2023
1 parent 36e3622 commit ff65494
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/chat/events/registerNewMessageEvent.ts
Expand Up @@ -41,14 +41,30 @@ function register() {
}

async function addAttributesMsg(msg: any): Promise<MsgModel> {
if (typeof msg.chat === 'undefined')
if (typeof msg.chat === 'undefined') {
msg.chat = ChatStore.get(msg.from as Wid);
msg.isGroupMsg = msg.isGroupMsg || msg?.chat?.isGroup;
Object.defineProperty(msg, 'chat', {
value: msg.isGroupMsg || msg?.chat?.isGroup,
writable: false,
});
}
Object.defineProperty(msg, 'isGroupMsg', {
value: msg.isGroupMsg || msg?.chat?.isGroup,
writable: false,
});

if (!(typeof msg.quotedStanzaID === 'undefined')) {
const replyMsg = await getQuotedMsg(msg.id);
msg._quotedMsgObj = replyMsg;
msg.quotedMsgId = replyMsg.id;
Object.defineProperties(msg, {
_quotedMsgObj: {
value: replyMsg,
writable: false,
},
quotedMsgId: {
value: replyMsg.id,
writable: false,
},
});
}
return msg;
}

0 comments on commit ff65494

Please sign in to comment.