Commit 590e6db6 by CaIon

fix: 修复被禁用的渠道无法测试的问题

parent 40848f28
...@@ -332,9 +332,12 @@ func TestChannel(c *gin.Context) { ...@@ -332,9 +332,12 @@ func TestChannel(c *gin.Context) {
} }
channel, err := model.CacheGetChannel(channelId) channel, err := model.CacheGetChannel(channelId)
if err != nil { if err != nil {
channel, err = model.GetChannelById(channelId, true)
if err != nil {
common.ApiError(c, err) common.ApiError(c, err)
return return
} }
}
//defer func() { //defer func() {
// if channel.ChannelInfo.IsMultiKey { // if channel.ChannelInfo.IsMultiKey {
// go func() { _ = channel.SaveChannelInfo() }() // go func() { _ = channel.SaveChannelInfo() }()
......
...@@ -239,6 +239,20 @@ func CacheUpdateChannelStatus(id int, status int) { ...@@ -239,6 +239,20 @@ func CacheUpdateChannelStatus(id int, status int) {
if channel, ok := channelsIDM[id]; ok { if channel, ok := channelsIDM[id]; ok {
channel.Status = status channel.Status = status
} }
if status != common.ChannelStatusEnabled {
// delete the channel from group2model2channels
for group, model2channels := range group2model2channels {
for model, channels := range model2channels {
for i, channelId := range channels {
if channelId == id {
// remove the channel from the slice
group2model2channels[group][model] = append(channels[:i], channels[i+1:]...)
break
}
}
}
}
}
} }
func CacheUpdateChannel(channel *Channel) { func CacheUpdateChannel(channel *Channel) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment