From 0390d3df7528ee24ab4f500afaf1f5e512e0b28b Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 5 Jun 2020 12:04:28 +0200 Subject: [PATCH] Don't show your own team notifications --- www/common/common-ui-elements.js | 2 +- www/common/outer/mailbox.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index a7c5d3994..37a5172db 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -281,7 +281,6 @@ define([ if (mailbox) { // Friend if (friends[curve] && !mailbox.notifications) { return; } if (mailbox.notifications && mailbox.curvePublic) { - // XXX we should mark this notification as "viewed" in our own proxy common.mailbox.sendTo("SHARE_PAD", { href: href, password: config.password, @@ -289,6 +288,7 @@ define([ name: myName, title: title }, { + viewed: team && team.id, channel: mailbox.notifications, curvePublic: mailbox.curvePublic }); diff --git a/www/common/outer/mailbox.js b/www/common/outer/mailbox.js index ccae95a7e..2250257aa 100644 --- a/www/common/outer/mailbox.js +++ b/www/common/outer/mailbox.js @@ -109,6 +109,17 @@ proxy.mailboxes = { }); var ciphertext = crypto.encrypt(text, user.curvePublic); + // If we've sent this message to one of our teams' mailbox, we may want to "dismiss" it + // automatically + if (user.viewed) { + var team = Util.find(ctx, ['store', 'proxy', 'teams', user.viewed]); + if (team) { + var hash = ciphertext.slice(0,64); + var viewed = Util.find(team, ['keys', 'mailbox', 'viewed']); + if (Array.isArray(viewed)) { viewed.push(hash); } + } + } + anonRpc.send("WRITE_PRIVATE_MESSAGE", [ user.channel, ciphertext