Skip to content

Commit 0abd613

Browse files
committed
Clarification on enqueue failure
Test fix Signed-off-by: Danny Kopping <danny@coder.com>
1 parent 8d12299 commit 0abd613

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

coderd/notifications/enqueuer.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ func (s *StoreEnqueuer) Enqueue(ctx context.Context, userID, templateID uuid.UUI
8383
CreatedBy: createdBy,
8484
})
8585
if err != nil {
86+
// We have a trigger on the notification_messages table named `inhibit_enqueue_if_disabled` which prevents messages
87+
// from being enqueued if the user has disabled them via notification_preferences. The trigger will fail the insertion
88+
// with the message "cannot enqueue message: user has disabled this notification".
89+
//
90+
// This is more efficient than fetching the user's preferences for each enqueue, and centralizes the business logic.
8691
if strings.Contains(err.Error(), ErrCannotEnqueueDisabledNotification.Error()) {
8792
return nil, ErrCannotEnqueueDisabledNotification
8893
}

0 commit comments

Comments
 (0)