From accb060e27ae2673c516bf90429cab509e12ee16 Mon Sep 17 00:00:00 2001 From: coward Date: Thu, 5 Dec 2024 10:43:40 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=E4=BF=AE=E5=A4=8D=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cron/task/client.go | 2 +- utils/wechat_notify.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cron/task/client.go b/cron/task/client.go index f745b6c..472ab85 100644 --- a/cron/task/client.go +++ b/cron/task/client.go @@ -65,7 +65,7 @@ func (c networkClient) ClientOfflineNotify() error { } // 如果存在,判断离线时间 - if time.Since(peer.LastHandshakeTime) < 3 { + if time.Since(peer.LastHandshakeTime).Minutes() < 3 { var ipAllocation string for _, iaip := range peer.AllowedIPs { ipAllocation += iaip.String() + "," diff --git a/utils/wechat_notify.go b/utils/wechat_notify.go index e333afc..a681a94 100644 --- a/utils/wechat_notify.go +++ b/utils/wechat_notify.go @@ -6,6 +6,7 @@ import ( "fmt" "gitee.ltd/lxh/logger/log" jsoniter "github.com/json-iterator/go" + "strings" "wireguard-ui/global/client" "wireguard-ui/model" ) @@ -36,6 +37,7 @@ func WechatNotify(setting *model.Setting) wechatNotify { // @param msg // @return error func (w wechatNotify) SendTextMessage(msg string) error { + log.Debugf("发送通知到微信: %v", msg) req := client.HttpClient.R() req.SetHeader("Content-Type", "application/json") @@ -43,7 +45,13 @@ func (w wechatNotify) SendTextMessage(msg string) error { "wxid": w.toUserId, "msg": msg, }) - result, err := req.Post(fmt.Sprintf("%s:%s", w.Addr, w.Path)) + + req.URL = fmt.Sprintf("%s:%s", w.Addr, w.Path) + switch strings.ToUpper(w.Method) { + case "POST": + req.Method = "POST" + } + result, err := req.SetDebug(true).Send() if err != nil { return err }