Debug Mode: new option to promote some JIDs as admins on the MUC component.
This commit is contained in:
parent
0b299883b1
commit
9ec7167da1
@ -3,6 +3,7 @@
|
|||||||
## ??? (Not Released Yet)
|
## ??? (Not Released Yet)
|
||||||
|
|
||||||
* Fix mod_muc_slow_mode: add min value for slow_mode_duration field.
|
* Fix mod_muc_slow_mode: add min value for slow_mode_duration field.
|
||||||
|
* Debug Mode: new option to promote some JIDs as admins on the MUC component.
|
||||||
|
|
||||||
## 8.3.1
|
## 8.3.1
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ interface DebugContent {
|
|||||||
prosodyDebuggerOptions?: ProsodyDebuggerOptions
|
prosodyDebuggerOptions?: ProsodyDebuggerOptions
|
||||||
alwaysPublishXMPPRoom?: boolean
|
alwaysPublishXMPPRoom?: boolean
|
||||||
enablePodcastChatTagForNonLive?: boolean
|
enablePodcastChatTagForNonLive?: boolean
|
||||||
|
mucAdmins?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
type DebugNumericValue = 'renewCertCheckInterval'
|
type DebugNumericValue = 'renewCertCheckInterval'
|
||||||
@ -63,6 +64,7 @@ function _readDebugFile (options: RegisterServerOptions): DebugContent | false {
|
|||||||
debugContent.remoteServerInfosMaxAge = _getNumericOptions(options, json, 'remote_server_infos_max_age')
|
debugContent.remoteServerInfosMaxAge = _getNumericOptions(options, json, 'remote_server_infos_max_age')
|
||||||
debugContent.alwaysPublishXMPPRoom = json.always_publish_xmpp_room === true
|
debugContent.alwaysPublishXMPPRoom = json.always_publish_xmpp_room === true
|
||||||
debugContent.enablePodcastChatTagForNonLive = json.enable_podcast_chat_tag_for_nonlive === true
|
debugContent.enablePodcastChatTagForNonLive = json.enable_podcast_chat_tag_for_nonlive === true
|
||||||
|
debugContent.mucAdmins = _getJIDs(options, json, 'muc_admins')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('Failed to read the debug_mode file content:', err)
|
logger.error('Failed to read the debug_mode file content:', err)
|
||||||
}
|
}
|
||||||
@ -101,6 +103,17 @@ function _getNumericOptions (options: RegisterServerOptions, json: any, name: st
|
|||||||
return json[name]
|
return json[name]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _getJIDs (options: RegisterServerOptions, json: any, name: string): string[] | undefined {
|
||||||
|
if (!(name in json)) { return undefined }
|
||||||
|
const v = json[name]
|
||||||
|
if (!Array.isArray(v)) { return undefined }
|
||||||
|
return v.filter(jid => {
|
||||||
|
if (typeof jid !== 'string') { return false }
|
||||||
|
if (!/^[a-zA-Z0-9_.-]+(?:@[a-zA-Z0-9_.-]+)?$/.test(jid)) { return false }
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function unloadDebugMode (): void {
|
function unloadDebugMode (): void {
|
||||||
debugContent = null
|
debugContent = null
|
||||||
}
|
}
|
||||||
@ -130,7 +143,7 @@ function isDebugMode (options: RegisterServerOptions, feature?: DebugBooleanValu
|
|||||||
*/
|
*/
|
||||||
function prosodyDebuggerOptions (options: RegisterServerOptions): false | ProsodyDebuggerOptions {
|
function prosodyDebuggerOptions (options: RegisterServerOptions): false | ProsodyDebuggerOptions {
|
||||||
// Additional security: testing NODE_ENV.
|
// Additional security: testing NODE_ENV.
|
||||||
// It should absolutly not be possible to enable Prosody debugger on production ev.
|
// It should absolutly not be possible to enable Prosody debugger on production env.
|
||||||
if (process.env.NODE_ENV !== 'dev') { return false }
|
if (process.env.NODE_ENV !== 'dev') { return false }
|
||||||
const debugContent = _readDebugFile(options)
|
const debugContent = _readDebugFile(options)
|
||||||
if (debugContent === false) { return false }
|
if (debugContent === false) { return false }
|
||||||
@ -198,10 +211,17 @@ function debugNumericParameter (
|
|||||||
return defaultDebug
|
return defaultDebug
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function debugMucAdmins (options: RegisterServerOptions): string[] | undefined {
|
||||||
|
const debugContent = _readDebugFile(options)
|
||||||
|
if (!debugContent) { return undefined }
|
||||||
|
return debugContent.mucAdmins
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
unloadDebugMode,
|
unloadDebugMode,
|
||||||
isDebugMode,
|
isDebugMode,
|
||||||
prosodyDebuggerOptions,
|
prosodyDebuggerOptions,
|
||||||
disableLuaUnboundIfNeeded,
|
disableLuaUnboundIfNeeded,
|
||||||
debugNumericParameter
|
debugNumericParameter,
|
||||||
|
debugMucAdmins
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import { getAPIKey } from '../apikey'
|
|||||||
import { parseExternalComponents } from './config/components'
|
import { parseExternalComponents } from './config/components'
|
||||||
import { getRemoteServerInfosDir } from '../federation/storage'
|
import { getRemoteServerInfosDir } from '../federation/storage'
|
||||||
import { BotConfiguration } from '../configuration/bot'
|
import { BotConfiguration } from '../configuration/bot'
|
||||||
|
import { debugMucAdmins } from '../debug'
|
||||||
|
|
||||||
async function getWorkingDir (options: RegisterServerOptions): Promise<string> {
|
async function getWorkingDir (options: RegisterServerOptions): Promise<string> {
|
||||||
const peertubeHelpers = options.peertubeHelpers
|
const peertubeHelpers = options.peertubeHelpers
|
||||||
@ -326,6 +327,11 @@ async function getProsodyConfig (options: RegisterServerOptionsV5): Promise<Pros
|
|||||||
|
|
||||||
config.useTestModule(apikey, testApiUrl)
|
config.useTestModule(apikey, testApiUrl)
|
||||||
|
|
||||||
|
const debugMucAdminJids = debugMucAdmins(options)
|
||||||
|
if (debugMucAdminJids) {
|
||||||
|
config.addMucAdmins(debugMucAdminJids)
|
||||||
|
}
|
||||||
|
|
||||||
let logLevel: ProsodyLogLevel | undefined
|
let logLevel: ProsodyLogLevel | undefined
|
||||||
if (logger.level && (typeof logger.level === 'string')) {
|
if (logger.level && (typeof logger.level === 'string')) {
|
||||||
if (logger.level === 'error' || logger.level === 'info' || logger.level === 'debug') {
|
if (logger.level === 'error' || logger.level === 'info' || logger.level === 'debug') {
|
||||||
|
@ -463,6 +463,12 @@ class ProsodyConfigContent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addMucAdmins (jids: string[]): void {
|
||||||
|
for (const jid of jids) {
|
||||||
|
this.muc.add('admins', jid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setLog (level: ProsodyLogLevel, syslog?: ProsodyLogLevel[]): void {
|
setLog (level: ProsodyLogLevel, syslog?: ProsodyLogLevel[]): void {
|
||||||
let log = ''
|
let log = ''
|
||||||
log += 'log = {\n'
|
log += 'log = {\n'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user