Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: optimize im message (#14215)
ecmadaoda0bd278978e
diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.goindex 6542796a4d..72ce046305 100644--- a/backend/api/v1/project_service.go+++ b/backend/api/v1/project_service.go@@ -869,9 +869,9 @@ func (s *ProjectService) TestWebhook(ctx context.Context, request *v1pb.TestWebhTitleZh: fmt.Sprintf("测试 webhook %q", webhook.Title),Description: "This is a test",Link: fmt.Sprintf("%s/project/%s/webhook/%s", setting.ExternalUrl, fmt.Sprintf("%s-%d", slug.Make(project.Title), project.UID), fmt.Sprintf("%s-%d", slug.Make(webhook.Title), webhook.ID)),- CreatorID: api.SystemBotID,- CreatorName: "Bytebase",- CreatorEmail: s.store.GetSystemBotUser(ctx).Email,+ ActorID: api.SystemBotID,+ ActorName: "Bytebase",+ ActorEmail: s.store.GetSystemBotUser(ctx).Email,CreatedTs: time.Now().Unix(),Issue: &webhookplugin.Issue{ID: 1,diff --git a/backend/component/webhook/manager.go b/backend/component/webhook/manager.goindex 99dbb9a51f..3ec2c2b545 100644--- a/backend/component/webhook/manager.go+++ b/backend/component/webhook/manager.go@@ -326,6 +326,7 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, actiStatus: e.Issue.Status,Type: e.Issue.Type,Description: e.Issue.Description,+ Creator: e.Issue.Creator,},Project: &webhook.Project{ID: e.Project.UID,@@ -335,9 +336,9 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, actiTaskResult: nil,Description: e.Comment,Link: link,- CreatorID: e.Actor.ID,- CreatorName: e.Actor.Name,- CreatorEmail: e.Actor.Email,+ ActorID: e.Actor.ID,+ ActorName: e.Actor.Name,+ ActorEmail: e.Actor.Email,MentionEndUsers: mentionEndUsers,MentionUsersByPhone: mentions,}diff --git a/backend/plugin/webhook/custom.go b/backend/plugin/webhook/custom.goindex 83d533baad..de4389425a 100644--- a/backend/plugin/webhook/custom.go+++ b/backend/plugin/webhook/custom.go@@ -44,8 +44,8 @@ func (*CustomReceiver) Post(context Context) error {Title: context.Title,Description: context.Description,Link: context.Link,- CreatorID: context.CreatorID,- CreatorName: context.CreatorName,+ CreatorID: context.ActorID,+ CreatorName: context.ActorName,CreatedTS: context.CreatedTs,Issue: context.Issue,Project: context.Project,diff --git a/backend/plugin/webhook/dingtalk/dingtalk.go b/backend/plugin/webhook/dingtalk/dingtalk.goindex 6f7165171f..173c928598 100644--- a/backend/plugin/webhook/dingtalk/dingtalk.go+++ b/backend/plugin/webhook/dingtalk/dingtalk.go@@ -51,7 +51,7 @@ func (*DingTalkReceiver) Post(context webhook.Context) error {for _, meta := range context.GetMetaListZh() {metaStrList = append(metaStrList, fmt.Sprintf("##### **%s:** %s", meta.Name, meta.Value))}- metaStrList = append(metaStrList, fmt.Sprintf("##### **由:** %s (%s)", context.CreatorName, context.CreatorEmail))+ metaStrList = append(metaStrList, fmt.Sprintf("##### **由:** %s (%s)", context.ActorName, context.ActorEmail))text := fmt.Sprintf("# %s\n%s\n##### [在 Bytebase 中显示](%s)", context.TitleZh, strings.Join(metaStrList, "\n"), context.Link)if context.Description != "" {diff --git a/backend/plugin/webhook/discord.go b/backend/plugin/webhook/discord.goindex 6c7a789fa8..83cd2b90d0 100644--- a/backend/plugin/webhook/discord.go+++ b/backend/plugin/webhook/discord.go@@ -74,7 +74,7 @@ func (*DiscordReceiver) Post(context Context) error {Description: context.Description,URL: context.Link,Author: DiscordWebhookEmbedAuthor{- Name: fmt.Sprintf("%s (%s)", context.CreatorName, context.CreatorEmail),+ Name: fmt.Sprintf("%s (%s)", context.ActorName, context.ActorEmail),},FieldList: fieldList,})diff --git a/backend/plugin/webhook/feishu/feishu.go b/backend/plugin/webhook/feishu/feishu.goindex 60b9044073..8162bea8ff 100644--- a/backend/plugin/webhook/feishu/feishu.go+++ b/backend/plugin/webhook/feishu/feishu.go@@ -215,7 +215,7 @@ func getMessageCard(context webhook.Context) *WebhookCard {_, _ = markdownBuf.WriteString(fmt.Sprintf("**%s**: %s\n", meta.Name, meta.Value))}- _, _ = markdownBuf.WriteString(fmt.Sprintf("**By**: %s (%s)\n[View in Bytebase](%s)", context.CreatorName, context.CreatorEmail, context.Link))+ _, _ = markdownBuf.WriteString(fmt.Sprintf("**Actor**: %s (%s)\n[View in Bytebase](%s)", context.ActorName, context.ActorEmail, context.Link))return &WebhookCard{Config: WebhookCardConfig{diff --git a/backend/plugin/webhook/slack/slack.go b/backend/plugin/webhook/slack/slack.goindex b5782306d5..db8418554c 100644--- a/backend/plugin/webhook/slack/slack.go+++ b/backend/plugin/webhook/slack/slack.go@@ -101,7 +101,7 @@ func GetBlocks(context webhook.Context) []Block {Type: "section",Text: &BlockMarkdown{Type: "mrkdwn",- Text: fmt.Sprintf("By: %s (%s)", context.CreatorName, context.CreatorEmail),+ Text: fmt.Sprintf("Actor: %s (%s)", context.ActorName, context.ActorEmail),},})diff --git a/backend/plugin/webhook/teams.go b/backend/plugin/webhook/teams.goindex 6713442869..cfdf909b61 100644--- a/backend/plugin/webhook/teams.go+++ b/backend/plugin/webhook/teams.go@@ -72,7 +72,7 @@ func (*TeamsReceiver) Post(context Context) error {Title: context.Title,SectionList: []TeamsWebhookSection{{- ActivityTitle: fmt.Sprintf("%s (%s)", context.CreatorName, context.CreatorEmail),+ ActivityTitle: fmt.Sprintf("%s (%s)", context.ActorName, context.ActorEmail),FactList: factList,Text: context.Description,},diff --git a/backend/plugin/webhook/webhook.go b/backend/plugin/webhook/webhook.goindex 72f0f2a9a6..f756edbd59 100644--- a/backend/plugin/webhook/webhook.go+++ b/backend/plugin/webhook/webhook.go@@ -2,6 +2,7 @@package webhookimport (+ "fmt""sync""time"@@ -42,11 +43,12 @@ const (// Issue object of issue.type Issue struct {- ID int `json:"id"`- Name string `json:"name"`- Status string `json:"status"`- Type string `json:"type"`- Description string `json:"description"`+ ID int `json:"id"`+ Name string `json:"name"`+ Status string `json:"status"`+ Type string `json:"type"`+ Description string `json:"description"`+ Creator *store.UserMessage `json:"-"`}type Stage struct {@@ -78,9 +80,9 @@ type Context struct {TitleZh stringDescription stringLink string- CreatorID int- CreatorName string- CreatorEmail string+ ActorID int+ ActorName string+ ActorEmail stringCreatedTs int64Issue *IssueStage *Stage@@ -113,6 +115,9 @@ func (c *Context) GetMetaList() []Meta {m = append(m, Meta{Name: "Issue",Value: c.Issue.Name,+ }, Meta{+ Name: "Issue Ctrator",+ Value: fmt.Sprintf("%s (%s)", c.Issue.Creator.Name, c.Issue.Creator.Email),})// For VCS workflow, the generated issue description is composed of file names in the push event.// So the description could be long, which is hard to display if merged into the issue name.diff --git a/backend/plugin/webhook/wecom/wecom.go b/backend/plugin/webhook/wecom/wecom.goindex a6a68c5ab5..499ff6454f 100644--- a/backend/plugin/webhook/wecom/wecom.go+++ b/backend/plugin/webhook/wecom/wecom.go@@ -49,7 +49,7 @@ func getMessageCard(context webhook.Context) *WebhookMarkdown {for _, meta := range context.GetMetaList() {metaStrList = append(metaStrList, fmt.Sprintf("%s: <font color=\"comment\">%s</font>", meta.Name, meta.Value))}- metaStrList = append(metaStrList, fmt.Sprintf("By: <font color=\"comment\">%s (%s)</font>", context.CreatorName, context.CreatorEmail))+ metaStrList = append(metaStrList, fmt.Sprintf("Actor: <font color=\"comment\">%s (%s)</font>", context.ActorName, context.ActorEmail))status := ""switch context.Level {