aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Whitmore <sww@eight45.net>2018-03-26 18:58:30 -0700
committerStephen Whitmore <sww@eight45.net>2018-03-26 18:58:30 -0700
commitc0b22799da2d39c7224fd51537b5216cd078355c (patch)
tree09013a72ca3d1aa5dbc5f34e03239a4fc3e62765
parente3399db341ae6987497859b0c43828081134c7ac (diff)
downloadpatchfoo-c0b22799da2d39c7224fd51537b5216cd078355c.tar.gz
patchfoo-c0b22799da2d39c7224fd51537b5216cd078355c.zip
feat: parse "@name" ids as private msg recipients
-rw-r--r--lib/serve.js26
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 09f7aa3..1bf2196 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -76,7 +76,7 @@ Serve.prototype.go = function () {
var auth = this.req.headers['authorization']
var tok = null
//console.log('Authorization: ',auth)
-
+
if (auth) {
var a = auth.split(' ')
if (a[0] == 'Basic') {
@@ -3052,9 +3052,9 @@ Serve.prototype.composer = function (opts, cb) {
return {name: name, id: id}
})
- // strip content other than feed ids from the recps field
+ // strip content other than names and feed ids from the recps field
if (data.recps) {
- data.recps = u.extractFeedIds(data.recps).filter(uniques()).join(', ')
+ data.recps = recpsToFeedIds(data.recps)
}
var done = multicb({pluck: 1, spread: true})
@@ -3125,6 +3125,26 @@ Serve.prototype.composer = function (opts, cb) {
))
done(cb)
+ function recpsToFeedIds (recps) {
+ var res = data.recps.split(',')
+ .map(function (str) {
+ str = str.trim()
+ var ids = u.extractFeedIds(str).filter(uniques())
+ if (ids.length >= 1) {
+ return ids[0]
+ } else {
+ ids = u.extractFeedIds(self.app.getReverseNameSync(str))
+ if (ids.length >= 1) {
+ return ids[0]
+ } else {
+ return null
+ }
+ }
+ })
+ .filter(Boolean)
+ return res.join(', ')
+ }
+
function prepareContent(cb) {
var done = multicb({pluck: 1})
content = {