feat: #11814, dont check content len for admins

isekai-main
Barış Soner Uşaklı 2 years ago
parent 437433ab75
commit f359a76702

@ -160,7 +160,7 @@ define('uploadHelpers', ['alerts'], function (alerts) {
if ((isImage && !app.user.privileges['upload:post:image']) || (!isImage && !app.user.privileges['upload:post:file'])) {
return alerts.error('[[error:no-privileges]]');
}
if (files[i].size > parseInt(config.maximumFileSize, 10) * 1024) {
if (!app.user.isAdmin && files[i].size > parseInt(config.maximumFileSize, 10) * 1024) {
options.uploadForm[0].reset();
return alerts.error('[[error:file-too-big, ' + config.maximumFileSize + ']]');
}

@ -163,8 +163,8 @@ uploadsController.uploadFile = async function (uid, uploadedFile) {
if (!uploadedFile) {
throw new Error('[[error:invalid-file]]');
}
if (uploadedFile.size > meta.config.maximumFileSize * 1024) {
const isAdmin = await user.isAdministrator(uid);
if (!isAdmin && uploadedFile.size > meta.config.maximumFileSize * 1024) {
throw new Error(`[[error:file-too-big, ${meta.config.maximumFileSize}]]`);
}

@ -80,23 +80,26 @@ module.exports = function (Topics) {
data = await plugins.hooks.fire('filter:topic.post', data);
const { uid } = data;
const [categoryExists, canCreate, canTag, isAdmin] = await Promise.all([
categories.exists(data.cid),
privileges.categories.can('topics:create', data.cid, uid),
privileges.categories.can('topics:tag', data.cid, uid),
privileges.users.isAdministrator(uid),
]);
data.title = String(data.title).trim();
data.tags = data.tags || [];
data.content = String(data.content || '').trimEnd();
if (!isAdmin) {
Topics.checkTitle(data.title);
}
await Topics.validateTags(data.tags, data.cid, uid);
data.tags = await Topics.filterTags(data.tags, data.cid);
if (!data.fromQueue) {
if (!data.fromQueue && !isAdmin) {
Topics.checkContent(data.content);
}
const [categoryExists, canCreate, canTag] = await Promise.all([
categories.exists(data.cid),
privileges.categories.can('topics:create', data.cid, uid),
privileges.categories.can('topics:tag', data.cid, uid),
]);
if (!categoryExists) {
throw new Error('[[error:no-category]]');
}
@ -159,7 +162,10 @@ module.exports = function (Topics) {
const { tid } = data;
const { uid } = data;
const topicData = await Topics.getTopicData(tid);
const [topicData, isAdmin] = await Promise.all([
Topics.getTopicData(tid),
privileges.users.isAdministrator(uid),
]);
await canReply(data, topicData);
@ -168,7 +174,7 @@ module.exports = function (Topics) {
await guestHandleValid(data);
data.content = String(data.content || '').trimEnd();
if (!data.fromQueue) {
if (!data.fromQueue && !isAdmin) {
await user.isReadyToPost(uid, data.cid);
Topics.checkContent(data.content);
}

Loading…
Cancel
Save