aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/app.js30
-rw-r--r--lib/serve.js16
2 files changed, 32 insertions, 14 deletions
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'))
+}
diff --git a/lib/serve.js b/lib/serve.js
index 354e75f..2d088ae 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -890,23 +890,11 @@ Serve.prototype.channel = function (path) {
lt: lt,
gt: gt,
limit: Number(q.limit) || 12,
- query: [{$filter: {
- value: {content: {channel: channel}},
- timestamp: {
- $gt: gt,
- $lt: lt,
- }
- }}]
+ channel: channel,
}
- if (!this.app.sbot.query) return pull(
- pull.once(u.renderError(new Error('Missing ssb-query plugin')).outerHTML),
- this.wrapPage('#' + channel),
- this.respondSink(400, {'Content-Type': ctype('html')})
- )
-
pull(
- this.app.sbot.query.read(opts),
+ this.app.streamChannel(opts),
this.renderThreadPaginated(opts, null, q),
this.wrapMessages(),
this.wrapChannel(channel),