feat(invitations): accept invitations with C4 consent and contact grants; share the E0 quota across holdings

This commit is contained in:
shira committed 2026-10-09 18:03:35 +03:00
1 parent a5990d3fc6
commit 676b3c6e24
59 files changed
+4926 -194

No files matched your search

@@ -144,7 +144,7 @@ func (service *Service) declineInTransaction(
return declineOutcome{}, fmt.Errorf("%s - reserve idempotency record: %w", declineLocation, err)
}
if !created {
return replayDecline(ctx, unit, request, command, stored)
return service.replayDecline(ctx, unit, request, command, stored)
}
entry, err := readCandidateEntry(ctx, unit, command.ActorID, command.InvitationID, true)
if errors.Is(err, outbound.ErrInvitationNotFound) {
@@ -176,7 +176,7 @@ func (service *Service) declineFound(
if previous.Choice.Equal(command.Choice) {
// The same decline answers with the invitation as it is, whatever
// the key or the version, and records nothing again.
return completeDecline(ctx, unit, request, entry)
return service.completeDecline(ctx, unit, request, entry)
}
return refuseDecline(ctx, unit, command, request, outbound.InvitationDeclineStateConflict)
}
@@ -204,18 +204,18 @@ func (service *Service) declineFound(
return declineOutcome{}, fmt.Errorf("%s - store decline: %w", declineLocation, err)
}
entry.Invitation = declined
return completeDecline(ctx, unit, request, entry)
return service.completeDecline(ctx, unit, request, entry)
}
// completeDecline stores the successful outcome under the key and builds the
// response with the stored decline.
func completeDecline(
func (service *Service) completeDecline(
ctx context.Context,
unit outbound.UnitOfWork,
request declineRequest,
entry outbound.CandidateInvitationEntry,
) (declineOutcome, error) {
view, err := candidateView(ctx, unit, entry)
view, err := service.candidateView(ctx, unit, entry, request.now)
if err != nil {
return declineOutcome{}, err
}
@@ -263,7 +263,7 @@ func declineRefusal(outcome outbound.InvitationDeclineOutcome) error {
// key used with another request. A stored success is rebuilt from the
// declined invitation and its decline: both are final, so the replay shows
// the same answer without a second copy of the comment.
func replayDecline(
func (service *Service) replayDecline(
ctx context.Context,
unit outbound.UnitOfWork,
request declineRequest,
@@ -290,7 +290,7 @@ func replayDecline(
if entry.Invitation.State() != domain.InvitationDeclined {
return declineOutcome{}, fmt.Errorf("%s - validate original response: %w", declineLocation, domain.ErrInvalidInvitation)
}
view, err := candidateView(ctx, unit, entry)
view, err := service.candidateView(ctx, unit, entry, request.now)
if err != nil {
return declineOutcome{}, err
}