aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-12-05 17:55:54 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-12-07 16:48:50 -1000
commit0ea52b9a188055c1bcf1e256c07251dfdc274a45 (patch)
tree3efcbf02fedb759c17cf78e036686faf3286f7ae
parent01ea88684375793b3e009d8cefb9722384e2c88b (diff)
downloadpatchfoo-0ea52b9a188055c1bcf1e256c07251dfdc274a45.tar.gz
patchfoo-0ea52b9a188055c1bcf1e256c07251dfdc274a45.zip
Reply mention feeds
-rw-r--r--README.md1
-rw-r--r--lib/serve.js15
2 files changed, 16 insertions, 0 deletions
diff --git a/README.md b/README.md
index deb1fa2..423442c 100644
--- a/README.md
+++ b/README.md
@@ -135,6 +135,7 @@ To make config options persistent, set them in `~/.ssb/config`, e.g.:
- `draftsDir: name of directory in patchfoo's directory (as set by `patchfoo.dir` config option above) to use for message draft data. default: `"drafts"`.
- `newLimit: limit of messages to show on `/new` page. Default: 500. Overridable with query string parameter `limit=...`.
- `dualMarkdownPreview`: Preview messages in composer in multiple SSB markdown implementations, `ssb-marked` and `ssb-markdown` >= 3. Overridable with query string parameter `dualMd=1`.
+- `replyMentionFeeds`: Mention thread branch authors in "reply" property, like Patchwork. Default `true`.
## TODO
diff --git a/lib/serve.js b/lib/serve.js
index d9df589..f037783 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -116,6 +116,9 @@ Serve.prototype.go = function () {
}
}
+ this.replyMentionFeeds = conf.replyMentionFeeds == null ? true :
+ Boolean(conf.replyMentionFeeds)
+
if (this.req.method === 'POST' || this.req.method === 'PUT') {
if (/^multipart\/form-data/.test(this.req.headers['content-type'])) {
var data = {}
@@ -3893,6 +3896,18 @@ Serve.prototype.composer = function (opts, cb) {
}
]
}
+
+ if (self.replyMentionFeeds && links && content.branch) {
+ var reply = {}
+ var ids = {}
+ u.toArray(content.branch).forEach(function (branch) {
+ ids[branch] = true
+ })
+ links.forEach(function (link) {
+ if (ids[link.key]) reply[link.key] = link.value.author
+ })
+ if (Object.keys(reply).length > 0) content.reply = reply
+ }
if (data.content_warning) content.contentWarning = String(data.content_warning)
if (channel) content.channel = data.channel