fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
@@ -29,8 +30,43 @@ func NewWebhookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WebhookLo
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *WebhookLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
// webhook消息事件基础信息
|
||||
type BaseWebhookMsgHeaderType struct {
|
||||
EventId string `json:"event_id"` //事件id(可作为消息唯一性确认)
|
||||
EventType string `json:"event_type"` //事件类型
|
||||
CreateTime string `json:"create_time"` //创建时间
|
||||
Token string `json:"token"` //事件token
|
||||
AppId string `json:"app_id"` //app id
|
||||
TenantKey string `json:"tenant_key"` //租户key
|
||||
}
|
||||
|
||||
func (l *WebhookLogic) Webhook(req *types.WebhookReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
var msgHeader BaseWebhookMsgHeaderType
|
||||
if req.Event["header"] == nil {
|
||||
logx.Error("invalid request")
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid request")
|
||||
}
|
||||
if err := json.Unmarshal([]byte(req.Event["header"].(string)), &msgHeader); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusAddMessage(basic.CodeJsonErr, "failed to parse params")
|
||||
}
|
||||
logx.Info("收到事件:" + msgHeader.EventType)
|
||||
switch msgHeader.EventType {
|
||||
case "contact.custom_attr_event.updated_v3": //成员字段管理属性变更事件
|
||||
case "contact.department.created_v3": //部门新建
|
||||
case "contact.department.deleted_v3": //部门删除
|
||||
case "contact.department.updated_v3": //部门信息变化
|
||||
case "contact.employee_type_enum.actived_v3": //启动人员类型事件
|
||||
case "contact.employee_type_enum.created_v3": //新建人员类型事件
|
||||
case "contact.employee_type_enum.deactivated_v3": //停用人员类型事件
|
||||
case "contact.employee_type_enum.deleted_v3": //删除人员类型事件
|
||||
case "contact.employee_type_enum.updated_v3": //修改人员类型名称事件
|
||||
case "contact.scope.updated_v3": //通讯录范围权限被更新
|
||||
case "contact.user.created_v3": //员工入职
|
||||
case "contact.user.deleted_v3": //员工离职
|
||||
case "contact.user.updated_v3": //员工信息变化
|
||||
|
||||
}
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user