git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit abb85fa0947760cd74602bc9f246265ae015e3e1

Don't register channel subscription / unsubscription or vote messages as 'recent channel activity.'

Gordon Martin committed on 10/7/2017, 7:31:49 PM
Parent: 5bd646e5318c724c8523f74e3cbcb3712bfbb20f

Files changed

sbot/channels.jschanged
sbot/channels.jsView
@@ -4,8 +4,15 @@
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+
815 function reduce (result, item) {
916 if (!result) result = {}
1017 if (item) {
1118 for (var channel in item) {
@@ -13,9 +20,13 @@
1320 if (!value) {
1421 value = result[channel] = {count: 0, timestamp: 0}
1522 }
1623 value.count += 1
17- if (item[channel].timestamp > value.timestamp) {
24+
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) {
1829 value.timestamp = item[channel].timestamp
1930 }
2031 }
2132 }
@@ -26,9 +37,9 @@
2637 if (msg.value.content) {
2738 var channel = normalizeChannel(msg.value.content.channel)
2839 if (channel) {
2940 return {
30- [channel]: {timestamp: msg.timestamp}
41+ [channel]: {timestamp: msg.timestamp, isActivityMessage: isActivityMessage(msg) }
3142 }
3243 }
3344 }
3445 }

Built with git-ssb-web