Custom channel emoticons WIP (#130) + Fix cleanup on channel deletion.
This commit is contained in:
@ -8,6 +8,7 @@ import { fillVideoCustomFields } from '../../custom-fields'
|
||||
import { videoHasWebchat } from '../../../../shared/lib/video'
|
||||
import { updateProsodyRoom } from '../../prosody/api/manage-rooms'
|
||||
import { getChannelInfosById } from '../../database/channel'
|
||||
import { Emojis } from '../../emojis'
|
||||
|
||||
/**
|
||||
* Register stuffs related to channel configuration
|
||||
@ -40,11 +41,12 @@ async function initChannelConfiguration (options: RegisterServerOptions): Promis
|
||||
|
||||
registerHook({
|
||||
target: 'action:api.video-channel.deleted',
|
||||
handler: async (params: { channel: VideoChannel }) => {
|
||||
handler: async (params: { videoChannel: VideoChannel }) => {
|
||||
// When a video is deleted, we can delete the channel2room and room2channel files.
|
||||
// Note: don't need to check if there is a chat for this video, just deleting existing files...
|
||||
if (!params.channel.isLocal) { return }
|
||||
const channelId = params.channel.id
|
||||
|
||||
// Note: this hook is only called for local channels.
|
||||
const channelId = params.videoChannel.id
|
||||
logger.info(`Channel ${channelId} deleted, removing 'channel configuration' related stuff.`)
|
||||
// Here the associated channel can be either channel.X@mucdomain or video_uuid@mucdomain.
|
||||
// In first case, nothing to do... in the second, we must delete.
|
||||
@ -55,6 +57,13 @@ async function initChannelConfiguration (options: RegisterServerOptions): Promis
|
||||
logger.error(err)
|
||||
}
|
||||
|
||||
logger.info(`Channel ${channelId} deleted, removing 'custom emojis' related stuff.`)
|
||||
try {
|
||||
Emojis.singletonSafe()?.deleteChannelDefinition(channelId)
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
}
|
||||
|
||||
// Note: we don't delete the room. So that admins can check logs afterward, if any doubts.
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user