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.
This commit is contained in:
Pascal Precht 2022-11-04 12:44:37 +01:00 committed by r4bbit.eth
parent 8ad9fb7713
commit c528660aa3
1 changed files with 6 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
"encoding/json" "encoding/json"
_errors "errors"
"fmt" "fmt"
"os" "os"
"strings" "strings"
@ -2300,7 +2301,11 @@ func (m *Messenger) RequestImportDiscordCommunity(request *requests.ImportDiscor
communityWithChats, changes, err := m.communitiesManager.CreateChat(discordCommunity.ID(), communityChat, false) communityWithChats, changes, err := m.communitiesManager.CreateChat(discordCommunity.ID(), communityChat, false)
if err != nil { if err != nil {
m.cleanUpImport(communityID) 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) importProgress.StopTask(discord.ChannelsCreationTask)
progressUpdates <- importProgress progressUpdates <- importProgress
return return