Commit 0e7c0899affc876a69d822ae746c7c358f8c2906
include posts in public feed that have tags you subscribe to
part of the way towards #601Matt McKegg committed on 9/29/2017, 1:22:43 PM
Parent: 771e58efb5920f3b771f41b4c98a7905a56975ee
Files changed
modules/page/html/render/public.js | changed |
sbot/roots.js | changed |
modules/page/html/render/public.js | ||
---|---|---|
@@ -75,10 +75,11 @@ | ||
75 | 75 | if (type === 'vote') return false |
76 | 76 | |
77 | 77 | var author = msg.value.author |
78 | 78 | var channel = normalizeChannel(msg.value.content.channel) |
79 | + var tagged = checkTag(msg.value.content.mentions) | |
79 | 80 | var isSubscribed = channel ? subscribedChannels().has(channel) : false |
80 | - return isSubscribed || id === author || following().includes(author) | |
81 | + return isSubscribed || id === author || following().includes(author) || tagged | |
81 | 82 | } |
82 | 83 | }, |
83 | 84 | rootFilter: function (msg) { |
84 | 85 | if (!filters()) return true |
@@ -104,8 +105,19 @@ | ||
104 | 105 | result.reload = feedView.reload |
105 | 106 | |
106 | 107 | return result |
107 | 108 | |
109 | + function checkTag (mentions) { | |
110 | + if (Array.isArray(mentions)) { | |
111 | + return mentions.some((mention) => { | |
112 | + if (mention && typeof mention.link === 'string' && mention.link.startsWith('#')) { | |
113 | + var channel = normalizeChannel(mention.link.slice(1)) | |
114 | + return channel ? subscribedChannels().has(channel) : false | |
115 | + } | |
116 | + }) | |
117 | + } | |
118 | + } | |
119 | + | |
108 | 120 | function getSidebar () { |
109 | 121 | var whoToFollow = computed([following, api.profile.obs.recentlyUpdated(), localPeers], (following, recent, peers) => { |
110 | 122 | return recent.filter(x => x !== id && !following.includes(x) && !peers.includes(x)).slice(0, 10) |
111 | 123 | }) |
sbot/roots.js | ||
---|---|---|
@@ -196,15 +196,26 @@ | ||
196 | 196 | cb(null, function (ids, msg) { |
197 | 197 | var type = msg.value.content.type |
198 | 198 | if (type === 'vote') return false // filter out likes |
199 | 199 | var matchesChannel = (type !== 'channel' && checkChannel(subscriptions, ids, msg.value.content.channel)) |
200 | - return ids.includes(msg.value.author) || matchesChannel || checkFollowing(friends, ids, msg.value.author) | |
200 | + var matchesTag = checkTag(subscriptions, ids, msg.value.content.mentions) | |
201 | + return ids.includes(msg.value.author) || matchesChannel || matchesTag || checkFollowing(friends, ids, msg.value.author) | |
201 | 202 | }) |
202 | 203 | }) |
203 | 204 | }) |
204 | 205 | } |
205 | 206 | } |
206 | 207 | |
208 | +function checkTag (lookup, ids, mentions) { | |
209 | + if (Array.isArray(mentions)) { | |
210 | + return mentions.some((mention) => { | |
211 | + if (mention && typeof mention.link === 'string' && mention.link.startsWith('#')) { | |
212 | + return checkChannel(lookup, ids, mention.link.slice(1)) | |
213 | + } | |
214 | + }) | |
215 | + } | |
216 | +} | |
217 | + | |
207 | 218 | function checkFollowing (lookup, ids, target) { |
208 | 219 | // TODO: rewrite contacts index (for some reason the order is different) |
209 | 220 | if (!lookup) return false |
210 | 221 | // HACK: only lookup the first ID until a method is added to ssb-friends to |
Built with git-ssb-web