Commit f3885cfda231da4263dec7ed80d25979cd50a76f
get block working correctly
Dominic Tarr committed on 5/31/2017, 11:49:21 AMParent: 4bbdcb0f89770891b04720e98b31f99295fe0d13
Files changed
plugins/block.js | changed |
plugins/friends.js | changed |
plugins/replicate/index.js | changed |
plugins/block.js | ||
---|---|---|
@@ -29,11 +29,15 @@ | ||
29 | 29 | } |
30 | 30 | |
31 | 31 | sbot.createHistoryStream.hook(function (fn, args) { |
32 | 32 | var opts = args[0], id = this.id |
33 | - if(opts.id !== this.id && isBlocked({source: opts.id, dest: this.id})) | |
34 | - return fn({id: null, sequence: 0}) | |
35 | - else | |
33 | + //reminder: this.id is the remote caller. | |
34 | + if(opts.id !== this.id && isBlocked({source: opts.id, dest: id})) { | |
35 | + return function (abort, cb) { | |
36 | + //just give them the cold shoulder | |
37 | + } | |
38 | +// return fn({id: null, sequence: 0}) | |
39 | + } else | |
36 | 40 | return pull( |
37 | 41 | fn.apply(this, args), |
38 | 42 | //break off this feed if they suddenly block |
39 | 43 | //the recipient. |
@@ -57,4 +61,5 @@ | ||
57 | 61 | |
58 | 62 | return {isBlocked: valid.sync(isBlocked, 'feedId|isBlockedOpts') } |
59 | 63 | |
60 | 64 | } |
65 | + |
plugins/friends.js | ||
---|---|---|
@@ -93,11 +93,11 @@ | ||
93 | 93 | if(block.isWanted(reachable[k])) |
94 | 94 | push(k, reachable[k][0]) |
95 | 95 | } else { |
96 | 96 | var _reachable = F.reachable(g, start, block) |
97 | - var patch = F.diff(reachable, _reachable) | |
97 | + var patch = F.diff(reachable, _reachable, block) | |
98 | 98 | for(var k in patch) { |
99 | - if(patch[k] == null) | |
99 | + if(patch[k] == null || patch[k][0] == null || patch[k][0] > patch[k][1]) | |
100 | 100 | push(k, -1) |
101 | 101 | else if(block.isWanted(patch[k])) |
102 | 102 | push(k, patch[k][0]) |
103 | 103 | } |
@@ -121,9 +121,4 @@ | ||
121 | 121 | }) |
122 | 122 | } |
123 | 123 | } |
124 | 124 | } |
125 | - | |
126 | - | |
127 | - | |
128 | - | |
129 | - |
plugins/replicate/index.js | ||
---|---|---|
@@ -24,15 +24,18 @@ | ||
24 | 24 | //to add things is easy, you just call replicate.request(id) |
25 | 25 | //calls to replicate.request(id) are ephemeral, |
26 | 26 | //and must be made each time run sbot. |
27 | 27 | pull( |
28 | - sbot.friends.createFriendStream({live: true, meta: false}), | |
28 | + sbot.friends.createFriendStream({live: true, meta: true}), | |
29 | 29 | // filter out duplicates, and also keep track of what we expect to receive |
30 | 30 | // lookup the latest sequence from each user |
31 | 31 | // TODO: use paramap? |
32 | - pull.drain(function (id) { | |
33 | - if(id.sync) return | |
34 | - replicate.request(id) | |
32 | + pull.drain(function (data) { | |
33 | + if(data.sync) return | |
34 | + if(data.hops >= 0) | |
35 | + replicate.request(data.id) | |
36 | + else | |
37 | + replicate.request(data.id, false) | |
35 | 38 | }) |
36 | 39 | ) |
37 | 40 | |
38 | 41 | return replicate |
@@ -40,4 +43,5 @@ | ||
40 | 43 | } |
41 | 44 | } |
42 | 45 | |
43 | 46 | |
47 | + |
Built with git-ssb-web