mirror of
https://gitdab.com/cadence/out-of-your-element.git
synced 2025-09-10 04:12:50 +02:00
configurable read_only_room_events_default_power
This commit is contained in:
parent
42b331135d
commit
e19703ef03
4 changed files with 9 additions and 5 deletions
|
@ -40,7 +40,9 @@ const PRIVACY_ENUMS = {
|
|||
|
||||
const DEFAULT_PRIVACY_LEVEL = 0
|
||||
|
||||
const READ_ONLY_ROOM_EVENTS_DEFAULT_POWER = 50
|
||||
function getReadOnlyRoomEventsDefaultPower() {
|
||||
return reg.ooye.read_only_room_events_default_power ?? 50
|
||||
}
|
||||
|
||||
/** @type {Map<string, Promise<string>>} channel ID -> Promise<room ID> */
|
||||
const inflightRoomCreate = new Map()
|
||||
|
@ -148,7 +150,7 @@ async function channelToKState(channel, guild, di) {
|
|||
"m.room.join_rules/": join_rules,
|
||||
/** @type {Ty.Event.M_Power_Levels} */
|
||||
"m.room.power_levels/": {
|
||||
events_default: everyoneCanSend ? 0 : READ_ONLY_ROOM_EVENTS_DEFAULT_POWER,
|
||||
events_default: everyoneCanSend ? 0 : getReadOnlyRoomEventsDefaultPower(),
|
||||
events: {
|
||||
"m.reaction": 0,
|
||||
"m.room.redaction": 0 // only affects redactions of own events, required to be able to un-react
|
||||
|
@ -559,7 +561,7 @@ async function createAllForGuild(guildID) {
|
|||
}
|
||||
|
||||
module.exports.DEFAULT_PRIVACY_LEVEL = DEFAULT_PRIVACY_LEVEL
|
||||
module.exports.READ_ONLY_ROOM_EVENTS_DEFAULT_POWER = READ_ONLY_ROOM_EVENTS_DEFAULT_POWER
|
||||
module.exports.getReadOnlyRoomEventsDefaultPower = getReadOnlyRoomEventsDefaultPower
|
||||
module.exports.PRIVACY_ENUMS = PRIVACY_ENUMS
|
||||
module.exports.createRoom = createRoom
|
||||
module.exports.ensureRoom = ensureRoom
|
||||
|
|
|
@ -165,7 +165,7 @@ function memberToPowerLevel(user, member, guild, channel) {
|
|||
/* PL 50 = if room is read-only but the user has been specially allowed to send messages */
|
||||
const everyoneCanSend = utils.hasPermission(everyonePermissions, DiscordTypes.PermissionFlagsBits.SendMessages)
|
||||
const userCanSend = utils.hasPermission(permissions, DiscordTypes.PermissionFlagsBits.SendMessages)
|
||||
if (!everyoneCanSend && userCanSend) return createRoom.READ_ONLY_ROOM_EVENTS_DEFAULT_POWER
|
||||
if (!everyoneCanSend && userCanSend) return createRoom.getReadOnlyRoomEventsDefaultPower()
|
||||
/* PL 20 = Mention Everyone for technical reasons. */
|
||||
const everyoneCanMentionEveryone = utils.hasPermission(everyonePermissions, DiscordTypes.PermissionFlagsBits.MentionEveryone)
|
||||
const userCanMentionEveryone = utils.hasPermission(permissions, DiscordTypes.PermissionFlagsBits.MentionEveryone)
|
||||
|
|
|
@ -57,7 +57,8 @@ function getTemplateRegistration(serverName) {
|
|||
max_file_size: 5000000,
|
||||
content_length_workaround: false,
|
||||
include_user_id_in_mxid: false,
|
||||
invite: []
|
||||
invite: [],
|
||||
read_only_room_events_default_power: 50
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
1
src/types.d.ts
vendored
1
src/types.d.ts
vendored
|
@ -31,6 +31,7 @@ export type AppServiceRegistrationConfig = {
|
|||
discord_origin?: string
|
||||
discord_cdn_origin?: string,
|
||||
web_password: string
|
||||
read_only_room_events_default_power?: number
|
||||
}
|
||||
old_bridge?: {
|
||||
as_token: string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue