From 2e87d6f2847b51ee3828ea6fe18df2ebaf4957d3 Mon Sep 17 00:00:00 2001 From: cel Date: Sun, 12 Aug 2018 16:50:47 -0700 Subject: Show if private message author is not a recipient --- lib/render-msg.js | 6 ++++-- lib/render.js | 5 ++++- lib/serve.js | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/render-msg.js b/lib/render-msg.js index f351039..89a5f90 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -188,10 +188,12 @@ RenderMsg.prototype.sync = function (cb) { RenderMsg.prototype.recpsLine = function (cb) { if (!this.value.private) return cb(), '' var author = this.value.author - var recpsNotSelf = u.toArray(this.c.recps).filter(function (link) { + var recps = u.toArray(this.c.recps) + var recpsNotAuthor = recps.filter(function (link) { return u.linkDest(link) !== author }) - return this.render.privateLine(recpsNotSelf, cb) + var isAuthorRecp = recpsNotAuthor.length < recps.length + return this.render.privateLine(recpsNotAuthor, isAuthorRecp, cb) } RenderMsg.prototype.recpsIds = function () { diff --git a/lib/render.js b/lib/render.js index a967ee4..0a20b10 100644 --- a/lib/render.js +++ b/lib/render.js @@ -307,11 +307,14 @@ Render.prototype.idLink = function (link, cb) { return a } -Render.prototype.privateLine = function (recps, cb) { +Render.prototype.privateLine = function (recps, isAuthorRecp, cb) { var done = multicb({pluck: 1, spread: true}) var self = this var el = h('div.recps', self.lockIcon(), + !isAuthorRecp ? [ + h('span', {title: 'Author is not a recipient'}, '[!]'), ' ' + ] : '', Array.isArray(recps) ? recps.map(function (recp) { return [' ', self.idLink(recp, done())] diff --git a/lib/serve.js b/lib/serve.js index e059f54..2eba468 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -3167,7 +3167,7 @@ Serve.prototype.composer = function (opts, cb) { h('input', {type: 'hidden', name: 'blobs', value: JSON.stringify(blobs)}), h('input', {type: 'hidden', name: 'composer_id', value: opts.id}), - opts.recps ? self.app.render.privateLine(opts.recps, done()) : + opts.recps ? self.app.render.privateLine(opts.recps, true, done()) : opts.private ? h('div', h('input.recps-input', {name: 'recps', value: data.recps || '', placeholder: 'recipient ids'})) : '', channel != null ? -- cgit v1.2.3