git ssb

16+

Dominic / patchbay



Tree: 7c8e28be85762984790fb8433e8ceb84c5ccf8e5

Files: 7c8e28be85762984790fb8433e8ceb84c5ccf8e5 / modules_basic / message-name.js

681 bytesRaw
1
2var sbot_get = require('../plugs').first(exports.sbot_get = [])
3
4function title (s) {
5 var m = /^[^\n]{0,40}/.exec(s)
6 return m && (m[0].length == 40 ? m[0]+'...' : m[0])
7}
8
9exports.message_name = function (id, cb) {
10 sbot_get(id, function (err, value) {
11 if(err && err.name == 'NotFoundError')
12 return cb(null, id.substring(0, 10)+'...(missing)')
13 if(value.content.type === 'post' && 'string' === typeof value.content.text)
14 return cb(null, title(value.content.text))
15 else if('string' === typeof value.content.text)
16 return cb(null, value.content.type + ':'+title(value.content.text))
17 else
18 return cb(null, id.substring(0, 10)+'...')
19 })
20}
21
22

Built with git-ssb-web