aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/contacts.js21
-rw-r--r--lib/serve.js12
2 files changed, 29 insertions, 4 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,
}
diff --git a/lib/serve.js b/lib/serve.js
index 0ca35a6..3db1c3c 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -879,7 +879,11 @@ Serve.prototype.tags = function (path) {
Serve.prototype.contacts = function (path) {
var self = this
var id = String(path).substr(1)
- var contacts = self.app.contacts.createContactStreams({id: id, msgIds: true})
+ var contacts = self.app.contacts.createContactStreams({
+ id: id,
+ msgIds: true,
+ enemies: true
+ })
var render = self.app.render
pull(
@@ -895,7 +899,11 @@ Serve.prototype.contacts = function (path) {
ph('h4', {}, 'Blocks'),
render.friendsList('/contacts/')(contacts.blocks),
ph('h4', {}, 'Blocked by'),
- render.friendsList('/contacts/')(contacts.blockers)
+ render.friendsList('/contacts/')(contacts.blockers),
+ contacts.enemies ? [
+ ph('h4', {}, 'Enemies'),
+ render.friendsList('/contacts/')(contacts.enemies),
+ ] : ''
])
]),
this.wrapPage('contacts: ' + id),