git ssb

16+

Dominic / patchbay



Tree: 1ebcea6c780b22911d8d71b9326be4539254272a

Files: 1ebcea6c780b22911d8d71b9326be4539254272a / 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