mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: #8957
This commit is contained in:
@@ -19,6 +19,11 @@ module.exports = function (SocketPosts) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
|
||||
const canMove = await privileges.topics.isAdminOrMod(data.tid, socket.uid);
|
||||
if (!canMove) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
|
||||
for (const pid of data.pids) {
|
||||
/* eslint-disable no-await-in-loop */
|
||||
const canMove = await privileges.posts.canMove(pid, socket.uid);
|
||||
|
||||
@@ -721,6 +721,21 @@ describe('Post\'s', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail to move post if not moderator of target category', async function () {
|
||||
const cat1 = await categories.create({ name: 'Test Category', description: 'Test category created by testing script' });
|
||||
const cat2 = await categories.create({ name: 'Test Category', description: 'Test category created by testing script' });
|
||||
const result = await socketTopics.post({ uid: globalModUid }, { title: 'target topic', content: 'queued topic', cid: cat2.cid });
|
||||
const modUid = await user.create({ username: 'modofcat1' });
|
||||
await privileges.categories.give(privileges.userPrivilegeList, cat1.cid, modUid);
|
||||
let err;
|
||||
try {
|
||||
await socketPosts.movePost({ uid: modUid }, { pid: replyPid, tid: result.tid });
|
||||
} catch (_err) {
|
||||
err = _err;
|
||||
}
|
||||
assert.strictEqual(err.message, '[[error:no-privileges]]');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPostSummaryByPids', function () {
|
||||
|
||||
Reference in New Issue
Block a user