From 6646ec3620bff75ffca314d5c0eb5019ea7c52e1 Mon Sep 17 00:00:00 2001 From: cel Date: Sun, 24 Dec 2017 11:47:06 -1000 Subject: Render talenet messages --- lib/app.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'lib/app.js') diff --git a/lib/app.js b/lib/app.js index 4068530..1c3647b 100644 --- a/lib/app.js +++ b/lib/app.js @@ -53,6 +53,7 @@ function App(sbot, config) { this.getBlobSize = memo({cache: this.blobSizeCache = lru(100)}, sbot.blobs.size.bind(sbot.blobs)) this.getVotes = memo({cache: lru(100)}, this._getVotes.bind(this)) + this.getIdeaTitle = memo({cache: lru(100)}, this.getIdeaTitle) this.unboxMsg = this.unboxMsg.bind(this) @@ -776,3 +777,31 @@ App.prototype.getAddresses = function (id) { pull.unique() ) } + +App.prototype.getIdeaTitle = function (id, cb) { + pull( + this.sbot.backlinks.read({ + reverse: true, + query: [ + {$filter: { + dest: id, + value: { + content: { + type: 'talenet-idea-update', + ideaKey: id, + title: {$truthy: true} + } + } + }}, + {$map: ['value', 'content', 'title']} + ] + }), + pull.take(1), + pull.collect(function (err, titles) { + if (err) return cb(err) + var title = titles && titles[0] + || (String(id).substr(0, 8) + '…') + cb(null, title) + }) + ) +} -- cgit v1.2.3