aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
authorcel <cel@lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519>2020-03-24 14:11:12 -0400
committercel <cel@lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519>2020-03-28 13:55:28 -0400
commitf97cda0d14184878c8466409c588de39a7651b15 (patch)
treed615d11ba11f3f6560ad4ba6826262cd23b4c3f2 /lib/serve.js
parenta7f5b23b2eb2b101fd1bb40cb77fbf879dc6fd0f (diff)
downloadpatchfoo-f97cda0d14184878c8466409c588de39a7651b15.tar.gz
patchfoo-f97cda0d14184878c8466409c588de39a7651b15.zip
Reduce mentions
Save message size by changing {link: id} to id
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js15
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)
})
}
}