mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: add vote privs to topic (#11734)
* feat: add vote privs to topic * add missing awaits
This commit is contained in:
committed by
GitHub
parent
09d42076be
commit
86faed6fd3
@@ -343,6 +343,10 @@ get:
|
||||
type: boolean
|
||||
posts:history:
|
||||
type: boolean
|
||||
posts:upvote:
|
||||
type: boolean
|
||||
posts:downvote:
|
||||
type: boolean
|
||||
posts:delete:
|
||||
type: boolean
|
||||
posts:view_deleted:
|
||||
|
||||
@@ -19,6 +19,7 @@ privsTopics.get = async function (tid, uid) {
|
||||
const privs = [
|
||||
'topics:reply', 'topics:read', 'topics:schedule', 'topics:tag',
|
||||
'topics:delete', 'posts:edit', 'posts:history',
|
||||
'posts:upvote', 'posts:downvote',
|
||||
'posts:delete', 'posts:view_deleted', 'read', 'purge',
|
||||
];
|
||||
const topicData = await topics.getTopicFields(tid, ['cid', 'uid', 'locked', 'deleted', 'scheduled']);
|
||||
@@ -43,6 +44,8 @@ privsTopics.get = async function (tid, uid) {
|
||||
'topics:delete': (privData['topics:delete'] && (isOwner || isModerator)) || isAdministrator,
|
||||
'posts:edit': (privData['posts:edit'] && (!topicData.locked || isModerator)) || isAdministrator,
|
||||
'posts:history': privData['posts:history'] || isAdministrator,
|
||||
'posts:upvote': privData['posts:upvote'] || isAdministrator,
|
||||
'posts:downvote': privData['posts:downvote'] || isAdministrator,
|
||||
'posts:delete': (privData['posts:delete'] && (!topicData.locked || isModerator)) || isAdministrator,
|
||||
'posts:view_deleted': privData['posts:view_deleted'] || isAdministrator,
|
||||
read: privData.read || isAdministrator,
|
||||
|
||||
@@ -421,7 +421,7 @@ describe('Controllers', () => {
|
||||
interstitials: [],
|
||||
});
|
||||
assert.strictEqual(result.interstitials[0].template, 'partials/email_update');
|
||||
assert.rejects(result.interstitials[0].callback({ uid }, {
|
||||
await assert.rejects(result.interstitials[0].callback({ uid }, {
|
||||
email: 'invalidEmail',
|
||||
}), { message: '[[error:invalid-email]]' });
|
||||
});
|
||||
@@ -434,7 +434,7 @@ describe('Controllers', () => {
|
||||
interstitials: [],
|
||||
});
|
||||
assert.strictEqual(result.interstitials[0].template, 'partials/email_update');
|
||||
assert.rejects(result.interstitials[0].callback({ uid }, {
|
||||
await assert.rejects(result.interstitials[0].callback({ uid }, {
|
||||
email: ' ',
|
||||
}), { message: '[[error:invalid-email]]' });
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ describe('API tokens', () => {
|
||||
|
||||
describe('.create()', () => {
|
||||
it('should fail to create a token for a user that does not exist', async () => {
|
||||
assert.rejects(api.utils.tokens.generate({ uid: 1 }), { message: '[[error:no-user]]' });
|
||||
await assert.rejects(api.utils.tokens.generate({ uid: 1 }), { message: '[[error:no-user]]' });
|
||||
});
|
||||
|
||||
it('should create a token for a user that exists', async () => {
|
||||
@@ -63,7 +63,7 @@ describe('API tokens', () => {
|
||||
});
|
||||
|
||||
it('should fail if you pass in invalid data', async () => {
|
||||
assert.rejects(api.utils.tokens.get(token), { message: '[[error:invalid-data]]' });
|
||||
await assert.rejects(api.utils.tokens.get(token), { message: '[[error:invalid-data]]' });
|
||||
});
|
||||
|
||||
it('should show lastSeen and lastSeenISO as undefined/null if it is a new token', async () => {
|
||||
|
||||
Reference in New Issue
Block a user