Skip to content

Commit

Permalink
fix: skip events are not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtARTs36 committed May 24, 2024
1 parent 729bbd8 commit 5e1877a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ notify:
```
{{ hook.Event.Title }}```
{{ hook.Event.IssueURL }}
{{ hook.Event.WebURL }}
to: my_team
issue:
Expand Down
16 changes: 9 additions & 7 deletions internal/notifier/immediately_notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ func NewImmediatelyNotifier(
}

func (n *ImmediatelyNotifier) Notify(ctx context.Context, payload sentry.Payload) error {
templates, err := n.selectTemplates(payload)
if err != nil {
return fmt.Errorf("notifier: failed to select templates: %w", err)
templates := n.selectTemplates(payload)
if len(templates) == 0 {
slog.DebugContext(ctx, "[notifier] no templates selected")

return nil
}

slog.DebugContext(ctx, fmt.Sprintf("[notifier] selected %d templates", len(templates)))
Expand Down Expand Up @@ -89,7 +91,7 @@ func (n *ImmediatelyNotifier) Notify(ctx context.Context, payload sentry.Payload

slog.InfoContext(ctx, fmt.Sprintf("[notifier] sending message via %s", mess.Name()))

err = mess.Send(ctx, messenger.Message{
err := mess.Send(ctx, messenger.Message{
Body: tmpl.message,
})
if err != nil {
Expand All @@ -116,15 +118,15 @@ func (n *ImmediatelyNotifier) selectMessengers(channelName string) ([]messenger.
return msgs, nil
}

func (n *ImmediatelyNotifier) selectTemplates(payload sentry.Payload) ([]Template, error) {
func (n *ImmediatelyNotifier) selectTemplates(payload sentry.Payload) []Template {
res := payload.GetHookResource()

msgs, exists := n.cfg.On[res]
if !exists {
return nil, fmt.Errorf("hook resource %q unsupported", res)
return []Template{}
}

return msgs, nil
return msgs
}

func (*ImmediatelyNotifier) Close() {
Expand Down
2 changes: 1 addition & 1 deletion sentry-notifier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ notify:
```
{{ hook.Event.Title }}```
{{ hook.Event.IssueURL }}
{{ hook.Event.WebURL }}
to: my_team
issue:
Expand Down

0 comments on commit 5e1877a

Please sign in to comment.