Skip to content

Node.js based forum software built for the modern web

fix: category moderators see an empty post queue (#14943)

palmoni587f90bb374e6
diff --git a/src/controllers/mods.js b/src/controllers/mods.js
index 00eee1fdce..de2a8bcaea 100644
--- a/src/controllers/mods.js
+++ b/src/controllers/mods.js
@@ -235,7 +235,7 @@ modsController.postQueue = async function (req, res, next) {
postData = postData
.filter(p => p &&
(!categoriesData.selectedCids.length || categoriesData.selectedCids.includes(p.category.cid)) &&
- (isAdmin || isGlobalMod || moderatedCids.includes(Number(p.category.cid)) || req.uid === p.user.uid))
+ (isAdmin || isGlobalMod || moderatedCids.map(String).includes(String(p.category.cid)) || req.uid === p.user.uid))
.map((post) => {
const isSelf = post.user.uid === req.uid;
post.canAccept = !isSelf && (isAdmin || isGlobalMod || !!moderatedCids.length);
diff --git a/test/posts.js b/test/posts.js
index f19f67c70b..065a8a8c04 100644
--- a/test/posts.js
+++ b/test/posts.js
@@ -1097,6 +1097,17 @@ describe('Post\'s', () => {
assert(!Object.hasOwn(posts[0].data, 'req'));
});
+ it('should load queued posts for a category moderator', async () => {
+ const modUid = await user.create({ username: 'queuecatmod', password: 'queuecatmodpwd' });
+ await privileges.categories.give(['moderate'], cid, modUid);
+ const { jar: modJar } = await helpers.loginUser('queuecatmod', 'queuecatmodpwd');
+ const { body } = await request.get(`${nconf.get('url')}/api/post-queue`, { jar: modJar });
+ const ids = body.posts.map(p => p.id);
+ assert(ids.includes(topicQueueId));
+ assert(ids.includes(queueId));
+ await privileges.categories.rescind(['moderate'], cid, modUid);
+ });
+
it('should error if data is invalid', async () => {
await assert.rejects(
apiPosts.editQueuedPost({ uid: globalModUid }, null),