Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Issue creation webhook
天舟80cac6f5e548
diff --git a/frontend/src/types/projectWebhook.ts b/frontend/src/types/projectWebhook.tsindex d6304416c5..0cb57a5c11 100644--- a/frontend/src/types/projectWebhook.ts+++ b/frontend/src/types/projectWebhook.ts@@ -55,6 +55,11 @@ type ProjectWebhookActivityItem = {};export const PROJECT_HOOK_ACTIVITY_ITEM_LIST: ProjectWebhookActivityItem[] = [+ {+ title: "Issue creation",+ label: "When new issue has been created",+ activity: "bb.issue.create",+ },{title: "Issue status change",label: "When issue status has changed",diff --git a/server/activity_manager.go b/server/activity_manager.goindex d01c428214..77905f1889 100644--- a/server/activity_manager.go+++ b/server/activity_manager.go@@ -37,6 +37,7 @@ func (m *ActivityManager) CreateActivity(ctx context.Context, create *api.Activiif meta.issue != nil {postInbox := falseswitch create.Type {+ case api.ActivityIssueCreate:case api.ActivityIssueStatusUpdate:case api.ActivityIssueCommentCreate:case api.ActivityIssueFieldUpdate:@@ -95,6 +96,8 @@ func (m *ActivityManager) CreateActivity(ctx context.Context, create *api.Activilink := fmt.Sprintf("%s:%d/issue/%s", m.s.frontendHost, m.s.frontendPort, api.IssueSlug(meta.issue))metaList := []webhook.WebhookMeta{}switch create.Type {+ case api.ActivityIssueCreate:+ title = fmt.Sprintf("Issue created - %s", meta.issue.Name)case api.ActivityIssueStatusUpdate:switch meta.issue.Status {case "OPEN":@@ -107,15 +110,7 @@ func (m *ActivityManager) CreateActivity(ctx context.Context, create *api.Activicase api.ActivityIssueCommentCreate:title = "Comment created"link += fmt.Sprintf("#activity%d", activity.ID)- metaList = append(metaList, webhook.WebhookMeta{- Name: "Issue",- Value: meta.issue.Name,- })case api.ActivityIssueFieldUpdate:- metaList = append(metaList, webhook.WebhookMeta{- Name: "Issue",- Value: meta.issue.Name,- })update := &api.ActivityIssueFieldUpdatePayload{}if err := json.Unmarshal([]byte(activity.Payload), update); err != nil {m.s.l.Warn("Failed to post webhook event after changing the issue field, failed to unmarshal paylaod",@@ -187,10 +182,6 @@ func (m *ActivityManager) CreateActivity(ctx context.Context, create *api.Activititle = "Updated issue"}case api.ActivityPipelineTaskStatusUpdate:- metaList = append(metaList, webhook.WebhookMeta{- Name: "Issue",- Value: meta.issue.Name,- })update := &api.ActivityPipelineTaskStatusUpdatePayload{}if err := json.Unmarshal([]byte(activity.Payload), update); err != nil {m.s.l.Warn("Failed to post webhook event after changing the issue task status, failed to unmarshal paylaod",@@ -228,6 +219,10 @@ func (m *ActivityManager) CreateActivity(ctx context.Context, create *api.Activi}}+ metaList = append(metaList, webhook.WebhookMeta{+ Name: "Issue",+ Value: meta.issue.Name,+ })metaList = append(metaList, webhook.WebhookMeta{Name: "Project",Value: meta.issue.Project.Name,diff --git a/server/issue.go b/server/issue.goindex f5c42976b3..16a84fd9d5 100644--- a/server/issue.go+++ b/server/issue.go@@ -402,15 +402,13 @@ func (s *Server) CreateIssue(ctx context.Context, issueCreate *api.IssueCreate,Level: api.ACTIVITY_INFO,Payload: string(bytes),}- activity, err := s.ActivityService.CreateActivity(context.Background(), activityCreate)+ _, err = s.ActivityManager.CreateActivity(context.Background(), activityCreate, &ActivityMeta{+ issue: issue,+ })if err != nil {return nil, fmt.Errorf("failed to create activity after creating the issue: %v. Error %w", issue.Name, err)}- if err := s.PostInboxIssueActivity(context.Background(), issue, activity.ID); err != nil {- return nil, err- }-if err := s.ComposeIssueRelationship(context.Background(), issue); err != nil {return nil, err}