Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle no subscriber on bulk notifications #66

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/notification/dispatch_bulk_notification_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ func (s *DispatchBulkNotificationService) Dispatch(ctx context.Context, ns []Not
return nil, err
}

if len(metaMessages) == 0 {
s.deps.Logger.Info("no meta messages to process")
return nil, nil
}

if err := s.deps.LogService.LogNotifications(ctx, notificationLogs...); err != nil {
return nil, fmt.Errorf("failed logging notifications: %w", err)
}
Expand Down
4 changes: 4 additions & 0 deletions internal/api/v1beta1/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ func (s *GRPCServer) PostBulkNotifications(ctx context.Context, req *sirenv1beta
return nil, s.generateRPCErr(err)
}

if len(notificationIDs) == 0 {
return &sirenv1beta1.PostBulkNotificationsResponse{}, nil
}

if idempotencyKey != "" {
if err := s.notificationService.InsertIdempotency(ctx, idempotencyScope, idempotencyKey, strings.Join(notificationIDs, ",")); err != nil {
return nil, s.generateRPCErr(err)
Expand Down
Loading