fix: #11306, show proper error if queued post doesn't exist

was showing no-privileges if someone else accepted the post
This commit is contained in:
Barış Soner Uşaklı
2023-02-17 11:41:35 -05:00
parent d6ed1e0f1e
commit 0349169879

View File

@@ -303,14 +303,17 @@ module.exports = function (Posts) {
}
Posts.editQueuedContent = async function (uid, editData) {
const canEditQueue = await Posts.canEditQueue(uid, editData, 'edit');
const [canEditQueue, data] = await Promise.all([
Posts.canEditQueue(uid, editData, 'edit'),
getParsedObject(editData.id),
]);
if (!data) {
throw new Error('[[error:no-post]]');
}
if (!canEditQueue) {
throw new Error('[[error:no-privileges]]');
}
const data = await getParsedObject(editData.id);
if (!data) {
return;
}
if (editData.content !== undefined) {
data.data.content = editData.content;
}