fix: check schedule privilege, closes #11032

This commit is contained in:
Barış Soner Uşaklı
2022-11-11 11:14:30 -05:00
parent b34e859c1b
commit 6109061501
2 changed files with 11 additions and 7 deletions

View File

@@ -40,13 +40,19 @@ topicsAPI.create = async function (caller, data) {
const payload = { ...data };
payload.tags = payload.tags || [];
apiHelpers.setDefaultPostData(caller, payload);
const isScheduling = parseInt(data.timestamp, 10) > payload.timestamp;
if (isScheduling) {
if (await privileges.categories.can('topics:schedule', data.cid, caller.uid)) {
payload.timestamp = parseInt(data.timestamp, 10);
} else {
throw new Error('[[error:no-privileges]]');
}
}
// Blacklist & Post Queue
await meta.blacklist.test(caller.ip);
const shouldQueue = await posts.shouldQueue(caller.uid, payload);
if (shouldQueue) {
const queueObj = await posts.addToQueue(payload);
return queueObj;
return await posts.addToQueue(payload);
}
const result = await topics.post(payload);
@@ -66,12 +72,10 @@ topicsAPI.reply = async function (caller, data) {
const payload = { ...data };
apiHelpers.setDefaultPostData(caller, payload);
// Blacklist & Post Queue
await meta.blacklist.test(caller.ip);
const shouldQueue = await posts.shouldQueue(caller.uid, payload);
if (shouldQueue) {
const queueObj = await posts.addToQueue(payload);
return queueObj;
return await posts.addToQueue(payload);
}
const postData = await topics.reply(payload); // postData seems to be a subset of postObj, refactor?