Commit 370bf616c2c19236893d5d9a0c7dce4001f1d176
include hashtags in active channels
Matt McKegg committed on 10/16/2017, 8:16:27 AMParent: a97b2ac07374b443c84bbd1f8d2c42f40456a4bb
Files changed
sbot/channels.js | changed |
sbot/channels.js | ||
---|---|---|
@@ -24,16 +24,40 @@ | ||
24 | 24 | } |
25 | 25 | |
26 | 26 | function map (msg) { |
27 | 27 | if (msg.value.content) { |
28 | + // filter out likes and subscriptions | |
28 | 29 | var isLike = msg.value.content.type === 'vote' |
29 | 30 | var isSubscription = msg.value.content.type === 'channel' |
30 | - var channel = normalizeChannel(msg.value.content.channel) | |
31 | 31 | |
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 | + }, {}) | |
36 | 39 | } |
37 | 40 | } |
38 | 41 | } |
39 | 42 | } |
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