mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-30 18:46:01 +01:00 
			
		
		
		
	fix: #9567, use regular 404
This commit is contained in:
		| @@ -13,7 +13,6 @@ const helpers = require('../controllers/helpers'); | |||||||
| const privileges = require('../privileges'); | const privileges = require('../privileges'); | ||||||
| const db = require('../database'); | const db = require('../database'); | ||||||
| const utils = require('../utils'); | const utils = require('../utils'); | ||||||
| const controllers404 = require('../controllers/404.js'); |  | ||||||
|  |  | ||||||
| const terms = { | const terms = { | ||||||
| 	daily: 'day', | 	daily: 'day', | ||||||
| @@ -60,9 +59,9 @@ async function validateTokenIfRequiresLogin(requiresLogin, cid, req, res) { | |||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| async function generateForTopic(req, res) { | async function generateForTopic(req, res, next) { | ||||||
| 	if (meta.config['feeds:disableRSS']) { | 	if (meta.config['feeds:disableRSS']) { | ||||||
| 		return controllers404.send404(req, res); | 		return next(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	const tid = req.params.topic_id; | 	const tid = req.params.topic_id; | ||||||
| @@ -73,7 +72,7 @@ async function generateForTopic(req, res) { | |||||||
| 	]); | 	]); | ||||||
|  |  | ||||||
| 	if (!privileges.topics.canViewDeletedScheduled(topic, userPrivileges)) { | 	if (!privileges.topics.canViewDeletedScheduled(topic, userPrivileges)) { | ||||||
| 		return controllers404.send404(req, res); | 		return next(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (await validateTokenIfRequiresLogin(!userPrivileges['topics:read'], topic.cid, req, res)) { | 	if (await validateTokenIfRequiresLogin(!userPrivileges['topics:read'], topic.cid, req, res)) { | ||||||
| @@ -116,11 +115,8 @@ async function generateForTopic(req, res) { | |||||||
| } | } | ||||||
|  |  | ||||||
| async function generateForCategory(req, res, next) { | async function generateForCategory(req, res, next) { | ||||||
| 	if (meta.config['feeds:disableRSS']) { |  | ||||||
| 		return controllers404.send404(req, res); |  | ||||||
| 	} |  | ||||||
| 	const cid = req.params.category_id; | 	const cid = req.params.category_id; | ||||||
| 	if (!parseInt(cid, 10)) { | 	if (meta.config['feeds:disableRSS'] || !parseInt(cid, 10)) { | ||||||
| 		return next(); | 		return next(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -153,9 +149,9 @@ async function generateForCategory(req, res, next) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| async function generateForTopics(req, res) { | async function generateForTopics(req, res, next) { | ||||||
| 	if (meta.config['feeds:disableRSS']) { | 	if (meta.config['feeds:disableRSS']) { | ||||||
| 		return controllers404.send404(req, res); | 		return next(); | ||||||
| 	} | 	} | ||||||
| 	let token = null; | 	let token = null; | ||||||
| 	if (req.query.token && req.query.uid) { | 	if (req.query.token && req.query.uid) { | ||||||
| @@ -171,9 +167,9 @@ async function generateForTopics(req, res) { | |||||||
| 	}, 'topics:tid', res); | 	}, 'topics:tid', res); | ||||||
| } | } | ||||||
|  |  | ||||||
| async function generateForRecent(req, res) { | async function generateForRecent(req, res, next) { | ||||||
| 	if (meta.config['feeds:disableRSS']) { | 	if (meta.config['feeds:disableRSS']) { | ||||||
| 		return controllers404.send404(req, res); | 		return next(); | ||||||
| 	} | 	} | ||||||
| 	let token = null; | 	let token = null; | ||||||
| 	if (req.query.token && req.query.uid) { | 	if (req.query.token && req.query.uid) { | ||||||
| @@ -189,9 +185,9 @@ async function generateForRecent(req, res) { | |||||||
| 	}, 'topics:recent', res); | 	}, 'topics:recent', res); | ||||||
| } | } | ||||||
|  |  | ||||||
| async function generateForTop(req, res) { | async function generateForTop(req, res, next) { | ||||||
| 	if (meta.config['feeds:disableRSS']) { | 	if (meta.config['feeds:disableRSS']) { | ||||||
| 		return controllers404.send404(req, res); | 		return next(); | ||||||
| 	} | 	} | ||||||
| 	const term = terms[req.params.term] || 'day'; | 	const term = terms[req.params.term] || 'day'; | ||||||
|  |  | ||||||
| @@ -221,9 +217,9 @@ async function generateForTop(req, res) { | |||||||
| 	sendFeed(feed, res); | 	sendFeed(feed, res); | ||||||
| } | } | ||||||
|  |  | ||||||
| async function generateForPopular(req, res) { | async function generateForPopular(req, res, next) { | ||||||
| 	if (meta.config['feeds:disableRSS']) { | 	if (meta.config['feeds:disableRSS']) { | ||||||
| 		return controllers404.send404(req, res); | 		return next(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	const term = terms[req.params.term] || 'day'; | 	const term = terms[req.params.term] || 'day'; | ||||||
| @@ -309,9 +305,9 @@ async function generateTopicsFeed(feedOptions, feedTopics) { | |||||||
| 	return feed; | 	return feed; | ||||||
| } | } | ||||||
|  |  | ||||||
| async function generateForRecentPosts(req, res) { | async function generateForRecentPosts(req, res, next) { | ||||||
| 	if (meta.config['feeds:disableRSS']) { | 	if (meta.config['feeds:disableRSS']) { | ||||||
| 		return controllers404.send404(req, res); | 		return next(); | ||||||
| 	} | 	} | ||||||
| 	const postData = await posts.getRecentPosts(req.uid, 0, 19, 'month'); | 	const postData = await posts.getRecentPosts(req.uid, 0, 19, 'month'); | ||||||
| 	const feed = generateForPostsFeed({ | 	const feed = generateForPostsFeed({ | ||||||
| @@ -324,9 +320,9 @@ async function generateForRecentPosts(req, res) { | |||||||
| 	sendFeed(feed, res); | 	sendFeed(feed, res); | ||||||
| } | } | ||||||
|  |  | ||||||
| async function generateForCategoryRecentPosts(req, res) { | async function generateForCategoryRecentPosts(req, res, next) { | ||||||
| 	if (meta.config['feeds:disableRSS']) { | 	if (meta.config['feeds:disableRSS']) { | ||||||
| 		return controllers404.send404(req, res); | 		return next(); | ||||||
| 	} | 	} | ||||||
| 	const cid = req.params.category_id; | 	const cid = req.params.category_id; | ||||||
|  |  | ||||||
| @@ -337,7 +333,7 @@ async function generateForCategoryRecentPosts(req, res) { | |||||||
| 	]); | 	]); | ||||||
|  |  | ||||||
| 	if (!category) { | 	if (!category) { | ||||||
| 		return controllers404.send404(req, res); | 		return next(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (await validateTokenIfRequiresLogin(!userPrivileges.read, cid, req, res)) { | 	if (await validateTokenIfRequiresLogin(!userPrivileges.read, cid, req, res)) { | ||||||
| @@ -378,7 +374,7 @@ function generateForPostsFeed(feedOptions, posts) { | |||||||
|  |  | ||||||
| async function generateForUserTopics(req, res, next) { | async function generateForUserTopics(req, res, next) { | ||||||
| 	if (meta.config['feeds:disableRSS']) { | 	if (meta.config['feeds:disableRSS']) { | ||||||
| 		return controllers404.send404(req, res); | 		return next(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	const { userslug } = req.params; | 	const { userslug } = req.params; | ||||||
| @@ -396,9 +392,9 @@ async function generateForUserTopics(req, res, next) { | |||||||
| 	}, `uid:${userData.uid}:topics`, res); | 	}, `uid:${userData.uid}:topics`, res); | ||||||
| } | } | ||||||
|  |  | ||||||
| async function generateForTag(req, res) { | async function generateForTag(req, res, next) { | ||||||
| 	if (meta.config['feeds:disableRSS']) { | 	if (meta.config['feeds:disableRSS']) { | ||||||
| 		return controllers404.send404(req, res); | 		return next(); | ||||||
| 	} | 	} | ||||||
| 	const tag = validator.escape(String(req.params.tag)); | 	const tag = validator.escape(String(req.params.tag)); | ||||||
| 	const page = parseInt(req.query.page, 10) || 1; | 	const page = parseInt(req.query.page, 10) || 1; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user