Limit channel & feed serving by default
This commit is contained in:
@@ -93,11 +93,14 @@ exports.init = function (sbot, config) {
|
||||
function serveFeed(req, res, feedId) {
|
||||
console.log("serving feed: " + feedId)
|
||||
|
||||
var showAll = req.url.endsWith("?showAll")
|
||||
var showAllHTML = showAll ? '' : '<br/><a href="' + req.url + '?showAll">Show whole feed</a>'
|
||||
|
||||
getAbout(feedId, function (err, about) {
|
||||
if (err) return respond(res, 500, err.stack || err)
|
||||
if (err) return respond(res, 500, err.stack || err)
|
||||
|
||||
pull(
|
||||
sbot.createUserStream({ id: feedId, reverse: true }),
|
||||
sbot.createUserStream({ id: feedId, reverse: true, limit: showAll ? -1 : 10 }),
|
||||
pull.collect(function (err, logs) {
|
||||
if (err) return respond(res, 500, err.stack || err)
|
||||
res.writeHead(200, {
|
||||
@@ -109,7 +112,7 @@ exports.init = function (sbot, config) {
|
||||
paramap(addFollowAbout, 8),
|
||||
paramap(addVoteMessage, 8),
|
||||
paramap(addGitLinks, 8),
|
||||
pull(renderAbout(defaultOpts, about), wrapPage(about.name)),
|
||||
pull(renderAbout(defaultOpts, about, showAllHTML), wrapPage(about.name)),
|
||||
toPull(res, function (err) {
|
||||
if (err) console.error('[viewer]', err)
|
||||
})
|
||||
@@ -191,9 +194,12 @@ exports.init = function (sbot, config) {
|
||||
function serveChannel(req, res, url) {
|
||||
var channelId = url.substring(url.lastIndexOf('channel/')+8, 100)
|
||||
console.log("serving channel: " + channelId)
|
||||
|
||||
var showAll = req.url.endsWith("?showAll")
|
||||
var showAllHTML = showAll ? '' : '<br/><a href="' + req.url + '?showAll">Show whole feed</a>'
|
||||
|
||||
pull(
|
||||
sbot.query.read({ limit: 500, reverse: true, query: [{$filter: { value: { content: { channel: channelId }}}}]}),
|
||||
sbot.query.read({ limit: showAll ? 300 : 10, reverse: true, query: [{$filter: { value: { content: { channel: channelId }}}}]}),
|
||||
pull.collect(function (err, logs) {
|
||||
if (err) return respond(res, 500, err.stack || err)
|
||||
res.writeHead(200, {
|
||||
@@ -203,7 +209,7 @@ exports.init = function (sbot, config) {
|
||||
pull.values(logs),
|
||||
paramap(addAuthorAbout, 8),
|
||||
paramap(addVoteMessage, 8),
|
||||
pull(renderThread(defaultOpts), wrapPage('#' + channelId)),
|
||||
pull(renderThread(defaultOpts, showAllHTML), wrapPage('#' + channelId)),
|
||||
toPull(res, function (err) {
|
||||
if (err) console.error('[viewer]', err)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user