Emoji only mode WIP
This commit is contained in:
@ -16,6 +16,8 @@ import {
|
||||
import { sanitizeChannelConfigurationOptions } from '../../configuration/channel/sanitize'
|
||||
import { getConverseJSParams } from '../../../lib/conversejs/params'
|
||||
import { Emojis } from '../../../lib/emojis'
|
||||
import { RoomChannel } from '../../../lib/room-channel'
|
||||
import { updateProsodyRoom } from '../../../lib/prosody/api/manage-rooms'
|
||||
|
||||
async function initConfigurationApiRouter (options: RegisterServerOptions, router: Router): Promise<void> {
|
||||
const logger = options.peertubeHelpers.logger
|
||||
@ -168,6 +170,20 @@ async function initConfigurationApiRouter (options: RegisterServerOptions, route
|
||||
|
||||
await emojis.saveChannelDefinition(channelInfos.id, emojisDefinitionSanitized, bufferInfos)
|
||||
|
||||
// We must update the emoji only regexp on the Prosody server.
|
||||
const emojisOnlyRegexp = await emojis.getChannelEmojisOnlyRegexp(channelInfos.id)
|
||||
const roomJIDs = RoomChannel.singleton().getChannelRoomJIDs(channelInfos.id)
|
||||
for (const roomJID of roomJIDs) {
|
||||
// No need to await here
|
||||
logger.info(`Updating room ${roomJID} emoji only regexp...`)
|
||||
updateProsodyRoom(options, roomJID, {
|
||||
livechat_emoji_only_regexp: emojisOnlyRegexp
|
||||
}).then(
|
||||
() => {},
|
||||
(err) => logger.error(err)
|
||||
)
|
||||
}
|
||||
|
||||
// Reloading data, to send them back to front:
|
||||
const channelEmojis =
|
||||
(await emojis.channelCustomEmojisDefinition(channelInfos.id)) ??
|
||||
|
@ -15,6 +15,7 @@ import {
|
||||
getChannelConfigurationOptions,
|
||||
getDefaultChannelConfigurationOptions
|
||||
} from '../../configuration/channel/storage'
|
||||
import { Emojis } from '../../emojis'
|
||||
|
||||
// See here for description: https://modules.prosody.im/mod_muc_http_defaults.html
|
||||
interface RoomDefaults {
|
||||
@ -37,6 +38,8 @@ interface RoomDefaults {
|
||||
// Following fields are specific to livechat (for now), and requires a customized version for mod_muc_http_defaults.
|
||||
slow_mode_duration?: number
|
||||
mute_anonymous?: boolean
|
||||
livechat_emoji_only?: boolean
|
||||
livechat_emoji_only_regexp?: string
|
||||
livechat_muc_terms?: string
|
||||
moderation_delay?: number
|
||||
anonymize_moderation_actions?: boolean
|
||||
@ -51,9 +54,12 @@ async function _getChannelSpecificOptions (
|
||||
const channelOptions = await getChannelConfigurationOptions(options, channelId) ??
|
||||
getDefaultChannelConfigurationOptions(options)
|
||||
|
||||
const emojiOnlyRegexp = await Emojis.singletonSafe()?.getChannelEmojisOnlyRegexp(channelId)
|
||||
|
||||
return {
|
||||
slow_mode_duration: channelOptions.slowMode.duration,
|
||||
mute_anonymous: channelOptions.mute.anonymous,
|
||||
livechat_emoji_only_regexp: emojiOnlyRegexp,
|
||||
livechat_muc_terms: channelOptions.terms,
|
||||
moderation_delay: channelOptions.moderation.delay,
|
||||
anonymize_moderation_actions: channelOptions.moderation.anonymize
|
||||
|
Reference in New Issue
Block a user