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

@@ -28,6 +28,7 @@ import (
"lincodex/backend/internal/domain"
"lincodex/backend/internal/port/outbound"
"lincodex/backend/internal/usecase/anonymousprofile"
"lincodex/backend/internal/usecase/candidateprivacy"
"lincodex/backend/internal/usecase/candidateview"
"lincodex/backend/internal/usecase/companyquota"
"lincodex/backend/internal/usecase/consent"
@@ -130,16 +131,25 @@ func newInvitationHTTPHarness(ctx context.Context, t *testing.T, env *testEnviro
if err != nil {
t.Fatalf("notification.NewInboxService() error = %v", err)
}
// The consent and the visibility operations are served too, so the contact
// read can be revoked through the same routes a candidate uses.
privacySettings, err := candidateprivacy.NewService(candidateprivacy.Dependencies{Transactor: transactor, Clock: clock.Now})
if err != nil {
t.Fatalf("candidateprivacy.NewService() error = %v", err)
}
logs := &strings.Builder{}
logger := slog.New(slog.NewJSONHandler(logs, nil))
responder := problem.NewResponder(logger)
healthHandler := v1.NewHealthHandler(health.NewReadiness(env.Postgres), time.Second)
identityHandler := v1.NewIdentityHandler(nil, v1.WithSessionService(sessionService), v1.WithPublicOrigin(env.Config.AppPublicURL))
organizationHandler := v1.NewOrganizationHandler(organizationService, env.Config.AppPublicURL)
consentHandler := v1.NewConsentHandler(consent.NewQueryService(postgresadapter.NewConsentStore(pool), clock.Now), consent.NewService(transactor, clock.Now))
privacyHandler := v1.NewPrivacyHandler(views, privacySettings, env.Config.AppPublicURL)
handler := v1.NewHandler(healthHandler, responder,
v1.WithIdentity(identityHandler), v1.WithOrganization(organizationHandler),
v1.WithNeed(v1.NewNeedHandler(needService)), v1.WithInvitation(v1.NewInvitationHandler(invitationService)),
v1.WithNotifications(v1.NewNotificationHandler(inbox)),
v1.WithConsent(consentHandler), v1.WithPrivacy(privacyHandler),
)
router, err := httpadapter.NewRouter(healthHandler, handler, identityHandler.SessionSecurity(), responder,
prometheus.New(), logger, nil, httpadapter.NewCompanyContextMiddleware(organizationHandler))