Compare commits

..

2 Commits

Author SHA1 Message Date
Barış Soner Uşaklı
8047900170 refactor: skip content length check if submitting from post-queue 2022-04-21 12:32:09 -04:00
Barış Soner Uşaklı
32b38643f8 feat: add response:helpers.notAllowed 2022-04-04 17:36:45 -04:00
2 changed files with 12 additions and 5 deletions

View File

@@ -123,6 +123,11 @@ helpers.buildTerms = function (url, term, query) {
helpers.notAllowed = async function (req, res, error) {
({ error } = await plugins.hooks.fire('filter:helpers.notAllowed', { req, res, error }));
await plugins.hooks.fire('response:helpers.notAllowed', { req, res, error });
if (res.headersSent) {
return;
}
if (req.loggedIn || req.uid === -1) {
if (res.locals.isAPI) {
if (req.originalUrl.startsWith(`${relative_path}/api/v3`)) {

View File

@@ -88,7 +88,9 @@ module.exports = function (Topics) {
Topics.checkTitle(data.title);
await Topics.validateTags(data.tags, data.cid, uid);
data.tags = await Topics.filterTags(data.tags, data.cid);
Topics.checkContent(data.content);
if (!data.fromQueue) {
Topics.checkContent(data.content);
}
const [categoryExists, canCreate, canTag] = await Promise.all([
categories.exists(data.cid),
@@ -165,13 +167,13 @@ module.exports = function (Topics) {
data.cid = topicData.cid;
await guestHandleValid(data);
if (!data.fromQueue) {
await user.isReadyToPost(uid, data.cid);
}
if (data.content) {
data.content = utils.rtrim(data.content);
}
Topics.checkContent(data.content);
if (!data.fromQueue) {
await user.isReadyToPost(uid, data.cid);
Topics.checkContent(data.content);
}
// For replies to scheduled topics, don't have a timestamp older than topic's itself
if (topicData.scheduled) {