From deed8bb14cf2c299b1a58b902590cbba7d793b86 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 6 Nov 2023 15:06:15 +0800 Subject: [PATCH] fix --- .../internal/handler/ticketwebhookhandler.go | 13 ++++++++++--- .../internal/logic/ticketwebhooklogic.go | 11 +---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/server/feishu-sync/internal/handler/ticketwebhookhandler.go b/server/feishu-sync/internal/handler/ticketwebhookhandler.go index 0351028e..6970c3ea 100644 --- a/server/feishu-sync/internal/handler/ticketwebhookhandler.go +++ b/server/feishu-sync/internal/handler/ticketwebhookhandler.go @@ -1,7 +1,7 @@ package handler import ( - "fmt" + "encoding/json" "net/http" "reflect" @@ -14,13 +14,20 @@ import ( func TicketWebhookHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - fmt.Println(r.Header) var req types.TicketWebhookReq userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } - + //验证连接 + if req.Type == "url_verification" { + challengeRsp := map[string]string{ + "challenge": req.Challenge, + } + b, _ := json.Marshal(challengeRsp) + w.Write(b) + return + } // 创建一个业务逻辑层实例 l := logic.NewTicketWebhookLogic(r.Context(), svcCtx) diff --git a/server/feishu-sync/internal/logic/ticketwebhooklogic.go b/server/feishu-sync/internal/logic/ticketwebhooklogic.go index 52862844..b62012b4 100644 --- a/server/feishu-sync/internal/logic/ticketwebhooklogic.go +++ b/server/feishu-sync/internal/logic/ticketwebhooklogic.go @@ -1,7 +1,6 @@ package logic import ( - "encoding/json" "fusenapi/utils/auth" "fusenapi/utils/basic" "net/http" @@ -33,15 +32,7 @@ func NewTicketWebhookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Tic // } func (l *TicketWebhookLogic) TicketWebhook(req *types.TicketWebhookReq, userinfo *auth.UserInfo, w http.ResponseWriter) (resp *basic.Response) { - //验证连接 - if req.Type == "url_verification" { - challengeRsp := map[string]string{ - "challenge": req.Challenge, - } - b, _ := json.Marshal(challengeRsp) - w.Write(b) - return - } + return resp.SetStatusWithMessage(basic.CodeOK, "success") }