tools.jsView |
---|
12 | 12 | var config = require('./config')() |
13 | 13 | |
14 | 14 | var id = require('./keys').id |
15 | 15 | |
| 16 | + |
| 17 | +module.exports.getBlocks = function (src) { |
| 18 | + var blocks = h('div.blocks', 'Blocking: ') |
| 19 | + |
| 20 | + pull( |
| 21 | + sbot.query({query: [{$filter: { value: { author: src, content: {type: 'contact'}}}}], live: true}), |
| 22 | + pull.drain(function (msg) { |
| 23 | + if (msg.value) { |
| 24 | + if (msg.value.content.blocking == true) { |
| 25 | + console.log(msg.value) |
| 26 | + var gotIt = document.getElementById('blocks:' + msg.value.content.contact.substring(0, 44)) |
| 27 | + if (gotIt == null) { |
| 28 | + blocks.appendChild(h('a#blocks:'+ msg.value.content.contact.substring(0, 44), {title: avatar.cachedName(msg.value.content.contact).textContent, href: '#' + msg.value.content.contact}, h('span.avatar--small', avatar.cachedImage(msg.value.content.contact)))) |
| 29 | + } |
| 30 | + } |
| 31 | + if (msg.value.content.blocking == false) { |
| 32 | + var gotIt = document.getElementById('blocks:' + msg.value.content.contact.substring(0, 44)) |
| 33 | + if (gotIt != null) { |
| 34 | + gotIt.outerHTML = '' |
| 35 | + } |
| 36 | + } |
| 37 | + } |
| 38 | + }) |
| 39 | + ) |
| 40 | + |
| 41 | + return blocks |
| 42 | + |
| 43 | +} |
| 44 | + |
| 45 | +module.exports.getBlocked = function (src) { |
| 46 | + var blocked = h('div.blocked', 'Blocked by: ') |
| 47 | + |
| 48 | + pull( |
| 49 | + sbot.query({query: [{$filter: { value: { content: {type: 'contact', contact: src}}}}], live: true}), |
| 50 | + pull.drain(function (msg) { |
| 51 | + if (msg.value) { |
| 52 | + if (msg.value.content.blocking == true) { |
| 53 | + console.log(msg.value) |
| 54 | + var gotIt = document.getElementById('blocked:' + msg.value.content.contact.substring(0, 44)) |
| 55 | + if (gotIt == null) { |
| 56 | + blocked.appendChild(h('a#blocked:'+ msg.value.author.substring(0, 44), {title: avatar.cachedName(msg.value.author).textContent, href: '#' + msg.value.author}, h('span.avatar--small', avatar.cachedImage(msg.value.author)))) |
| 57 | + } |
| 58 | + } |
| 59 | + if (msg.value.content.blocking == false) { |
| 60 | + var gotIt = document.getElementById('blocked:' + msg.value.author.substring(0, 44)) |
| 61 | + if (gotIt != null) { |
| 62 | + gotIt.outerHTML = '' |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | + }) |
| 67 | + ) |
| 68 | + |
| 69 | + return blocked |
| 70 | + |
| 71 | +} |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
16 | 77 | module.exports.getFollowing = function (src) { |
17 | 78 | var followingCount = 0 |
18 | 79 | |
19 | 80 | var following = h('div.following', 'Following: ') |
47 | 108 | }) |
48 | 109 | ) |
49 | 110 | return following |
50 | 111 | } |
51 | | - |
52 | 112 | module.exports.getFollowers = function (src) { |
53 | 113 | var followerCount = 0 |
54 | 114 | |
55 | 115 | var followers = h('div.followers', 'Followers: ') |