From e3f9ef1894eb7731e41b2b1d2ed2c4c21785df49 Mon Sep 17 00:00:00 2001 From: "1808837298@qq.com" <1808837298@qq.com> Date: Thu, 6 Mar 2025 15:56:42 +0800 Subject: [PATCH] fix: error NotifyRootUser #812 --- relay/helper/stream_scanner.go | 3 +++ service/channel.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/relay/helper/stream_scanner.go b/relay/helper/stream_scanner.go index 115e2de8..7a7507f5 100644 --- a/relay/helper/stream_scanner.go +++ b/relay/helper/stream_scanner.go @@ -15,10 +15,13 @@ import ( ) func StreamScannerHandler(c *gin.Context, resp *http.Response, info *relaycommon.RelayInfo, dataHandler func(data string) bool) { + if resp == nil { return } + defer resp.Body.Close() + streamingTimeout := time.Duration(constant.StreamingTimeout) * time.Second if strings.HasPrefix(info.UpstreamModelName, "o1") || strings.HasPrefix(info.UpstreamModelName, "o3") { // twice timeout for thinking model diff --git a/service/channel.go b/service/channel.go index 7fb41fe3..0f4270a4 100644 --- a/service/channel.go +++ b/service/channel.go @@ -15,14 +15,14 @@ func DisableChannel(channelId int, channelName string, reason string) { model.UpdateChannelStatusById(channelId, common.ChannelStatusAutoDisabled, reason) subject := fmt.Sprintf("通道「%s」(#%d)已被禁用", channelName, channelId) content := fmt.Sprintf("通道「%s」(#%d)已被禁用,原因:%s", channelName, channelId, reason) - NotifyRootUser(subject, content, dto.NotifyTypeChannelUpdate) + NotifyRootUser(dto.NotifyTypeChannelUpdate, subject, content) } func EnableChannel(channelId int, channelName string) { model.UpdateChannelStatusById(channelId, common.ChannelStatusEnabled, "") subject := fmt.Sprintf("通道「%s」(#%d)已被启用", channelName, channelId) content := fmt.Sprintf("通道「%s」(#%d)已被启用", channelName, channelId) - NotifyRootUser(subject, content, dto.NotifyTypeChannelUpdate) + NotifyRootUser(dto.NotifyTypeChannelUpdate, subject, content) } func ShouldDisableChannel(channelType int, err *dto.OpenAIErrorWithStatusCode) bool {