Files: 13be5ee9906beb5d8c2a24db46c68ef183c78d3a / modules / obs-recently-updated-feeds.js
836 bytesRaw
1 | var pull = require('pull-stream') |
2 | var pullCat = require('pull-cat') |
3 | var computed = require('@mmckegg/mutant/computed') |
4 | var MutantPullReduce = require('../lib/mutant-pull-reduce') |
5 | var plugs = require('patchbay/plugs') |
6 | var sbot_log = plugs.first(exports.sbot_log = []) |
7 | var hr = 60 * 60 * 1000 |
8 | |
9 | exports.obs_recently_updated_feeds = function (limit) { |
10 | var stream = pull( |
11 | pullCat([ |
12 | sbot_log({reverse: true, limit: limit || 500}), |
13 | sbot_log({old: false}) |
14 | ]) |
15 | ) |
16 | |
17 | var result = MutantPullReduce(stream, (result, msg) => { |
18 | if (msg.value.timestamp && Date.now() - msg.value.timestamp < 24 * hr) { |
19 | result.add(msg.value.author) |
20 | } |
21 | return result |
22 | }, { |
23 | startValue: new Set(), |
24 | nextTick: true |
25 | }) |
26 | |
27 | result.has = function (value) { |
28 | return computed(result, x => x.has(value)) |
29 | } |
30 | |
31 | return result |
32 | } |
33 |
Built with git-ssb-web