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

View File

@ -5,7 +5,7 @@ import (
)
type ArchiveChannel struct {
Guild int64 `gorm:"column:GUILDID"`
Guild int64 `gorm:"column:GUILDID"`
Channel int64 `gorm:"column:CHANNELID"`
}
@ -24,4 +24,3 @@ func GetArchiveChannel(guildId int64) int64 {
return channel.Channel
}