MCPcopy Create free account
hub / github.com/bytebase/bytebase / getMessageCard

Function getMessageCard

backend/plugin/webhook/wecom/wecom.go:61–89  ·  view source on GitHub ↗
(context webhook.Context)

Source from the content-addressed store, hash-verified

59}
60
61func getMessageCard(context webhook.Context) *WebhookMarkdown {
62 metaStrList := []string{}
63 for _, meta := range context.GetMetaList() {
64 metaStrList = append(metaStrList, fmt.Sprintf("**%s**: %s", meta.Name, meta.Value))
65 }
66 if context.ActorName != "" {
67 metaStrList = append(metaStrList, fmt.Sprintf("**Actor**: %s (%s)", context.ActorName, context.ActorEmail))
68 }
69
70 status := ""
71 switch context.Level {
72 case webhook.WebhookSuccess:
73 status = "<font color=\"green\">Success</font> "
74 case webhook.WebhookWarn:
75 status = "<font color=\"yellow\">Warn</font> "
76 case webhook.WebhookError:
77 status = "<font color=\"red\">Error</font> "
78 default:
79 // For any other level (including WebhookInfo), use no special formatting
80 status = ""
81 }
82 content := fmt.Sprintf("# %s%s\n\n%s\n[View in Bytebase](%s)", status, context.Title, strings.Join(metaStrList, "\n"), context.Link)
83 if context.Description != "" {
84 content = fmt.Sprintf("# %s%s\n> %s\n\n%s\n[View in Bytebase](%s)", status, context.Title, context.Description, strings.Join(metaStrList, "\n"), context.Link)
85 }
86 return &WebhookMarkdown{
87 Content: content,
88 }
89}
90
91func (r *Receiver) Post(context webhook.Context) error {
92 if context.DirectMessage && len(context.MentionEndUsers) > 0 {

Callers 2

sendMessageMethod · 0.70
sendDirectMessageMethod · 0.70

Calls 2

GetMetaListMethod · 0.80
JoinMethod · 0.80

Tested by

no test coverage detected