Changing defaults MUC affiliation (#385):

* video/channel owner is MUC owner
* the bot is MUC owner
* the bot is admin on the MUC component
* Peertube moderators/admins have no more special access (by default)
* migration script to update all existing rooms
This commit is contained in:
John Livingston
2024-05-17 11:47:37 +02:00
parent ebcbe8227b
commit 5745e8c8a3
6 changed files with 166 additions and 27 deletions

View File

@ -1,4 +1,5 @@
import type { RegisterServerOptions } from '@peertube/peertube-types'
import type { Affiliations } from '../config/affiliations'
import { getCurrentProsody } from './host'
import { getAPIKey } from '../../apikey'
import { getProsodyDomain } from '../config/domain'
@ -59,6 +60,8 @@ async function updateProsodyRoom (
data: {
name?: string
slow_mode_duration?: number
addAffiliations?: Affiliations
removeAffiliationsFor?: string[]
}
): Promise<boolean> {
const logger = options.peertubeHelpers.logger
@ -79,12 +82,18 @@ async function updateProsodyRoom (
const apiData = {
jid
} as any
if ('name' in data) {
if (('name' in data) && data.name !== undefined) {
apiData.name = data.name
}
if ('slow_mode_duration' in data) {
if (('slow_mode_duration' in data) && data.slow_mode_duration !== undefined) {
apiData.slow_mode_duration = data.slow_mode_duration
}
if (('addAffiliations' in data) && data.addAffiliations !== undefined) {
apiData.addAffiliations = data.addAffiliations
}
if (('removeAffiliationsFor' in data) && data.removeAffiliationsFor !== undefined) {
apiData.removeAffiliationsFor = data.removeAffiliationsFor
}
try {
logger.debug('Calling update room API on url: ' + apiUrl + ', with data: ' + JSON.stringify(apiData))
const result = await got(apiUrl, {