diff options
-rw-r--r-- | lib/serve.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/serve.js b/lib/serve.js index 452cad4..e05cc56 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -60,6 +60,14 @@ function uniques() { } } +function reduceLink(link) { + return link + && typeof link.link === 'string' + && typeof link.name === 'undefined' + && Object.keys(link).length === 1 + ? link.link : link +} + function Serve(app, req, res) { this.app = app this.req = req @@ -1462,7 +1470,7 @@ Serve.prototype.editGathering = function (url) { // don't mention ids already mentioned in the thread textMentions.forEach(function (link) { if (mentions.indexOf(link.link) === -1) { - mentions.push(link) + mentions.push(reduceLink(link)) } }) } @@ -1611,6 +1619,7 @@ Serve.prototype.newGathering = function () { if (description) { content.description = description var mentions = ssbMentions(description, {bareFeedNames: false, emoji: false}) + .map(reduceLink) if (mentions.length) content.mentions = mentions } if (startDateTime) content.startDateTime = startDateTime @@ -4501,6 +4510,8 @@ Serve.prototype.composer = function (opts, cb) { } return true }) + .map(reduceLink) + if (mentions.length) content.mentions = mentions if (data.recps != null) { if (opts.recps) return cb(new Error('got recps in opts and data')) @@ -4555,7 +4566,7 @@ Serve.prototype.composer = function (opts, cb) { alreadyMentioned[id] = true }) attendeeLinks.forEach(function (link) { - if (!alreadyMentioned[link.link]) content.mentions.push(link) + if (!alreadyMentioned[link]) content.mentions.push(link) }) } } |