Commit c343d27955954f95f2c6ce3302289420b7e1e075
can type in @name and get to feed quickly
Dominic Tarr committed on 12/16/2018, 11:35:57 AMParent: 400e46051f560a0554711aaff869e200a5ea7a8a
Files changed
apis/search.js | changed |
apis/search.js | ||
---|---|---|
@@ -9,8 +9,26 @@ | ||
9 | 9 | return api('message', {id: opts.query}) |
10 | 10 | if(ref.isFeed(opts.query)) |
11 | 11 | return api('public', {id: opts.query}) |
12 | 12 | |
13 | + if(/^@\w+$/.test(opts.query)) //is name | |
14 | + return function (cb) { | |
15 | + self.sbot.names.getSignifies(opts.query.substring(1), function (err, ids) { | |
16 | + if(err) return cb(err) | |
17 | + if(ids.length == 0) | |
18 | + cb(null, ['h1', 'no feed named:'+opts.query]) | |
19 | + else if(ids.length == 1) | |
20 | + cb(null, api('public', {author: ids[0].id})) | |
21 | + else | |
22 | + cb(null, ['div', | |
23 | + ['div', opts.query + ' may also refer to:'].concat(ids.slice(1).map(function (e) { | |
24 | + return api('avatar', {id: e.id, name: false}) | |
25 | + })), | |
26 | + api('public', {author: ids[0].id}) | |
27 | + ]) | |
28 | + }) | |
29 | + } | |
30 | + | |
13 | 31 | return pull( |
14 | 32 | self.sbot.search.query(opts), |
15 | 33 | pull.map(function (data) { |
16 | 34 | return api('message', data) |
@@ -19,4 +37,8 @@ | ||
19 | 37 | } |
20 | 38 | |
21 | 39 | |
22 | 40 | |
41 | + | |
42 | + | |
43 | + | |
44 | + |
Built with git-ssb-web