Do not list own public key as recipient

This commit is contained in:
Franck Royer 2021-06-25 16:17:42 +10:00
parent 452f4285eb
commit 820307ef8c
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 3 additions and 0 deletions

View File

@ -79,6 +79,7 @@ function App() {
const observerPublicKeyMessage = handlePublicKeyMessage.bind(
{},
ethDmKeyPair?.publicKey,
setPublicKeys
);
@ -204,11 +205,13 @@ function encodePublicKeyWakuMessage(ethDmMsg: PublicKeyMessage): WakuMessage {
}
function handlePublicKeyMessage(
myPublicKey: string | undefined,
setter: Dispatch<SetStateAction<Map<string, string>>>,
msg: WakuMessage
) {
if (!msg.payload) return;
const publicKeyMsg: PublicKeyMessage = decode(msg.payload);
if (publicKeyMsg.ethDmPublicKey === myPublicKey) return;
const res = validatePublicKeyMessage(publicKeyMsg);
console.log(`Public Key Message Received, valid: ${res}`, publicKeyMsg);