Commit d0b1c05b483fa6de9080159f9713c98893cdb358
use first line as message title
Dominic Tarr committed on 11/12/2016, 4:23:57 PMParent: da116a36a6e34b4499633c0a896b9bf32d263383
Files changed
modules_basic/message-name.js | changed |
modules_basic/message-name.js | |||
---|---|---|---|
@@ -1,15 +1,21 @@ | |||
1 | 1 … | ||
2 | 2 … | var sbot_get = require('../plugs').first(exports.sbot_get = []) | |
3 | 3 … | ||
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 … | + | ||
4 | 9 … | exports.message_name = function (id, cb) { | |
5 | 10 … | sbot_get(id, function (err, value) { | |
6 | 11 … | if(err && err.name == 'NotFoundError') | |
7 | 12 … | return cb(null, id.substring(0, 10)+'...(missing)') | |
8 | 13 … | 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)) | ||
10 | 15 … | 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)) | ||
12 | 17 … | else | |
13 | 18 … | return cb(null, id.substring(0, 10)+'...') | |
14 | 19 … | }) | |
15 | 20 … | } | |
21 … | + |
Built with git-ssb-web