mirror of https://gitgud.io/fatchan/jschan.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.0 KiB
38 lines
1.0 KiB
'use strict';
|
|
|
|
const { Posts } = require(__dirname+'/../../../db/')
|
|
, { ipHashPermLevel } = require(__dirname+'/../../../configs/main.js')
|
|
, pageQueryConverter = require(__dirname+'/../../../helpers/pagequeryconverter.js')
|
|
, decodeQueryIP = require(__dirname+'/../../../helpers/decodequeryip.js')
|
|
, hashIp = require(__dirname+'/../../../helpers/haship.js')
|
|
, limit = 20;
|
|
|
|
module.exports = async (req, res, next) => {
|
|
|
|
const { page, offset, queryString } = pageQueryConverter(req.query, limit);
|
|
let ipMatch = decodeQueryIP(req.query, res.locals.permLevel);
|
|
|
|
let posts;
|
|
try {
|
|
posts = await Posts.getGlobalRecent(offset, limit, ipMatch);
|
|
} catch (err) {
|
|
return next(err)
|
|
}
|
|
if (ipHashPermLevel !== -1
|
|
&& res.locals.permLevel > ipHashPermLevel) {
|
|
for (let i = 0; i < posts.length; i++) {
|
|
posts[i].ip.single = hashIp(posts[i].ip.single);
|
|
}
|
|
}
|
|
|
|
res
|
|
.set('Cache-Control', 'private, max-age=5')
|
|
.render('globalmanagerecent', {
|
|
csrf: req.csrfToken(),
|
|
posts,
|
|
page,
|
|
ip: ipMatch ? req.query.ip : null,
|
|
queryString,
|
|
});
|
|
|
|
}
|
|
|