fix(discord): Handle multiple channels with the same name (#4313)
This commit is contained in:
parent
7b752ac34c
commit
4ae9c02e57
|
@ -1087,6 +1087,9 @@ func (m *Messenger) RequestImportDiscordCommunity(request *requests.ImportDiscor
|
||||||
processedChannelIds := make(map[string]string, 0)
|
processedChannelIds := make(map[string]string, 0)
|
||||||
processedCategoriesIds := make(map[string]string, 0)
|
processedCategoriesIds := make(map[string]string, 0)
|
||||||
|
|
||||||
|
// The map with counts of duplicated channel names
|
||||||
|
uniqueChatNames := make(map[string]int, 0)
|
||||||
|
|
||||||
for i, importFile := range request.FilesToImport {
|
for i, importFile := range request.FilesToImport {
|
||||||
|
|
||||||
exportData, errs := m.ExtractDiscordDataFromImportFiles([]string{importFile})
|
exportData, errs := m.ExtractDiscordDataFromImportFiles([]string{importFile})
|
||||||
|
@ -1184,12 +1187,20 @@ func (m *Messenger) RequestImportDiscordCommunity(request *requests.ImportDiscor
|
||||||
}
|
}
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
|
channelUniqueName := channel.Channel.Name
|
||||||
|
if count, ok := uniqueChatNames[channelUniqueName]; ok {
|
||||||
|
uniqueChatNames[channelUniqueName] = count + 1
|
||||||
|
channelUniqueName = fmt.Sprintf("%s_%d", channelUniqueName, uniqueChatNames[channelUniqueName])
|
||||||
|
} else {
|
||||||
|
uniqueChatNames[channelUniqueName] = 1
|
||||||
|
}
|
||||||
|
|
||||||
communityChat := &protobuf.CommunityChat{
|
communityChat := &protobuf.CommunityChat{
|
||||||
Permissions: &protobuf.CommunityPermissions{
|
Permissions: &protobuf.CommunityPermissions{
|
||||||
Access: protobuf.CommunityPermissions_AUTO_ACCEPT,
|
Access: protobuf.CommunityPermissions_AUTO_ACCEPT,
|
||||||
},
|
},
|
||||||
Identity: &protobuf.ChatIdentity{
|
Identity: &protobuf.ChatIdentity{
|
||||||
DisplayName: channel.Channel.Name,
|
DisplayName: channelUniqueName,
|
||||||
Emoji: "",
|
Emoji: "",
|
||||||
Description: channel.Channel.Description,
|
Description: channel.Channel.Description,
|
||||||
Color: discordCommunity.Color(),
|
Color: discordCommunity.Color(),
|
||||||
|
|
Loading…
Reference in New Issue