git ssb

16+

Dominic / patchbay



Commit d0b1c05b483fa6de9080159f9713c98893cdb358

use first line as message title

Dominic Tarr committed on 11/12/2016, 4:23:57 PM
Parent: da116a36a6e34b4499633c0a896b9bf32d263383

Files changed

modules_basic/message-name.jschanged
modules_basic/message-name.jsView
@@ -1,15 +1,21 @@
11
22 var sbot_get = require('../plugs').first(exports.sbot_get = [])
33
4 +function title (s) {
5 + var m = /^[^\n]{0,40}/.exec(s)
6 + return m && (m[0].length == 40 ? m[0]+'...' : m[0])
7 +}
8 +
49 exports.message_name = function (id, cb) {
510 sbot_get(id, function (err, value) {
611 if(err && err.name == 'NotFoundError')
712 return cb(null, id.substring(0, 10)+'...(missing)')
813 if(value.content.type === 'post' && 'string' === typeof value.content.text)
9- return cb(null, value.content.text.substring(0, 40)+'...')
14 + return cb(null, title(value.content.text))
1015 else if('string' === typeof value.content.text)
11- return cb(null, value.content.type + ':'+value.content.text.substring(0, 20))
16 + return cb(null, value.content.type + ':'+title(value.content.text))
1217 else
1318 return cb(null, id.substring(0, 10)+'...')
1419 })
1520 }
21 +

Built with git-ssb-web