From 99cd10b62130561f2212c47e2d1443466537b647 Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Tue, 12 Mar 2024 23:56:38 +0200 Subject: [PATCH] fix logic --- src/Socket/messages-recv.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index cd90132..4fe444f 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -99,13 +99,14 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { stanza.attrs.recipient = attrs.recipient } - if(!!attrs.type) { - stanza.attrs.type = attrs.type - } - if(tag === 'message') { - stanza.attrs.from = authState.creds.me!.id - } + if (!!attrs.type && (tag !== "message" || getBinaryNodeChild({ tag, attrs, content }, "unavailable"))) { + stanza.attrs.type = attrs.type; + } + + if(tag === "message" && getBinaryNodeChild({ tag, attrs, content }, "unavailable")) { + stanza.attrs.from = authState.creds.me!.id; + } logger.debug({ recv: { tag, attrs }, sent: stanza.attrs }, 'sent ack') await sendNode(stanza)