git ssb

10+

Matt McKegg / patchwork



Commit 0e7c0899affc876a69d822ae746c7c358f8c2906

include posts in public feed that have tags you subscribe to

part of the way towards #601
Matt McKegg committed on 9/29/2017, 1:22:43 PM
Parent: 771e58efb5920f3b771f41b4c98a7905a56975ee

Files changed

modules/page/html/render/public.jschanged
sbot/roots.jschanged
modules/page/html/render/public.jsView
@@ -75,10 +75,11 @@
7575 if (type === 'vote') return false
7676
7777 var author = msg.value.author
7878 var channel = normalizeChannel(msg.value.content.channel)
79+ var tagged = checkTag(msg.value.content.mentions)
7980 var isSubscribed = channel ? subscribedChannels().has(channel) : false
80- return isSubscribed || id === author || following().includes(author)
81+ return isSubscribed || id === author || following().includes(author) || tagged
8182 }
8283 },
8384 rootFilter: function (msg) {
8485 if (!filters()) return true
@@ -104,8 +105,19 @@
104105 result.reload = feedView.reload
105106
106107 return result
107108
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+
108120 function getSidebar () {
109121 var whoToFollow = computed([following, api.profile.obs.recentlyUpdated(), localPeers], (following, recent, peers) => {
110122 return recent.filter(x => x !== id && !following.includes(x) && !peers.includes(x)).slice(0, 10)
111123 })
sbot/roots.jsView
@@ -196,15 +196,26 @@
196196 cb(null, function (ids, msg) {
197197 var type = msg.value.content.type
198198 if (type === 'vote') return false // filter out likes
199199 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)
201202 })
202203 })
203204 })
204205 }
205206 }
206207
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+
207218 function checkFollowing (lookup, ids, target) {
208219 // TODO: rewrite contacts index (for some reason the order is different)
209220 if (!lookup) return false
210221 // HACK: only lookup the first ID until a method is added to ssb-friends to

Built with git-ssb-web