mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-03 11:01:20 +01:00
feat: introduce new topics:crosspost privilege
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
"access-topics": "Access Topics",
|
||||
"create-topics": "Create Topics",
|
||||
"reply-to-topics": "Reply to Topics",
|
||||
"crosspost-topics": "Cross-post Topics",
|
||||
"schedule-topics": "Schedule Topics",
|
||||
"tag-topics": "Tag Topics",
|
||||
"edit-posts": "Edit Posts",
|
||||
|
||||
@@ -59,6 +59,7 @@ module.exports = function (Categories) {
|
||||
'groups:topics:read',
|
||||
'groups:topics:create',
|
||||
'groups:topics:reply',
|
||||
'groups:topics:crosspost',
|
||||
'groups:topics:tag',
|
||||
'groups:posts:edit',
|
||||
'groups:posts:history',
|
||||
|
||||
@@ -23,6 +23,7 @@ const _privilegeMap = new Map([
|
||||
['topics:read', { label: '[[admin/manage/privileges:access-topics]]', type: 'viewing' }],
|
||||
['topics:create', { label: '[[admin/manage/privileges:create-topics]]', type: 'posting' }],
|
||||
['topics:reply', { label: '[[admin/manage/privileges:reply-to-topics]]', type: 'posting' }],
|
||||
['topics:crosspost', { label: '[[admin/manage/privileges:crosspost-topics]]', type: 'posting' }],
|
||||
['topics:schedule', { label: '[[admin/manage/privileges:schedule-topics]]', type: 'posting' }],
|
||||
['topics:tag', { label: '[[admin/manage/privileges:tag-topics]]', type: 'posting' }],
|
||||
['posts:edit', { label: '[[admin/manage/privileges:edit-posts]]', type: 'posting' }],
|
||||
|
||||
18
src/upgrades/4.9.0/crosspost_privilege.js
Normal file
18
src/upgrades/4.9.0/crosspost_privilege.js
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
const privileges = require('../../privileges');
|
||||
const db = require('../../database');
|
||||
|
||||
module.exports = {
|
||||
name: 'Give topic:crosspost privilege to registered-users on all categories',
|
||||
timestamp: Date.UTC(2026, 1, 12),
|
||||
method: async () => {
|
||||
const cids = await db.getSortedSetMembers('categories:cid');
|
||||
await Promise.all(cids.map(async (cid) => {
|
||||
const can = await privileges.categories.can('topics:create', cid, 'registered-users');
|
||||
if (can) {
|
||||
await privileges.categories.give(['groups:topics:crosspost'], cid, 'registered-users');
|
||||
}
|
||||
}));
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user