git ssb

3+

dangerousbeans / scuttle-vue



Tree: 8dc25143a3f37f1618f7a92b3c46dec512b43bfd

Files: 8dc25143a3f37f1618f7a92b3c46dec512b43bfd / modules / message-name.js

739 bytesRaw
1
2function title (s) {
3 var m = /^\n*([^\n]{0,40})/.exec(s)
4 return m && (m[1].length == 40 ? m[1]+'...' : m[1])
5}
6
7exports.needs = { sbot_get: 'first' }
8exports.gives = 'message_name'
9
10exports.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