diff options
Diffstat (limited to 'lib/app.js')
-rw-r--r-- | lib/app.js | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -4,6 +4,7 @@ var lru = require('lrucache') var pkg = require('../package') var u = require('./util') var pull = require('pull-stream') +var ssbAvatar = require('ssb-avatar') var Serve = require('./serve') var Render = require('./render') @@ -28,7 +29,7 @@ function App(sbot, config) { sbot.get = memo({cache: lru(100)}, sbot.get) this.getMsg = memo({cache: lru(100)}, getMsgWithValue, sbot) - this.getAbout = memo({cache: lru(100)}, require('ssb-avatar'), sbot, sbot.id) + this.getAbout = memo({cache: lru(100)}, getAbout, sbot, sbot.id) this.unboxContent = memo({cache: lru(100)}, sbot.private.unbox) this.unboxMsg = this.unboxMsg.bind(this) @@ -97,3 +98,14 @@ function getMsgWithValue(sbot, id, cb) { cb(null, {key: id, value: value}) }) } + +function getAbout(sbot, src, id, cb) { + ssbAvatar(sbot, src, id, function (err, about) { + if (err) return cb(err) + var sigil = id && id[0] || '@' + if (about.name && about.name[0] !== sigil) { + about.name = sigil + about.name + } + cb(null, about) + }) +} |