diff options
-rw-r--r-- | lib/app.js | 57 |
1 files changed, 55 insertions, 2 deletions
@@ -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() ) } |