From 84af8d8b09c0f1fe8cf07171859be411e5f56670 Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 12 Jun 2017 11:34:55 -1000 Subject: Use ssb-backlinks for channels/hashtags if it is available --- lib/app.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'lib/app.js') diff --git a/lib/app.js b/lib/app.js index d1f76f3..6e182bf 100644 --- a/lib/app.js +++ b/lib/app.js @@ -471,3 +471,33 @@ App.prototype.streamEmojis = function () { pull.unique('link') ) } + +App.prototype.streamChannel = function (opts) { + if (this.sbot.backlinks) return this.sbot.backlinks.read(u.mergeOpts(opts, { + query: [{$filter: { + dest: '#' + opts.channel, + value: { + content: { + type: 'post' + } + }, + timestamp: { + $gt: opts.gt, + $lt: opts.lt, + } + }}] + })) + + if (this.sbot.query) return this.sbot.query.read(u.mergeOpts(opts, { + query: [{$filter: { + value: {content: {channel: opts.channel}}, + timestamp: { + $gt: opts.gt, + $lt: opts.lt, + } + }}] + })) + + return pull.error(new Error( + 'Viewing channels/tags requires the ssb-backlinks or ssb-query plugin')) +} -- cgit v1.2.3