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

@@ -134,13 +134,13 @@ func TestGetMineHasNoSideEffectAndViewMineKeepsTheDeadline(t *testing.T) {
}
}
func TestViewMineAtTheDeadlineChangesNothing(t *testing.T) {
func TestViewMineAtTheDeadlineExpiresTheInvitationAndRecordsNoView(t *testing.T) {
test := newHarness(t)
sent, candidateID := test.deliveredTo(t)
test.setTime(*sent.ResponseDeadlineAt)
view, err := test.service.ViewMine(t.Context(), candidateID, sent.ID)
if err != nil || view.State != domain.InvitationDelivered || view.Version != sent.Version || view.ViewedAt != nil {
t.Fatalf("late view = %+v, %v; want the delivered invitation unchanged", view, err)
if err != nil || view.State != domain.InvitationExpired || view.Version != sent.Version+1 || view.ViewedAt != nil {
t.Fatalf("late view = %+v, %v; want the invitation expired by the due expiry and no view", view, err)
}
}
@@ -211,8 +211,8 @@ func TestDeclineMineFollowsTheOrderOfChecks(t *testing.T) {
t.Fatalf("late decline error = %v, want ErrAnswerBlocked", err)
}
}
if state := test.transactor.snapshot(); len(state.declineResults) != 1 || state.invitations[sent.ID].State() != domain.InvitationDelivered {
t.Fatal("a late decline was not stored once or changed the invitation")
if state := test.transactor.snapshot(); len(state.declineResults) != 1 || state.invitations[sent.ID].State() != domain.InvitationExpired || len(state.declines) != 0 {
t.Fatal("a late decline was not stored once, or it recorded a decline or left the expired state unchanged")
}
// An unknown identifier is not found and stored as well.