From 6cf5e1b999c6e59b1f8092a99d6b0a462a016b34 Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 28 Jan 2019 23:31:47 -1000 Subject: Recognize more ways of finding pub addresses --- lib/app.js | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/lib/app.js b/lib/app.js index bac3d53..031077f 100644 --- a/lib/app.js +++ b/lib/app.js @@ -950,7 +950,8 @@ App.prototype.getAddresses = function (id) { } return pull.empty() } - return pull( + + var pubMsgAddresses = pull( this.sbot.backlinks.read({ reverse: true, query: [ @@ -972,7 +973,59 @@ App.prototype.getAddresses = function (id) { }), pull.map(function (addr) { return addr.host + ':' + addr.port - }), + }) + ) + + var newerAddresses = pull( + cat([ + this.sbot.query.read({ + reverse: true, + limit: 1, + query: [ + {$filter: { + value: { + author: id, + content: { + type: 'address', + address: {$truthy: true} + } + } + }}, + {$map: ['value', 'content', 'address']} + ] + }), + this.sbot.query.read({ + reverse: true, + limit: 1, + query: [ + {$filter: { + value: { + author: id, + content: { + type: 'pub-owner-confirm', + address: {$truthy: true} + } + } + }}, + {$map: ['value', 'content', 'address']} + ] + }) + ]), + pull.map(function (addr) { + var i = addr.lastIndexOf(':' + id) + if (i > -1 && addr.length === i + id.length + 1) { + return addr.substr(0, i) + } + var m = /^(?:net|onion):([^~;]*:[0-9]*)~shs:([0-9a-zA-Z/=+]{44})/.exec(addr) + if (m && id === '@' + m[2] + '.ed25519') { + return m[1] + } + return addr + }) + ) + + return pull( + cat([newerAddresses, pubMsgAddresses]), pull.unique() ) } -- cgit v1.2.3