aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-08-22 18:57:57 -0700
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-08-22 19:10:39 -0700
commitf76defc54c292f33838caf35eca329793ff7d733 (patch)
tree214b9ab44f86c0b3971c5119a048711657519867 /lib
parent24765da30eaa84bc6084932ad4b80e8fa73b7521 (diff)
downloadpatchfoo-f76defc54c292f33838caf35eca329793ff7d733.tar.gz
patchfoo-f76defc54c292f33838caf35eca329793ff7d733.zip
Implement limit for /new
Fix %CtcZaNNWEWFwdCOZL343mxFXUvqV5BPVMv+CM8ELOCo=.sha256
Diffstat (limited to 'lib')
-rw-r--r--lib/serve.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 34861bc..1206b36 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -75,6 +75,8 @@ Serve.prototype.go = function () {
this.res.setTimeout(0)
var conf = self.app.config.patchfoo || {}
+ this.conf = conf
+
var authtok = conf.auth || null
if (authtok) {
var auth = this.req.headers['authorization']
@@ -524,8 +526,10 @@ Serve.prototype.new = function (ext) {
var self = this
var q = self.query
var latest = (/latest=([^;]*)/.exec(self.req.headers.cookie) || [])[1]
+ var limit = Number(q.limit || self.conf.newLimit || 500)
var opts = {
gt: Number(q.gt) || Number(latest) || Date.now(),
+ limit: limit
}
if (q.catchup) self.setCookie('latest', opts.gt, {'Max-Age': 86400000})
@@ -552,6 +556,7 @@ Serve.prototype.new = function (ext) {
pull.values(msgs),
self.renderThread(),
self.wrapNew({
+ reachedLimit: msgs.length === limit && limit,
gt: isFinite(maxTS) ? maxTS : Date.now()
}),
self.wrapMessages(),
@@ -3415,10 +3420,14 @@ Serve.prototype.wrapNew = function (opts) {
cb(null, [
composer,
h('table.ssb-msgs',
+ opts.reachedLimit ? h('tr', h('td.paginate.msg-left', {colspan: 3},
+ 'Reached limit of ' + opts.reachedLimit + ' messages'
+ )) : '',
thread,
h('tr', h('td.paginate.msg-left', {colspan: 3},
h('form', {method: 'get', action: ''},
h('input', {type: 'hidden', name: 'gt', value: opts.gt}),
+ self.query.limit ? h('input', {type: 'hidden', name: 'limit', value: self.query.limit}) : '',
h('input', {type: 'hidden', name: 'catchup', value: '1'}),
h('input', {type: 'submit', value: 'catchup'})
)