aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/app.js')
-rw-r--r--lib/app.js29
1 files changed, 29 insertions, 0 deletions
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)
+ })
+ )
+}