fix
This commit is contained in:
parent
09fcd6c7ab
commit
fd86cccdf2
|
@ -27,7 +27,7 @@ func TicketWebhookHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
rl := reflect.ValueOf(l)
|
||||
basic.BeforeLogic(w, r, rl)
|
||||
|
||||
resp := l.TicketWebhook(&req, userinfo)
|
||||
resp := l.TicketWebhook(&req, userinfo, w)
|
||||
|
||||
if !basic.AfterLogic(w, r, rl, resp) {
|
||||
basic.NormalAfterLogic(w, r, resp)
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"net/http"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -30,8 +32,17 @@ func NewTicketWebhookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Tic
|
|||
// func (l *TicketWebhookLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
func (l *TicketWebhookLogic) TicketWebhook(req *types.TicketWebhookReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
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")
|
||||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
|
|
|
@ -10,6 +10,8 @@ type TicketWebhookReq struct {
|
|||
Uuid string `json:"uuid"` //事件唯一标识
|
||||
Token string `json:"token"` //即Verification Token
|
||||
Event Event `json:"event"` //事件
|
||||
Challenge string `json:"challenge"` //设置飞书通知接口验证用
|
||||
Type string `json:"type"` //设置飞书通知接口验证用
|
||||
}
|
||||
|
||||
type Event struct {
|
||||
|
|
|
@ -20,6 +20,8 @@ type TicketWebhookReq {
|
|||
Uuid string `json:"uuid"` //事件唯一标识
|
||||
Token string `json:"token"` //即Verification Token
|
||||
Event Event `json:"event"` //事件
|
||||
Challenge string `json:"challenge"` //设置飞书通知接口验证用
|
||||
Type string `json:"type"` //设置飞书通知接口验证用
|
||||
}
|
||||
|
||||
type Event {
|
||||
|
|
Loading…
Reference in New Issue
Block a user