aboutsummaryrefslogtreecommitdiff
path: root/lib/contacts.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/contacts.js')
-rw-r--r--lib/contacts.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/contacts.js b/lib/contacts.js
index 846cdf9..e1d4a0a 100644
--- a/lib/contacts.js
+++ b/lib/contacts.js
@@ -88,6 +88,7 @@ Contacts.prototype.createFriendsStream = function (opts, endCb) {
var msgIds = opts.msgIds
var follows = {}, followers = {}
var blocks = {}, blockers = {}
+ var enemies = opts.enemies && {}
return pull(
many([
this._createContactStream(id, null),
@@ -114,9 +115,21 @@ Contacts.prototype.createFriendsStream = function (opts, endCb) {
}
} else if (edge.value === false) {
if (edge.source === id) {
- blocks[edge.dest] = msgIds ? {feed: edge.dest, msg: edge.msg} : edge.dest
+ if (enemies && blockers[edge.dest]) {
+ var item2 = blockers[edge.dest]
+ delete blockers[edge.dest]
+ enemies[edge.dest] = msgIds ? {feed: edge.dest, msg: edge.msg, msg2: item2.msg} : edge.dest
+ } else {
+ blocks[edge.dest] = msgIds ? {feed: edge.dest, msg: edge.msg} : edge.dest
+ }
} else if (edge.dest === id) {
- blockers[edge.source] = msgIds ? {feed: edge.source, msg: edge.msg} : edge.source
+ if (enemies && blocks[edge.source]) {
+ var item2 = blocks[edge.source]
+ delete blocks[edge.source]
+ enemies[edge.source] = msgIds ? {feed: edge.source, msg: edge.msg, msg2: item2.msg} : edge.source
+ } else {
+ blockers[edge.source] = msgIds ? {feed: edge.source, msg: edge.msg} : edge.source
+ }
}
}
}),
@@ -130,6 +143,7 @@ Contacts.prototype.createFriendsStream = function (opts, endCb) {
follows: Object.values(follows),
blocks: Object.values(blocks),
blockers: Object.values(blockers),
+ enemies: Object.values(enemies),
})
})
}
@@ -143,16 +157,19 @@ Contacts.prototype.createContactStreams = function (opts) {
var followers = defer.source()
var blocks = defer.source()
var blockers = defer.source()
+ var enemies = defer.source()
var friends = this.createFriendsStream(opts, function (err, more) {
follows.resolve(err ? pull.error(err) : pull.values(more.follows))
followers.resolve(err ? pull.error(err) : pull.values(more.followers))
blocks.resolve(err ? pull.error(err) : pull.values(more.blocks))
blockers.resolve(err ? pull.error(err) : pull.values(more.blockers))
+ enemies.resolve(err ? pull.error(err) : pull.values(more.enemies))
})
return {
friends: friends,
follows: follows,
followers: followers,
+ enemies: enemies,
blocks: blocks,
blockers: blockers,
}