git ssb

10+

Matt McKegg / patchwork



Commit 370bf616c2c19236893d5d9a0c7dce4001f1d176

include hashtags in active channels

Matt McKegg committed on 10/16/2017, 8:16:27 AM
Parent: a97b2ac07374b443c84bbd1f8d2c42f40456a4bb

Files changed

sbot/channels.jschanged
sbot/channels.jsView
@@ -24,16 +24,40 @@
2424 }
2525
2626 function map (msg) {
2727 if (msg.value.content) {
28+ // filter out likes and subscriptions
2829 var isLike = msg.value.content.type === 'vote'
2930 var isSubscription = msg.value.content.type === 'channel'
30- var channel = normalizeChannel(msg.value.content.channel)
3131
32- // filter out likes and subscriptions
33- if (channel && !isLike && !isSubscription) {
34- return {
35- [channel]: {timestamp: msg.timestamp}
32+ if (!isLike && !isSubscription) {
33+ var channels = getChannels(msg)
34+ if (channels.length) {
35+ return channels.reduce((result, channel) => {
36+ result[channel] = {timestamp: msg.timestamp}
37+ return result
38+ }, {})
3639 }
3740 }
3841 }
3942 }
43+
44+function getChannels (msg) {
45+ var result = []
46+ if (msg.value && msg.value.content) {
47+ var channel = normalizeChannel(msg.value.content.channel)
48+ if (channel) {
49+ result.push(channel)
50+ }
51+ if (Array.isArray(msg.value.content.mentions)) {
52+ msg.value.content.mentions.forEach(mention => {
53+ if (typeof mention.link === 'string' && mention.link.startsWith('#')) {
54+ var tag = normalizeChannel(mention.link.slice(1))
55+ if (tag) {
56+ result.push(tag)
57+ }
58+ }
59+ })
60+ }
61+ }
62+ return result
63+}

Built with git-ssb-web