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