Files: b65df85068d01bbc7fd6b0ba8686cccbae6928ee / modules / message-name.js
739 bytesRaw
1 | |
2 | function title (s) { |
3 | var m = /^\n*([^\n]{0,40})/.exec(s) |
4 | return m && (m[1].length == 40 ? m[1]+'...' : m[1]) |
5 | } |
6 | |
7 | exports.needs = { sbot_get: 'first' } |
8 | exports.gives = 'message_name' |
9 | |
10 | exports.create = function (api) { |
11 | return function (id, cb) { |
12 | api.sbot_get(id, function (err, value) { |
13 | if(err && err.name == 'NotFoundError') |
14 | return cb(null, id.substring(0, 10)+'...(missing)') |
15 | if(value.content.type === 'post' && 'string' === typeof value.content.text) |
16 | return cb(null, title(value.content.text)) |
17 | else if('string' === typeof value.content.text) |
18 | return cb(null, value.content.type + ':'+title(value.content.text)) |
19 | else |
20 | return cb(null, id.substring(0, 10)+'...') |
21 | }) |
22 | } |
23 | } |
24 | |
25 |
Built with git-ssb-web