aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/app.js')
-rw-r--r--lib/app.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/app.js b/lib/app.js
index d994d04..530f10f 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -31,8 +31,9 @@ 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)}, getAbout, sbot, sbot.id)
+ this.getAbout = memo({cache: lru(100)}, getAbout.bind(this), sbot, sbot.id)
this.unboxContent = memo({cache: lru(100)}, sbot.private.unbox)
+ this.reverseNameCache = lru(100)
this.unboxMsg = this.unboxMsg.bind(this)
@@ -110,9 +111,15 @@ App.prototype.addBlob = function (cb) {
}
App.prototype.pushBlob = function (id, cb) {
+ console.error('pushing blob', id)
this.sbot.blobs.push(id, cb)
}
+App.prototype.getReverseNameSync = function (name) {
+ var id = this.reverseNameCache.get(name)
+ return id
+}
+
function getMsgWithValue(sbot, id, cb) {
sbot.get(id, function (err, value) {
if (err) return cb(err)
@@ -121,12 +128,14 @@ function getMsgWithValue(sbot, id, cb) {
}
function getAbout(sbot, src, id, cb) {
+ var self = this
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
}
+ self.reverseNameCache.set(about.name, id)
cb(null, about)
})
}