aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-04-19 02:34:56 -0700
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-04-19 02:40:16 -0700
commit1c2dae811b7b511f0346d86b1c7331a80b2af611 (patch)
tree6c2667e78e54df1142f922d390bdfe69508c758c
parentdb262b697b4b6b7bc1c76f183fc51bd99a57bd30 (diff)
downloadpatchfoo-1c2dae811b7b511f0346d86b1c7331a80b2af611.tar.gz
patchfoo-1c2dae811b7b511f0346d86b1c7331a80b2af611.zip
Reformat private message recipients input
-rw-r--r--lib/serve.js33
1 files changed, 21 insertions, 12 deletions
diff --git a/lib/serve.js b/lib/serve.js
index d3a1a6b..f9c954c 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -48,6 +48,14 @@ function encodeDispositionFilename(fname) {
return '"' + encodeURIComponent(fname) + '"'
}
+function uniques() {
+ var set = {}
+ return function (item) {
+ if (set[item]) return false
+ return set[item] = true
+ }
+}
+
function Serve(app, req, res) {
this.app = app
this.req = req
@@ -1183,18 +1191,20 @@ Serve.prototype.composer = function (opts, cb) {
.filter(function (mention) {
return mention.link === '@'
})
- .filter(function (mention) {
- if (unknownMentionNames[mention.name]) return false
- unknownMentionNames[mention.name] = true
- return true
- })
.map(function (mention) {
- var name = mention.name
- var fullName = mention.link + name
- var id = formNames[name] || self.app.getReverseNameSync(fullName)
- return {name: name, fullName: fullName, id: id}
+ return mention.name
+ })
+ .filter(uniques())
+ .map(function (name) {
+ var id = formNames[name] || self.app.getReverseNameSync('@' + name)
+ return {name: name, id: id}
})
+ // strip content other than feed ids from the recps field
+ if (data.recps) {
+ data.recps = u.extractFeedIds(data.recps).filter(uniques()).join(', ')
+ }
+
var done = multicb({pluck: 1, spread: true})
done()(null, h('section.composer',
h('form', {method: 'post', action: opts.id ? '#' + opts.id : '',
@@ -1218,7 +1228,7 @@ Serve.prototype.composer = function (opts, cb) {
h('div', h('em', 'names:')),
h('ul.mentions', unknownMentions.map(function (mention) {
return h('li',
- h('code', mention.fullName), ': ',
+ h('code', '@' + mention.name), ': ',
h('input', {name: 'mention_name', type: 'hidden',
value: mention.name}),
h('input.mention-id-input', {name: 'mention_id',
@@ -1264,8 +1274,7 @@ Serve.prototype.composer = function (opts, cb) {
} else if (mention.link === '@') {
// bare feed name
var name = mention.name
- var fullName = mention.link + name
- var id = formNames[name] || self.app.getReverseNameSync(fullName)
+ var id = formNames[name] || self.app.getReverseNameSync('@' + name)
if (id) mention.link = id
else return false
}