feat(notifications): send product notifications with a rights check right before each send
This commit is contained in:
1 parent
a856066316
commit
623d41b969
59 files changed
+4125
-1126
No files matched your search
@@ -0,0 +1,31 @@
|
||||
package notification
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"lincodex/backend/internal/domain"
|
||||
"lincodex/backend/internal/port/outbound"
|
||||
)
|
||||
|
||||
// invitationNoticeRights checks the notice that tells a candidate about a
|
||||
// delivered invitation: the standing it reads is the one the rule in
|
||||
// domain.Delivery.CheckInvitationNotice decides on.
|
||||
type invitationNoticeRights struct{}
|
||||
|
||||
// NewInvitationNoticeRights returns the rights check of invitation notices.
|
||||
func NewInvitationNoticeRights() SubjectRights { return invitationNoticeRights{} }
|
||||
|
||||
func (invitationNoticeRights) Subject() domain.MailSubjectKind {
|
||||
return domain.MailSubjectInvitation
|
||||
}
|
||||
|
||||
func (invitationNoticeRights) Check(ctx context.Context, unit outbound.UnitOfWork, delivery domain.Delivery, at time.Time) (domain.DeliveryCancelReason, error) {
|
||||
subject := delivery.Subject()
|
||||
standing, err := unit.NotificationRights().InvitationNoticeStanding(ctx, delivery.RecipientUserID(), subject.ID(), subject.OrganizationID())
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("invitationNoticeRights.Check - read standing: %w", err)
|
||||
}
|
||||
return delivery.CheckInvitationNotice(standing, at), nil
|
||||
}
|
||||
Reference in new issue
Block a user