diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-12-24 11:47:06 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-12-24 12:19:27 -1000 |
commit | 6646ec3620bff75ffca314d5c0eb5019ea7c52e1 (patch) | |
tree | f3b7bdcf3670ae916979a3a4cd0f067efae963bb /lib/app.js | |
parent | 079499f482a67c8007cea211c9000eb90aa4e67a (diff) | |
download | patchfoo-6646ec3620bff75ffca314d5c0eb5019ea7c52e1.tar.gz patchfoo-6646ec3620bff75ffca314d5c0eb5019ea7c52e1.zip |
Render talenet messages
Diffstat (limited to 'lib/app.js')
-rw-r--r-- | lib/app.js | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -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) + }) + ) +} |