git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 37af73bc5ddcbd3b63159caf24f253e95f6f3664

Files: 37af73bc5ddcbd3b63159caf24f253e95f6f3664 / message / sync / is-blocked.js

740 bytesRaw
1const nest = require('depnest')
2
3exports.gives = nest('message.sync.isBlocked')
4
5exports.needs = nest({
6 'contact.obs.blocking': 'first',
7 'contact.obs.raw': 'first',
8 'keys.sync.id': 'first'
9})
10
11exports.create = function (api) {
12 var cache = null
13
14 return nest('message.sync.isBlocked', function isBlockedMessage (msg, rootMessage) {
15 if (!cache) {
16 cache = api.contact.obs.blocking(api.keys.sync.id())
17 }
18
19 if (rootMessage) {
20 // check if the author of the root message blocks the author of the message
21 var rawContact = api.contact.obs.raw(rootMessage.value.author)
22 if (rawContact()[msg.value.author] === false) {
23 return true
24 }
25 }
26
27 return cache().includes(msg.value.author)
28 })
29}
30

Built with git-ssb-web