Fix muc domain
This commit is contained in:
parent
de243bdc01
commit
0e201d4e43
@ -17,7 +17,7 @@ type ChannelCommonRoomConf = Omit<RoomConf, 'local' | 'domain'>
|
|||||||
*/
|
*/
|
||||||
class BotConfiguration {
|
class BotConfiguration {
|
||||||
protected readonly options: RegisterServerOptions
|
protected readonly options: RegisterServerOptions
|
||||||
protected readonly prosodyDomain: string
|
protected readonly mucDomain: string
|
||||||
protected readonly confDir: string
|
protected readonly confDir: string
|
||||||
protected readonly roomConfDir: string
|
protected readonly roomConfDir: string
|
||||||
protected readonly logger: {
|
protected readonly logger: {
|
||||||
@ -31,12 +31,12 @@ class BotConfiguration {
|
|||||||
|
|
||||||
constructor (params: {
|
constructor (params: {
|
||||||
options: RegisterServerOptions
|
options: RegisterServerOptions
|
||||||
prosodyDomain: string
|
mucDomain: string
|
||||||
confDir: string
|
confDir: string
|
||||||
roomConfDir: string
|
roomConfDir: string
|
||||||
}) {
|
}) {
|
||||||
this.options = params.options
|
this.options = params.options
|
||||||
this.prosodyDomain = params.prosodyDomain
|
this.mucDomain = params.mucDomain
|
||||||
this.confDir = params.confDir
|
this.confDir = params.confDir
|
||||||
this.roomConfDir = params.roomConfDir
|
this.roomConfDir = params.roomConfDir
|
||||||
|
|
||||||
@ -54,10 +54,11 @@ class BotConfiguration {
|
|||||||
*/
|
*/
|
||||||
public static async initSingleton (options: RegisterServerOptions): Promise<BotConfiguration> {
|
public static async initSingleton (options: RegisterServerOptions): Promise<BotConfiguration> {
|
||||||
const prosodyDomain = await getProsodyDomain(options)
|
const prosodyDomain = await getProsodyDomain(options)
|
||||||
|
const mucDomain = 'room.' + prosodyDomain
|
||||||
const confDir = path.resolve(
|
const confDir = path.resolve(
|
||||||
options.peertubeHelpers.plugin.getDataDirectoryPath(),
|
options.peertubeHelpers.plugin.getDataDirectoryPath(),
|
||||||
'bot',
|
'bot',
|
||||||
prosodyDomain
|
mucDomain
|
||||||
)
|
)
|
||||||
const roomConfDir = path.resolve(
|
const roomConfDir = path.resolve(
|
||||||
confDir,
|
confDir,
|
||||||
@ -69,7 +70,7 @@ class BotConfiguration {
|
|||||||
|
|
||||||
singleton = new BotConfiguration({
|
singleton = new BotConfiguration({
|
||||||
options,
|
options,
|
||||||
prosodyDomain,
|
mucDomain,
|
||||||
confDir,
|
confDir,
|
||||||
roomConfDir
|
roomConfDir
|
||||||
})
|
})
|
||||||
@ -101,7 +102,7 @@ class BotConfiguration {
|
|||||||
|
|
||||||
const roomConf: RoomConf = Object.assign({
|
const roomConf: RoomConf = Object.assign({
|
||||||
local: roomJID,
|
local: roomJID,
|
||||||
domain: this.prosodyDomain
|
domain: this.mucDomain
|
||||||
}, conf)
|
}, conf)
|
||||||
|
|
||||||
if (!(roomConf.enabled ?? true)) {
|
if (!(roomConf.enabled ?? true)) {
|
||||||
@ -216,7 +217,7 @@ class BotConfiguration {
|
|||||||
this.logger.error('The room JID contains multiple @, not valid')
|
this.logger.error('The room JID contains multiple @, not valid')
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
if (splits[1] !== this.prosodyDomain) {
|
if (splits[1] !== this.mucDomain) {
|
||||||
this.logger.error('The room JID is not on the correct domain')
|
this.logger.error('The room JID is not on the correct domain')
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ let singleton: RoomChannel | undefined
|
|||||||
*/
|
*/
|
||||||
class RoomChannel {
|
class RoomChannel {
|
||||||
protected readonly options: RegisterServerOptions
|
protected readonly options: RegisterServerOptions
|
||||||
protected readonly prosodyDomain: string
|
protected readonly mucDomain: string
|
||||||
protected readonly dataFilePath: string
|
protected readonly dataFilePath: string
|
||||||
protected readonly logger: {
|
protected readonly logger: {
|
||||||
debug: (s: string) => void
|
debug: (s: string) => void
|
||||||
@ -38,11 +38,11 @@ class RoomChannel {
|
|||||||
|
|
||||||
constructor (params: {
|
constructor (params: {
|
||||||
options: RegisterServerOptions
|
options: RegisterServerOptions
|
||||||
prosodyDomain: string
|
mucDomain: string
|
||||||
dataFilePath: string
|
dataFilePath: string
|
||||||
}) {
|
}) {
|
||||||
this.options = params.options
|
this.options = params.options
|
||||||
this.prosodyDomain = params.prosodyDomain
|
this.mucDomain = params.mucDomain
|
||||||
this.dataFilePath = params.dataFilePath
|
this.dataFilePath = params.dataFilePath
|
||||||
|
|
||||||
const logger = params.options.peertubeHelpers.logger
|
const logger = params.options.peertubeHelpers.logger
|
||||||
@ -59,15 +59,16 @@ class RoomChannel {
|
|||||||
*/
|
*/
|
||||||
public static async initSingleton (options: RegisterServerOptions): Promise<RoomChannel> {
|
public static async initSingleton (options: RegisterServerOptions): Promise<RoomChannel> {
|
||||||
const prosodyDomain = await getProsodyDomain(options)
|
const prosodyDomain = await getProsodyDomain(options)
|
||||||
|
const mucDomain = 'room.' + prosodyDomain
|
||||||
const dataFilePath = path.resolve(
|
const dataFilePath = path.resolve(
|
||||||
options.peertubeHelpers.plugin.getDataDirectoryPath(),
|
options.peertubeHelpers.plugin.getDataDirectoryPath(),
|
||||||
'room-channel',
|
'room-channel',
|
||||||
prosodyDomain + '.json'
|
mucDomain + '.json'
|
||||||
)
|
)
|
||||||
|
|
||||||
singleton = new RoomChannel({
|
singleton = new RoomChannel({
|
||||||
options,
|
options,
|
||||||
prosodyDomain,
|
mucDomain,
|
||||||
dataFilePath
|
dataFilePath
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -291,7 +292,7 @@ class RoomChannel {
|
|||||||
const botConf: RoomConf = Object.assign(
|
const botConf: RoomConf = Object.assign(
|
||||||
{
|
{
|
||||||
local: roomJID,
|
local: roomJID,
|
||||||
domain: this.prosodyDomain
|
domain: this.mucDomain
|
||||||
},
|
},
|
||||||
channelConfigurationOptionsToBotRoomConf(this.options, channelConfigurationOptions)
|
channelConfigurationOptionsToBotRoomConf(this.options, channelConfigurationOptions)
|
||||||
)
|
)
|
||||||
@ -515,7 +516,7 @@ class RoomChannel {
|
|||||||
this.logger.error('The room JID contains multiple @, not valid')
|
this.logger.error('The room JID contains multiple @, not valid')
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
if (splits[1] !== this.prosodyDomain) {
|
if (splits[1] !== this.mucDomain) {
|
||||||
this.logger.error('The room JID is not on the correct domain')
|
this.logger.error('The room JID is not on the correct domain')
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user