From c528660aa3be050ad8de90af85d2620455f63ff2 Mon Sep 17 00:00:00 2001 From: Pascal Precht <445106+PascalPrecht@users.noreply.github.com> Date: Fri, 4 Nov 2022 12:44:37 +0100 Subject: [PATCH] fix(communities): improve error message about duplicated chat names We don't allow multiple channels with the same name in communities. Discord allows for multiple channels with the same name (living in different categories), so this is an error case in our import tool. This commit improves the user facing error message of this scenario. --- protocol/messenger_communities.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/protocol/messenger_communities.go b/protocol/messenger_communities.go index 370c5b340..f355befce 100644 --- a/protocol/messenger_communities.go +++ b/protocol/messenger_communities.go @@ -4,6 +4,7 @@ import ( "context" "crypto/ecdsa" "encoding/json" + _errors "errors" "fmt" "os" "strings" @@ -2300,7 +2301,11 @@ func (m *Messenger) RequestImportDiscordCommunity(request *requests.ImportDiscor communityWithChats, changes, err := m.communitiesManager.CreateChat(discordCommunity.ID(), communityChat, false) if err != nil { m.cleanUpImport(communityID) - importProgress.AddTaskError(discord.ChannelsCreationTask, discord.Error(err.Error())) + errmsg := err.Error() + if _errors.Is(err, communities.ErrInvalidCommunityDescriptionDuplicatedName) { + errmsg = fmt.Sprintf("Couldn't create channel '%s': %s", communityChat.Identity.DisplayName, err.Error()) + } + importProgress.AddTaskError(discord.ChannelsCreationTask, discord.Error(errmsg)) importProgress.StopTask(discord.ChannelsCreationTask) progressUpdates <- importProgress return