From b705fe62e350ac3087feb811b0390c7fd2f9a20f Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 28 Jan 2019 23:30:51 -1000 Subject: Move pub addresses out of profile page --- lib/app.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'lib/app.js') diff --git a/lib/app.js b/lib/app.js index 3b56da7..bac3d53 100644 --- a/lib/app.js +++ b/lib/app.js @@ -977,6 +977,46 @@ App.prototype.getAddresses = function (id) { ) } +App.prototype.isPub = function (id, cb) { + if (!this.sbot.backlinks) { + return pull( + this.sbot.links({ + dest: id, + rel: 'pub' + }), + pull.take(1), + pull.collect(function (err, links) { + if (err) return cb(err) + cb(null, links.length == 1) + }) + ) + } + return pull( + this.sbot.backlinks.read({ + limit: 1, + query: [ + {$filter: { + dest: id, + value: { + content: { + type: 'pub', + address: { + key: id, + host: {$truthy: true}, + port: {$truthy: true}, + } + } + } + }} + ] + }), + pull.collect(function (err, msgs) { + if (err) return cb(err) + cb(null, msgs.length == 1) + }) + ) +} + App.prototype.getIdeaTitle = function (id, cb) { if (!this.sbot.backlinks) return cb(null, String(id).substr(0, 8) + '…') pull( -- cgit v1.2.3