feat(invitations): let candidates read, view and decline their invitations

This commit is contained in:
shira committed 2026-10-09 17:25:12 +03:00
1 parent c410636b7f
commit ac57c05aca
27 files changed
+3285 -21

No files matched your search

@@ -43,6 +43,10 @@ type testState struct {
results map[[outbound.IdempotencyDigestSize]byte]domain.OrganizationInvitationView
sendResults map[[outbound.IdempotencyDigestSize]byte]outbound.InvitationSendResult
needVersions map[[3]string]bool
// declines holds the stored declines by invitation, and declineResults
// the decline outcomes kept under a key.
declines map[uuid.UUID]domain.InvitationDecline
declineResults map[[outbound.IdempotencyDigestSize]byte]outbound.InvitationDeclineResult
// charged lists the invitations charged against the organization quota,
// and notified the delivered invitations that were notified.
charged []uuid.UUID
@@ -53,10 +57,12 @@ func newTestState() testState {
return testState{
users: map[uuid.UUID]domain.User{}, memberships: map[[2]uuid.UUID]domain.Membership{},
invitations: map[uuid.UUID]domain.Invitation{}, terms: map[termsKey]domain.InvitationTerms{},
idempotency: map[[outbound.IdempotencyDigestSize]byte]outbound.IdempotencyRecord{},
results: map[[outbound.IdempotencyDigestSize]byte]domain.OrganizationInvitationView{},
sendResults: map[[outbound.IdempotencyDigestSize]byte]outbound.InvitationSendResult{},
needVersions: map[[3]string]bool{},
idempotency: map[[outbound.IdempotencyDigestSize]byte]outbound.IdempotencyRecord{},
results: map[[outbound.IdempotencyDigestSize]byte]domain.OrganizationInvitationView{},
sendResults: map[[outbound.IdempotencyDigestSize]byte]outbound.InvitationSendResult{},
needVersions: map[[3]string]bool{},
declines: map[uuid.UUID]domain.InvitationDecline{},
declineResults: map[[outbound.IdempotencyDigestSize]byte]outbound.InvitationDeclineResult{},
}
}
@@ -87,6 +93,12 @@ func (state testState) clone() testState {
for key, found := range state.needVersions {
cloned.needVersions[key] = found
}
for id, decline := range state.declines {
cloned.declines[id] = decline
}
for scope, result := range state.declineResults {
cloned.declineResults[scope] = result
}
cloned.charged = slices.Clone(state.charged)
cloned.notified = slices.Clone(state.notified)
return cloned
@@ -143,6 +155,9 @@ func (unit *testUnit) InvitationCreationResults() outbound.InvitationCreationRes
func (unit *testUnit) InvitationSendResults() outbound.InvitationSendResultRepository {
return testInvitations{state: unit.state}
}
func (unit *testUnit) InvitationDeclineResults() outbound.InvitationDeclineResultRepository {
return testInvitations{state: unit.state}
}
type testUsers struct {
outbound.UserRepository
@@ -217,6 +232,7 @@ func (repository testIdempotency) PurgeExpired(_ context.Context, at time.Time,
delete(repository.state.idempotency, scope)
delete(repository.state.results, scope)
delete(repository.state.sendResults, scope)
delete(repository.state.declineResults, scope)
deleted++
}
}