From 08a7cff8db13bc65b509e3ba4f53566e2cb21e6a Mon Sep 17 00:00:00 2001 From: Matt McKegg Date: Tue, 10 Oct 2017 13:03:54 +1300 Subject: [PATCH] alternative approach to #642 --- sbot/channels.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/sbot/channels.js b/sbot/channels.js index 2a8b657e6..95b165aa2 100644 --- a/sbot/channels.js +++ b/sbot/channels.js @@ -5,13 +5,6 @@ module.exports = function (ssb, config) { return ssb._flumeUse('patchwork-channels', FlumeReduce(1, reduce, map)) } -function isActivityMessage(msg) { - var isVote = msg.value.content.type === "vote"; - - return !isVote && msg.value.content.subscribed !== false - && msg.value.content.subscribed !== true; -} - function reduce (result, item) { if (!result) result = {} if (item) { @@ -22,10 +15,7 @@ function reduce (result, item) { } value.count += 1 - // We don't update the timestamp if the messsage was just somebody subscribing - // or unsubscribing from the channel, or it is a vote as we don't want it to register as - // 'recent activity'. - if (item[channel].isActivityMessage && item[channel].timestamp > value.timestamp) { + if (item[channel].timestamp > value.timestamp) { value.timestamp = item[channel].timestamp } } @@ -35,10 +25,14 @@ function reduce (result, item) { function map (msg) { if (msg.value.content) { + var isLike = msg.value.content.type === 'vote' + var isSubscription = msg.value.content.type === 'channel' var channel = normalizeChannel(msg.value.content.channel) - if (channel) { + + // filter out likes and subscriptions + if (channel && !isLike && !isSubscription) { return { - [channel]: {timestamp: msg.timestamp, isActivityMessage: isActivityMessage(msg) } + [channel]: {timestamp: msg.timestamp} } } }