From b06c370fd9927bcb33117bfea7176f158ff08008 Mon Sep 17 00:00:00 2001 From: CaIon <1808837298@qq.com> Date: Mon, 25 Sep 2023 18:53:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B8=A0=E9=81=93=E6=96=B0=E5=8F=AF?= =?UTF-8?q?=E9=80=89=E6=98=AF=E5=90=A6=E8=87=AA=E5=8A=A8=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- middleware/distributor.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/middleware/distributor.go b/middleware/distributor.go index 8c0ecddd..668241f2 100644 --- a/middleware/distributor.go +++ b/middleware/distributor.go @@ -87,7 +87,12 @@ func Distribute() func(c *gin.Context) { c.Set("channel", channel.Type) c.Set("channel_id", channel.Id) c.Set("channel_name", channel.Name) - c.Set("auto_ban", channel.AutoBan) + ban := true + // parse *int to bool + if channel.AutoBan != nil && *channel.AutoBan == 0 { + ban = false + } + c.Set("auto_ban", ban) c.Set("model_mapping", channel.GetModelMapping()) c.Request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", channel.Key)) c.Set("base_url", channel.GetBaseURL())