From 43efc2161a873397b0b62195018e6443631c3371 Mon Sep 17 00:00:00 2001 From: CaIon Date: Mon, 25 Aug 2025 11:20:16 +0800 Subject: [PATCH] feat: add SaveWithoutKey method to Channel and update status saving logic --- model/channel.go | 6 +++++- service/channel.go | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/model/channel.go b/model/channel.go index 0d21b076a..7aa7d0975 100644 --- a/model/channel.go +++ b/model/channel.go @@ -247,6 +247,10 @@ func (channel *Channel) Save() error { return DB.Save(channel).Error } +func (channel *Channel) SaveWithoutKey() error { + return DB.Omit("key").Save(channel).Error +} + func GetAllChannels(startIdx int, num int, selectAll bool, idSort bool) ([]*Channel, error) { var channels []*Channel var err error @@ -645,7 +649,7 @@ func UpdateChannelStatus(channelId int, usingKey string, status int, reason stri channel.Status = status shouldUpdateAbilities = true } - err = channel.Save() + err = channel.SaveWithoutKey() if err != nil { common.SysLog(fmt.Sprintf("failed to update channel status: channel_id=%d, status=%d, error=%v", channel.Id, status, err)) return false diff --git a/service/channel.go b/service/channel.go index 20eefee0f..6ddc8e9ec 100644 --- a/service/channel.go +++ b/service/channel.go @@ -18,11 +18,11 @@ func formatNotifyType(channelId int, status int) string { // disable & notify func DisableChannel(channelError types.ChannelError, reason string) { + common.SysLog(fmt.Sprintf("通道「%s」(#%d)发生错误,准备禁用,原因:%s", channelError.ChannelName, channelError.ChannelId, reason)) + // 检查是否启用自动禁用功能 if !channelError.AutoBan { - if common.DebugEnabled { - common.SysLog(fmt.Sprintf("通道「%s」(#%d)未启用自动禁用功能,跳过禁用操作", channelError.ChannelName, channelError.ChannelId)) - } + common.SysLog(fmt.Sprintf("通道「%s」(#%d)未启用自动禁用功能,跳过禁用操作", channelError.ChannelName, channelError.ChannelId)) return }