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

Method postWebhookList

backend/component/webhook/manager.go:242–271  ·  view source on GitHub ↗
(ctx context.Context, webhookCtx *webhook.Context, webhookList []*store.ProjectWebhookMessage, workspaceID string)

Source from the content-addressed store, hash-verified

240}
241
242func (m *Manager) postWebhookList(ctx context.Context, webhookCtx *webhook.Context, webhookList []*store.ProjectWebhookMessage, workspaceID string) {
243 ctx = context.WithoutCancel(ctx)
244 setting, err := m.store.GetAppIMSetting(ctx, workspaceID)
245 if err != nil {
246 slog.Error("failed to get app im setting", log.BBError(err))
247 } else {
248 webhookCtx.IMSetting = setting
249 }
250
251 for _, hook := range webhookList {
252 webhookCtx := *webhookCtx
253 webhookCtx.URL = hook.Payload.GetUrl()
254 webhookCtx.CreatedTS = time.Now().Unix()
255 webhookCtx.DirectMessage = hook.Payload.GetDirectMessage()
256 go func(webhookCtx *webhook.Context, hook *store.ProjectWebhookMessage) {
257 if err := common.Retry(ctx, func() error {
258 return webhook.Post(hook.Payload.GetType(), *webhookCtx)
259 }); err != nil {
260 // The external webhook endpoint might be invalid which is out of our code control, so we just emit a warning
261 slog.Warn("failed to post webhook event on activity",
262 slog.String("webhook type", hook.Payload.GetType().String()),
263 slog.String("webhook name", hook.Payload.GetTitle()),
264 slog.String("activity type", webhookCtx.EventType),
265 slog.String("title", webhookCtx.Title),
266 log.BBError(err))
267 return
268 }
269 }(&webhookCtx, hook)
270 }
271}

Callers 1

CreateEventMethod · 0.95

Calls 10

BBErrorFunction · 0.92
RetryFunction · 0.92
PostFunction · 0.92
GetAppIMSettingMethod · 0.80
StringMethod · 0.65
ErrorMethod · 0.45
GetUrlMethod · 0.45
GetDirectMessageMethod · 0.45
GetTypeMethod · 0.45
GetTitleMethod · 0.45

Tested by

no test coverage detected