From a755d08d1cdfde6a9a48de38d8fdd779148709b8 Mon Sep 17 00:00:00 2001 From: cel Date: Wed, 12 Apr 2017 17:53:27 -0700 Subject: Add (un)follow button --- lib/app.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/app.js') diff --git a/lib/app.js b/lib/app.js index 6cc71a0..465e45b 100644 --- a/lib/app.js +++ b/lib/app.js @@ -201,6 +201,21 @@ App.prototype.streamPeers = function (opts) { }) } +App.prototype.getFollow = function (source, dest, cb) { + var self = this + pull( + self.sbot.links({source: source, dest: dest, rel: 'contact', values: true}), + pull.filter(function (msg) { + var c = msg && msg.value && msg.value.content + return c && c.type === 'contact' + }), + pull.reduce(function (doesFollow, msg) { + var c = msg.value.content + return !!c.following + }, false, cb) + ) +} + App.prototype.getFollows = function (id, cb) { var self = this pull( -- cgit v1.2.3