Commit ea367c48e4de385f8dc1b8e39b58fcab4ad8d4b7
feed.pull: add more, accept `lt` value as objects, extract correct seq out
Matt McKegg committed on 6/15/2017, 5:19:05 AMParent: 0cae923ff917e2cab616dee0db56d2e4cf5f66c8
Files changed
feed/pull/channel.js | changed |
feed/pull/mentions.js | changed |
feed/pull/private.js | changed |
feed/pull/public.js | changed |
feed/pull/profile.js | added |
feed/pull/channel.js | ||
---|---|---|
@@ -10,19 +10,23 @@ | ||
10 | 10 … | return nest('feed.pull.channel', function (channel) { |
11 | 11 … | if (typeof channel !== 'string') throw new Error('a channel name be specified') |
12 | 12 … | |
13 | 13 … | return function (opts) { |
14 … | + // handle last item passed in as lt | |
15 … | + var lt = typeof opts.lt === 'object' | |
16 … | + ? opts.lt.value.timestamp | |
17 … | + : opts.lt | |
18 … | + | |
19 … | + delete opts.lt | |
20 … | + | |
14 | 21 … | var filter = { |
15 | 22 … | dest: `#${channel}`, |
16 | - timestamp: opts.lt | |
17 | - ? {$lt: opts.lt, $gt: 0} | |
18 | - : {$gt: 0} | |
23 … | + value: { | |
24 … | + timestamp: lt ? {$lt: lt, $gt: 0} : {$gt: 0} | |
25 … | + } | |
19 | 26 … | } |
20 | 27 … | |
21 | - delete opts.lt | |
22 | - | |
23 | 28 … | return api.sbot.pull.backlinks(extend(opts, { |
24 | - index: 'DTS', // HACK: force index since flumeview-query is choosing the wrong one | |
25 | 29 … | query: [ |
26 | 30 … | {$filter: filter} |
27 | 31 … | ] |
28 | 32 … | })) |
feed/pull/mentions.js | ||
---|---|---|
@@ -20,8 +20,13 @@ | ||
20 | 20 … | opts = extend(opts) |
21 | 21 … | var take = opts.limit |
22 | 22 … | opts.limit = 5000 |
23 | 23 … | |
24 … | + // handle last item passed in as lt | |
25 … | + opts.lt = typeof opts.lt === 'object' | |
26 … | + ? opts.lt.timestamp | |
27 … | + : opts.lt | |
28 … | + | |
24 | 29 … | var stream = pull( |
25 | 30 … | api.sbot.pull.log(opts), |
26 | 31 … | unboxIfNeeded(), |
27 | 32 … | pull.filter((msg) => { |
feed/pull/private.js | ||
---|---|---|
@@ -8,19 +8,23 @@ | ||
8 | 8 … | }) |
9 | 9 … | |
10 | 10 … | exports.create = function (api) { |
11 | 11 … | return nest('feed.pull.private', function (opts) { |
12 … | + // handle last item passed in as lt | |
13 … | + var lt = typeof opts.lt === 'object' | |
14 … | + ? opts.lt.timestamp | |
15 … | + : opts.lt | |
16 … | + delete opts.lt | |
17 … | + | |
12 | 18 … | // HACK: needed to select correct index and handle lt |
13 | 19 … | opts.query = [ |
14 | 20 … | {$filter: { |
15 | - timestamp: opts.lt | |
16 | - ? {$lt: opts.lt, $gt: 0} | |
21 … | + timestamp: lt | |
22 … | + ? {$lt: lt, $gt: 0} | |
17 | 23 … | : {$gt: 0} |
18 | 24 … | }} |
19 | 25 … | ] |
20 | 26 … | |
21 | - delete opts.lt | |
22 | - | |
23 | 27 … | return StreamWhenConnected(api.sbot.obs.connection, (sbot) => { |
24 | 28 … | return sbot.private.read(opts) |
25 | 29 … | }) |
26 | 30 … | }) |
feed/pull/public.js | ||
---|---|---|
@@ -1,7 +1,13 @@ | ||
1 | 1 … | const nest = require('depnest') |
2 | 2 … | |
3 | 3 … | exports.gives = nest('feed.pull.public') |
4 | -exports.needs = nest('sbot.pull.log', 'first') | |
4 … | +exports.needs = nest('sbot.pull.feed', 'first') | |
5 | 5 … | exports.create = function (api) { |
6 | - return nest('feed.pull.public', api.sbot.pull.log) | |
6 … | + return nest('feed.pull.public', (opts) => { | |
7 … | + // handle last item passed in as lt | |
8 … | + opts.lt = typeof opts.lt === 'object' | |
9 … | + ? opts.lt.value.timestamp | |
10 … | + : opts.lt | |
11 … | + return api.sbot.pull.feed(opts) | |
12 … | + }) | |
7 | 13 … | } |
feed/pull/profile.js | ||
---|---|---|
@@ -1,0 +1,16 @@ | ||
1 … | +const nest = require('depnest') | |
2 … | +const extend = require('xtend') | |
3 … | + | |
4 … | +exports.gives = nest('feed.pull.profile') | |
5 … | +exports.needs = nest('sbot.pull.userFeed', 'first') | |
6 … | +exports.create = function (api) { | |
7 … | + return nest('feed.pull.profile', (id) => { | |
8 … | + // handle last item passed in as lt | |
9 … | + return function (opts) { | |
10 … | + opts = extend(opts, { | |
11 … | + id, lt: typeof opts.lt === 'object' ? opts.lt.value.sequence : opts.lt | |
12 … | + }) | |
13 … | + return api.sbot.pull.userFeed(opts) | |
14 … | + } | |
15 … | + }) | |
16 … | +} |
Built with git-ssb-web