feat(invitations): check contact grants on every read, cap pending invitations, and expire them at the deadline

This commit is contained in:
shira committed 2026-10-09 19:06:50 +03:00
1 parent 676b3c6e24
commit 12a7213d4a
67 files changed
+4255 -149

No files matched your search

+5 -5
View File
@@ -122,7 +122,7 @@ func (service *Service) createInTransaction(
if err := unit.Invitations().Create(ctx, invitation, event); err != nil {
return domain.OrganizationInvitationView{}, fmt.Errorf("%s - store draft: %w", createLocation, err)
}
view, err := service.view(invitation)
view, err := service.view(ctx, unit, invitation)
if err != nil {
return domain.OrganizationInvitationView{}, err
}
@@ -300,7 +300,7 @@ func (service *Service) updateInTransaction(
merged := mergeDraft(before, command)
changed := before.ChangedFields(merged)
if len(changed) == 0 {
return service.view(current)
return service.view(ctx, unit, current)
}
if command.ExpectedVersion != current.Version() {
return domain.OrganizationInvitationView{}, fmt.Errorf("%s - compare expected version: %w", updateLocation, domain.ErrInvitationVersionConflict)
@@ -333,7 +333,7 @@ func (service *Service) updateInTransaction(
}
return domain.OrganizationInvitationView{}, fmt.Errorf("%s - save draft: %w", updateLocation, err)
}
return service.view(next)
return service.view(ctx, unit, next)
}
// mergeDraft applies the fields the command sets over the current content.
@@ -407,7 +407,7 @@ func (service *Service) Get(ctx context.Context, actorID, organizationID, invita
if err != nil {
return fmt.Errorf("%s - read invitation: %w", getLocation, err)
}
result, err = service.view(current)
result, err = service.view(ctx, unit, current)
return err
})
if err != nil {
@@ -452,7 +452,7 @@ func (service *Service) List(ctx context.Context, command ListCommand) (Page, er
}
result = Page{Items: make([]domain.OrganizationInvitationView, 0, len(page.Items)), HasMore: page.HasMore}
for _, invitation := range page.Items {
item, err := service.view(invitation)
item, err := service.view(ctx, unit, invitation)
if err != nil {
return err
}