aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-01-28 20:22:36 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-01-28 21:16:41 -1000
commit3b4e38cc4b02d5f47a531c3029520e67d98d6d10 (patch)
treebbef367f84922ce6f079613e4526306977ffa227 /lib
parentf002fac331c79baff7fde57899d76be0410ffe10 (diff)
downloadpatchfoo-3b4e38cc4b02d5f47a531c3029520e67d98d6d10.tar.gz
patchfoo-3b4e38cc4b02d5f47a531c3029520e67d98d6d10.zip
Add mute (private block) button
Diffstat (limited to 'lib')
-rw-r--r--lib/app.js23
-rw-r--r--lib/serve.js12
2 files changed, 32 insertions, 3 deletions
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)
}
diff --git a/lib/serve.js b/lib/serve.js
index 30b529b..7eefc9f 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -219,6 +219,9 @@ Serve.prototype.publishContact = function (next) {
if (this.data.block) content.blocking = true
if (this.data.unfollow) content.following = false
if (this.data.unblock) content.blocking = false
+ if (this.data.mute) content.blocking = true
+ if (this.data.unmute) content.blocking = false
+ if (this.data.mute || this.data.unmute) content.recps = [this.app.sbot.id]
if (this.app.previewContacts) {
var json = JSON.stringify(content, 0, 2)
var q = qs.stringify({text: json, action: 'preview'})
@@ -1757,7 +1760,8 @@ Serve.prototype.followInfo = function (id, myId) {
var done = multicb({pluck: 1, spread: true})
self.app.getContact(myId, id, done())
self.app.getContact(id, myId, done())
- done(function (err, contactToThem, contactFromThem) {
+ self.app.isMuted(id, done())
+ done(function (err, contactToThem, contactFromThem, isMuted) {
if (err) return cb(err)
cb(null, ph('form', {action: '', method: 'post'}, [
contactFromThem ? contactToThem ? 'friend ' : 'follows you ' :
@@ -1769,7 +1773,11 @@ Serve.prototype.followInfo = function (id, myId) {
value: contactToThem ? 'unfollow' : 'follow'}), ' ',
ph('input', {type: 'submit',
name: contactToThem === false ? 'unblock' : 'block',
- value: contactToThem === false ? 'unblock' : 'block'})
+ value: contactToThem === false ? 'unblock' : 'block'}), ' ',
+ ph('input', {type: 'submit',
+ name: isMuted ? 'unmute' : 'mute',
+ value: isMuted ? 'unmute' : 'mute',
+ title: isMuted ? 'unmute (private unblock)' : 'mute (private block)'})
]))
})
})