feat(notifications): send product notifications with a rights check right before each send

This commit is contained in:
shira committed 2026-10-09 20:38:39 +03:00
1 parent a856066316
commit 623d41b969
59 files changed
+4125 -1126

No files matched your search

@@ -193,8 +193,26 @@ type DeliveryRetrySnapshot struct {
ManualRetryStartedAt time.Time
}
// ClaimScope names the lane a claim serves. Each lane has its own claim
// statement and partial due index, so an idle poll of one lane never reads
// the backlog of the other.
type ClaimScope int
const (
// ClaimScopeService claims service identity mail: verification and
// password reset, through deliveries_due_idx. It is the zero value, so a
// claim that names no lane is a service claim.
ClaimScopeService ClaimScope = iota
// ClaimScopeNotification claims product notifications, through
// deliveries_product_due_idx.
ClaimScopeNotification
)
// DeliveryClaim selects and leases the next delivery for a sending worker.
type DeliveryClaim struct {
// Scope selects the lane and its claim statement. Kinds must be the kinds
// of that lane.
Scope ClaimScope
// Owner identifies the worker; a lease belongs to it.
Owner uuid.UUID
// Account is the configured provider account. Only deliveries pinned to
@@ -0,0 +1,23 @@
package outbound
import (
"context"
"github.com/google/uuid"
"lincodex/backend/internal/domain"
)
// NotificationRightsReader reads the standing that the rights checks of
// product notifications need. It runs inside the caller's transaction, in
// the same transaction that holds the delivery lock, and it locks nothing
// itself. It returns the facts of one record only, never an address, a
// contact, or the content of a notification.
type NotificationRightsReader interface {
// InvitationNoticeStanding reads the standing of an invitation notice: the
// recipient account, the invitation the recipient is addressed by, the
// hiding of the sending organization, and the current publication. A
// missing account or invitation is reported as not found, not as an
// error.
InvitationNoticeStanding(ctx context.Context, recipientUserID, invitationID, organizationID uuid.UUID) (domain.InvitationNoticeStanding, error)
}
@@ -79,6 +79,7 @@ type UnitOfWork interface {
Deliveries() DeliveryRepository
MailRequests() MailRequestRepository
MailQuotas() MailQuotaRepository
NotificationRights() NotificationRightsReader
Outbox() OutboxWriter
ScheduledJobs() JobScheduler
}