feat(invitations): check contact grants on every read, cap pending invitations, and expire them at the deadline
This commit is contained in:
1 parent
676b3c6e24
commit
12a7213d4a
67 files changed
+4255
-149
No files matched your search
@@ -171,7 +171,9 @@ func (service *Service) acceptInTransaction(
|
||||
}
|
||||
|
||||
// acceptFound applies the checks that follow a found invitation and, when they
|
||||
// pass, stores the acceptance with its consent and grant.
|
||||
// pass, stores the acceptance with its consent and grant. The deadline is judged
|
||||
// at the time the row is held, and a due expiry is applied first, so an
|
||||
// acceptance at the deadline or later is refused with the expired state.
|
||||
func (service *Service) acceptFound(
|
||||
ctx context.Context,
|
||||
unit outbound.UnitOfWork,
|
||||
@@ -179,8 +181,16 @@ func (service *Service) acceptFound(
|
||||
request acceptRequest,
|
||||
entry outbound.CandidateInvitationEntry,
|
||||
) (acceptOutcome, error) {
|
||||
now, err := service.now(acceptLocation)
|
||||
if err != nil {
|
||||
return acceptOutcome{}, err
|
||||
}
|
||||
entry, err = settleCandidateEntry(ctx, unit, entry, now)
|
||||
if err != nil {
|
||||
return acceptOutcome{}, fmt.Errorf("%s - expire due invitation: %w", acceptLocation, err)
|
||||
}
|
||||
current := entry.Invitation
|
||||
at := notBefore(request.now, current.UpdatedAt())
|
||||
at := notBefore(now, current.UpdatedAt())
|
||||
switch {
|
||||
case current.State() == domain.InvitationAccepted:
|
||||
return service.repeatAccept(ctx, unit, command, request, entry)
|
||||
|
||||
Reference in new issue
Block a user