use shared cache

This commit is contained in:
Dot-Rar 2020-04-02 20:53:11 +01:00
parent 770d8925bf
commit 26172fbd89
86 changed files with 9138 additions and 9136 deletions

View File

@ -114,17 +114,20 @@ func UpdateSettingsHandler(ctx *gin.Context) {
// Archive channel // Archive channel
// Create a list of IDs // Create a list of IDs
var channelIds []string channelsChan := make(chan []table.Channel)
for _, c := range guild.Channels { go table.GetCachedChannelsByGuild(guildId, channelsChan)
channelIds = append(channelIds, c.Id) channels := <-channelsChan
var channelIds []int64
for _, channel := range channels {
channelIds = append(channelIds, channel.ChannelId)
} }
// Update or archive channel // Update or archive channel
archiveChannelStr := ctx.PostForm("archivechannel") archiveChannelStr := ctx.PostForm("archivechannel")
if utils.Contains(channelIds, archiveChannelStr) { archiveChannelId, err := strconv.ParseInt(archiveChannelStr, 10, 64)
// Error is impossible, as we check it's a valid channel already if err == nil && utils.Contains(channelIds, archiveChannelId) {
parsed, _ := strconv.ParseInt(archiveChannelStr, 10, 64) table.UpdateArchiveChannel(guildId, archiveChannelId)
table.UpdateArchiveChannel(guildId, parsed)
} }
// Users can close // Users can close

View File

@ -24,4 +24,3 @@ func GetArchiveChannel(guildId int64) int64 {
return channel.Channel return channel.Channel
} }