Skip to content

Commit

Permalink
Merge pull request #2267 from actiontech/issue2266
Browse files Browse the repository at this point in the history
add project name of workflow to the request of webhook
  • Loading branch information
ColdWaterLW authored Feb 23, 2024
2 parents 736b961 + 28ec516 commit 2ef3831
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions sqle/dms/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func GetUserNameWithDelTag(userId string) string {
return user.Name
}

// !dms-todo: 注意脚本服务调用该接口,接口修改会导致脚本服务调用原接口失败,需要通知相关开发修改接口调用
// dms-todo: 临时方案
func GetPorjectUIDByName(ctx context.Context, projectName string, needActive ...bool) (projectUID string, err error) {
project, err := GetPorjectByName(ctx, projectName)
Expand Down
16 changes: 15 additions & 1 deletion sqle/notification/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type webHookRequestBody struct {

type workflowPayload struct {
ProjectName string `json:"project_name"`
ProjectUID string `json:"project_uid"`
WorkflowID string `json:"workflow_id"`
WorkflowSubject string `json:"workflow_subject"`
WorkflowStatus string `json:"workflow_status"`
Expand Down Expand Up @@ -55,6 +56,18 @@ func workflowSendRequest(action string, workflow *model.Workflow) (err error) {
if err != nil {
return err
}
ret, _, err := dmsobject.ListProjects(context.TODO(), dms.GetDMSServerAddress(), v1.ListProjectReq{
PageSize: 1,
PageIndex: 1,
FilterByUID: string(workflow.ProjectId),
})
if err != nil {
return err
}
var projectName string
if len(ret) > 0 {
projectName = ret[0].Name
}
currentStepID := uint(0)
if workflow.CurrentStep() != nil {
currentStepID = workflow.CurrentStep().ID
Expand All @@ -65,7 +78,8 @@ func workflowSendRequest(action string, workflow *model.Workflow) (err error) {
Timestamp: time.Now().Format(time.RFC3339),
Payload: &httpBodyPayload{
Workflow: &workflowPayload{
ProjectName: string(workflow.ProjectId),
ProjectName: projectName,
ProjectUID: string(workflow.ProjectId),
WorkflowID: workflow.WorkflowId,
WorkflowSubject: workflow.Subject,
WorkflowStatus: workflow.Record.Status,
Expand Down

0 comments on commit 2ef3831

Please sign in to comment.