diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-01-28 23:31:47 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-01-29 00:20:15 -1000 |
commit | 6cf5e1b999c6e59b1f8092a99d6b0a462a016b34 (patch) | |
tree | 401e39ce07f351cbf05c6f8f6ac688332a057553 /lib | |
parent | b705fe62e350ac3087feb811b0390c7fd2f9a20f (diff) | |
download | patchfoo-6cf5e1b999c6e59b1f8092a99d6b0a462a016b34.tar.gz patchfoo-6cf5e1b999c6e59b1f8092a99d6b0a462a016b34.zip |
Recognize more ways of finding pub addresses
Diffstat (limited to 'lib')
-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() ) } |