From c0b22799da2d39c7224fd51537b5216cd078355c Mon Sep 17 00:00:00 2001 From: Stephen Whitmore Date: Mon, 26 Mar 2018 18:58:30 -0700 Subject: feat: parse "@name" ids as private msg recipients --- lib/serve.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'lib') 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 = { -- cgit v1.2.3