(ctx context.Context, webhookCtx *webhook.Context, webhookList []*store.ProjectWebhookMessage, workspaceID string)
| 240 | } |
| 241 | |
| 242 | func (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 | } |
no test coverage detected