From 3b4e38cc4b02d5f47a531c3029520e67d98d6d10 Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 28 Jan 2019 20:22:36 -1000 Subject: Add mute (private block) button --- lib/app.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'lib/app.js') diff --git a/lib/app.js b/lib/app.js index 0b7784c..3b56da7 100644 --- a/lib/app.js +++ b/lib/app.js @@ -514,7 +514,7 @@ App.prototype.getContact = function (source, dest, cb) { self.sbot.links({source: source, dest: dest, rel: 'contact', reverse: true, values: true, meta: false, keys: false}), pull.filter(function (value) { - var c = value && value.content + var c = value && !value.private && value.content return c && c.type === 'contact' }), pull.take(1), @@ -527,6 +527,27 @@ App.prototype.getContact = function (source, dest, cb) { ) } +App.prototype.isMuted = function (id, cb) { + var self = this + pull( + self.sbot.links({source: self.sbot.id, dest: id, rel: 'contact', reverse: true, + values: true}), + pull.filter(function (msg) { + return msg && msg.value && typeof msg.value.content === 'string' + }), + this.unboxMessages(), + pull.filter(function (msg) { + var c = msg && msg.value && msg && msg.value.content + return c && c.type === 'contact' + }), + pull.take(1), + pull.reduce(function (acc, msg) { + var c = msg && msg.value && msg.value.content + return c.following ? false : c.flagged || c.blocking ? true : null + }, null, cb) + ) +} + App.prototype.unboxMessages = function () { return paramap(this.unboxMsg, 16) } -- cgit v1.2.3