Fix Discord Import getting stuck (#4681)

* fix(community_import): fix import getting stuck in case of error in msgs

Fixes #13438 and #13439

* fix(community_import): fixes a bug with the timestamp format

The importer didn't like `-` time zones like `-4`. Using the standard date format makes it work.
This commit is contained in:
Jonathan Rainville 2024-02-07 13:02:47 -05:00 committed by GitHub
parent 9c89409c94
commit 18e7b6c331
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -48,7 +48,7 @@ var messageArchiveInterval = 7 * 24 * time.Hour
// 1 day interval
var updateActiveMembersInterval = 24 * time.Hour
const discordTimestampLayout = "2006-01-02T15:04:05+00:00"
const discordTimestampLayout = time.RFC3339
const (
importSlowRate = time.Second / 1

View File

@ -662,6 +662,13 @@ func (m *Messenger) RequestImportDiscordChannel(request *requests.ImportDiscordC
messagesToSave, pinMessagesToSave, authorProfilesToSave, messageAttachmentsToDownload :=
m.processDiscordMessages(channel, newChat, importProgress, progressUpdates, request.From, community)
// If either there were no messages in the channel or something happened and all the messages errored, we
// we still up the percent to 100%
if len(messagesToSave) == 0 {
importProgress.UpdateTaskProgress(discord.ImportMessagesTask, 1.0)
progressUpdates <- importProgress
}
var discordMessages []*protobuf.DiscordMessage
for _, msg := range messagesToSave {
if msg.ChatMessage.ContentType == protobuf.ChatMessage_DISCORD_MESSAGE {
@ -994,6 +1001,12 @@ func (m *Messenger) RequestImportDiscordChannel(request *requests.ImportDiscordC
return
}
// Make sure all progress tasks are at 100%, in case one of the steps had errors
// The front-end doesn't understand that the import is done until all tasks are at 100%
importProgress.UpdateTaskProgress(discord.CommunityCreationTask, float32(1.0))
importProgress.UpdateTaskProgress(discord.ChannelsCreationTask, float32(1.0))
importProgress.UpdateTaskProgress(discord.ImportMessagesTask, float32(1.0))
importProgress.UpdateTaskProgress(discord.DownloadAssetsTask, float32(1.0))
importProgress.UpdateTaskProgress(discord.InitCommunityTask, float32(1.0))
m.config.messengerSignalsHandler.DiscordChannelImportFinished(request.CommunityID.String(), newChat.ID)