From 59bfa01faf1939dc6b327b05439cb0b23cfddcfa Mon Sep 17 00:00:00 2001 From: cel Date: Fri, 17 Nov 2017 00:33:18 -0500 Subject: Show pub addresses --- lib/app.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'lib/app.js') diff --git a/lib/app.js b/lib/app.js index 7d8516a..5557b58 100644 --- a/lib/app.js +++ b/lib/app.js @@ -764,3 +764,38 @@ App.prototype._getVotes = function (id, cb) { }) ) } + +App.prototype.getAddresses = function (id) { + if (!this.sbot.backlinks) { + if (!this.warned1) { + this.warned1 = true + console.trace('Getting peer addresses requires the ssb-backlinks plugin') + } + return pull.empty() + } + return pull( + this.sbot.backlinks.read({ + reverse: true, + query: [ + {$filter: { + dest: id, + value: { + content: { + type: 'pub', + address: { + key: id, + host: {$truthy: true}, + port: {$truthy: true}, + } + } + } + }}, + {$map: ['value', 'content', 'address']} + ] + }), + pull.map(function (addr) { + return addr.host + ':' + addr.port + }), + pull.unique() + ) +} -- cgit v1.2.3