From 51c50db166ffdae8072398c01f2e8dba93c4eabc Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 26 Oct 2022 16:14:45 +0200 Subject: [PATCH] Fix form anonymous responses not triggering the notification --- www/common/outer/async-store.js | 2 +- www/common/outer/mailbox.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 9265e807c..5c9958bec 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -1955,7 +1955,7 @@ define([ // If send is true, send the request to the owner. if (owner) { if (data.send) { - store.mailbox.sendTo(data.query, { + Mailbox.sendToAnon(store.anon_rpc, data.query, { channel: data.channel, data: data.msgData }, { diff --git a/www/common/outer/mailbox.js b/www/common/outer/mailbox.js index 8f9860a41..3e85585dc 100644 --- a/www/common/outer/mailbox.js +++ b/www/common/outer/mailbox.js @@ -164,6 +164,22 @@ proxy.mailboxes = { }); }); }; + Mailbox.sendToAnon = function (anonRpc, type, msg, user, cb) { + var Nacl = Crypto.Nacl; + var curveSeed = Nacl.randomBytes(32); + var curvePair = Nacl.box.keyPair.fromSecretKey(new Uint8Array(curveSeed)); + var curvePrivate = Nacl.util.encodeBase64(curvePair.secretKey); + var curvePublic = Nacl.util.encodeBase64(curvePair.publicKey); + sendTo({ + store: { + anon_rpc: anonRpc, + proxy: { + curvePrivate: curvePrivate, + curvePublic: curvePublic + } + } + }, type, msg, user, cb); + }; // Mark a message as read var dismiss = function (ctx, data, cId, cb) {