feat(discord_import): send signal when the import was cleaned up (#4693)

This is to let the front end know that the community was deleted so it can also delete it from the UI
This commit is contained in:
Jonathan Rainville 2024-02-12 16:04:12 -05:00 committed by GitHub
parent ca973b4aa6
commit 1c42c07760
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 0 deletions

View File

@ -382,6 +382,7 @@ func (m *Messenger) cleanUpImport(communityID string) {
if deleteErr != nil {
m.logger.Error("clean up failed, couldn't delete community messages", zap.Error(deleteErr))
}
m.config.messengerSignalsHandler.DiscordCommunityImportCleanedUp(communityID)
}
func (m *Messenger) cleanUpImportChannel(communityID string, channelID string) {

View File

@ -57,6 +57,7 @@ type MessengerSignalsHandler interface {
DiscordCommunityImportProgress(importProgress *discord.ImportProgress)
DiscordCommunityImportFinished(communityID string)
DiscordCommunityImportCancelled(communityID string)
DiscordCommunityImportCleanedUp(communityID string)
DiscordChannelImportProgress(importProgress *discord.ImportProgress)
DiscordChannelImportFinished(communityID string, channelID string)
DiscordChannelImportCancelled(channelID string)

View File

@ -153,6 +153,10 @@ func (m *MessengerSignalsHandler) DiscordCommunityImportCancelled(id string) {
signal.SendDiscordCommunityImportCancelled(id)
}
func (m *MessengerSignalsHandler) DiscordCommunityImportCleanedUp(id string) {
signal.SendDiscordCommunityImportCleanedUp(id)
}
func (m *MessengerSignalsHandler) DiscordChannelImportCancelled(id string) {
signal.SendDiscordChannelImportCancelled(id)
}

View File

@ -22,6 +22,9 @@ const (
// the discord community was cancelled
EventDiscordCommunityImportCancelled = "community.discordCommunityImportCancelled"
// EventDiscordCommunityImportCleanedUp triggered when the community has been cleaned up (deleted)
EventDiscordCommunityImportCleanedUp = "community.discordCommunityImportCleanedUp"
// EventDiscordChannelImportProgress is triggered during the import
// of a discord community channel as it progresses
EventDiscordChannelImportProgress = "community.discordChannelImportProgress"
@ -54,6 +57,10 @@ type DiscordCommunityImportCancelledSignal struct {
CommunityID string `json:"communityId"`
}
type DiscordCommunityImportCleanedUpSignal struct {
CommunityID string `json:"communityId"`
}
type DiscordChannelImportProgressSignal struct {
ImportProgress *discord.ImportProgress `json:"importProgress"`
}
@ -107,6 +114,12 @@ func SendDiscordCommunityImportCancelled(communityID string) {
})
}
func SendDiscordCommunityImportCleanedUp(communityID string) {
send(EventDiscordCommunityImportCleanedUp, DiscordCommunityImportCleanedUpSignal{
CommunityID: communityID,
})
}
func SendDiscordChannelImportCancelled(channelID string) {
send(EventDiscordChannelImportCancelled, DiscordChannelImportCancelledSignal{
ChannelID: channelID,