git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 08a7cff8db13bc65b509e3ba4f53566e2cb21e6a

alternative approach to #642

Matt McKegg committed on 10/10/2017, 12:03:54 AM
Parent: abb85fa0947760cd74602bc9f246265ae015e3e1

Files changed

sbot/channels.jschanged
sbot/channels.jsView
@@ -4,15 +4,8 @@
44 module.exports = function (ssb, config) {
55 return ssb._flumeUse('patchwork-channels', FlumeReduce(1, reduce, map))
66 }
77
8-function isActivityMessage(msg) {
9- var isVote = msg.value.content.type === "vote";
10-
11- return !isVote && msg.value.content.subscribed !== false
12- && msg.value.content.subscribed !== true;
13-}
14-
158 function reduce (result, item) {
169 if (!result) result = {}
1710 if (item) {
1811 for (var channel in item) {
@@ -21,12 +14,9 @@
2114 value = result[channel] = {count: 0, timestamp: 0}
2215 }
2316 value.count += 1
2417
25- // We don't update the timestamp if the messsage was just somebody subscribing
26- // or unsubscribing from the channel, or it is a vote as we don't want it to register as
27- // 'recent activity'.
28- if (item[channel].isActivityMessage && item[channel].timestamp > value.timestamp) {
18+ if (item[channel].timestamp > value.timestamp) {
2919 value.timestamp = item[channel].timestamp
3020 }
3121 }
3222 }
@@ -34,12 +24,16 @@
3424 }
3525
3626 function map (msg) {
3727 if (msg.value.content) {
28+ var isLike = msg.value.content.type === 'vote'
29+ var isSubscription = msg.value.content.type === 'channel'
3830 var channel = normalizeChannel(msg.value.content.channel)
39- if (channel) {
31+
32+ // filter out likes and subscriptions
33+ if (channel && !isLike && !isSubscription) {
4034 return {
41- [channel]: {timestamp: msg.timestamp, isActivityMessage: isActivityMessage(msg) }
35+ [channel]: {timestamp: msg.timestamp}
4236 }
4337 }
4438 }
4539 }

Built with git-ssb-web