mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-13 12:56:43 +00:00
Fix bad comparison logic
This commit is contained in:
parent
44db58d2fd
commit
66d450ae36
@ -58,20 +58,24 @@ export async function handleDirectMessage(
|
|||||||
console.log('Direct Message received:', wakuMsg);
|
console.log('Direct Message received:', wakuMsg);
|
||||||
if (!wakuMsg.payload) return;
|
if (!wakuMsg.payload) return;
|
||||||
const directMessage: DirectMessage = decode(wakuMsg.payload);
|
const directMessage: DirectMessage = decode(wakuMsg.payload);
|
||||||
// Do not return our own messages
|
// Only decrypt messages for us
|
||||||
if (directMessage.toAddress === address) return;
|
if (!equalByteArrays(directMessage.toAddress, address)) return;
|
||||||
|
|
||||||
const text = await decryptMessage(privateKey, directMessage);
|
try {
|
||||||
|
const text = await decryptMessage(privateKey, directMessage);
|
||||||
|
|
||||||
const timestamp = wakuMsg.timestamp ? wakuMsg.timestamp : new Date();
|
const timestamp = wakuMsg.timestamp ? wakuMsg.timestamp : new Date();
|
||||||
|
|
||||||
console.log('Message decrypted:', text);
|
console.log('Message decrypted:', text);
|
||||||
setter((prevMsgs: Message[]) => {
|
setter((prevMsgs: Message[]) => {
|
||||||
const copy = prevMsgs.slice();
|
const copy = prevMsgs.slice();
|
||||||
copy.push({
|
copy.push({
|
||||||
text: text,
|
text: text,
|
||||||
timestamp: timestamp,
|
timestamp: timestamp,
|
||||||
|
});
|
||||||
|
return copy;
|
||||||
});
|
});
|
||||||
return copy;
|
} catch (e) {
|
||||||
});
|
console.log(' Failed to decrypt message', e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user