git ssb

16+

Dominic / patchbay



Tree: c713144685decb84e2df39b0fcf3fc1cadab7528

Files: c713144685decb84e2df39b0fcf3fc1cadab7528 / modules_basic / message-name.js

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