diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | lib/app.js | 7 |
2 files changed, 7 insertions, 2 deletions
@@ -72,6 +72,7 @@ To make config options persistent, set them in `~/.ssb/config`, e.g.: "port": 8027, "host": "::", "filter": "all", + "showPrivates": true, } } ``` @@ -87,6 +88,7 @@ To make config options persistent, set them in `~/.ssb/config`, e.g.: - `encode_msgids`: whether to URL-encode message ids in local links. default: `true` - `auth`: HTTP auth password. default: `null` (no password required) - `filter`: Filter setting. `"all"` to show all messages. `"invert"` to show messages that would be hidden by the default setting. Otherwise the default setting applies, which is so to only show messages authored or upvoted by yourself or by a feed that you you follow. Exceptions are that if you navigate to a user feed page, you will see messages authored by that feed, and if you navigate to a message page, you will see that message - regardless of the filter setting. The `filter` setting may also be specified per-request as a query string parameter. +- `showPrivates`: Whether or not to show private messages. Default is `true`. Overridden by `filter=all`. ## TODO @@ -30,6 +30,7 @@ function App(sbot, config) { this.port = conf.port || 8027 this.host = conf.host || 'localhost' this.msgFilter = conf.filter + this.showPrivates = conf.showPrivates == null ? true : conf.showPrivates var base = conf.base || '/' this.opts = { @@ -687,9 +688,11 @@ App.prototype.filterMsg = function (msg, opts, cb) { var myId = self.sbot.id var author = msg.value && msg.value.author var filter = opts.filter || self.msgFilter + if (filter === 'all') return cb(null, true) var show = (filter !== 'invert') - if (filter === 'all' - || author === myId + var isPrivate = msg.value && typeof msg.value.content === 'string' + if (isPrivate && !self.showPrivates) return cb(null, !show) + if (author === myId || author === opts.feed || msg.key === opts.msgId) return cb(null, show) self.follows.getFollows(myId, function (err, follows) { |