feat: introduce new topics:crosspost privilege

This commit is contained in:
Julian Lam
2026-02-12 14:18:19 -05:00
parent 803473cace
commit 5c35dc866c
4 changed files with 21 additions and 0 deletions

View File

@@ -29,6 +29,7 @@
"access-topics": "Access Topics", "access-topics": "Access Topics",
"create-topics": "Create Topics", "create-topics": "Create Topics",
"reply-to-topics": "Reply to Topics", "reply-to-topics": "Reply to Topics",
"crosspost-topics": "Cross-post Topics",
"schedule-topics": "Schedule Topics", "schedule-topics": "Schedule Topics",
"tag-topics": "Tag Topics", "tag-topics": "Tag Topics",
"edit-posts": "Edit Posts", "edit-posts": "Edit Posts",

View File

@@ -59,6 +59,7 @@ module.exports = function (Categories) {
'groups:topics:read', 'groups:topics:read',
'groups:topics:create', 'groups:topics:create',
'groups:topics:reply', 'groups:topics:reply',
'groups:topics:crosspost',
'groups:topics:tag', 'groups:topics:tag',
'groups:posts:edit', 'groups:posts:edit',
'groups:posts:history', 'groups:posts:history',

View File

@@ -23,6 +23,7 @@ const _privilegeMap = new Map([
['topics:read', { label: '[[admin/manage/privileges:access-topics]]', type: 'viewing' }], ['topics:read', { label: '[[admin/manage/privileges:access-topics]]', type: 'viewing' }],
['topics:create', { label: '[[admin/manage/privileges:create-topics]]', type: 'posting' }], ['topics:create', { label: '[[admin/manage/privileges:create-topics]]', type: 'posting' }],
['topics:reply', { label: '[[admin/manage/privileges:reply-to-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:schedule', { label: '[[admin/manage/privileges:schedule-topics]]', type: 'posting' }],
['topics:tag', { label: '[[admin/manage/privileges:tag-topics]]', type: 'posting' }], ['topics:tag', { label: '[[admin/manage/privileges:tag-topics]]', type: 'posting' }],
['posts:edit', { label: '[[admin/manage/privileges:edit-posts]]', type: 'posting' }], ['posts:edit', { label: '[[admin/manage/privileges:edit-posts]]', type: 'posting' }],

View 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');
}
}));
},
};