feat(invitations): send invitations into the candidate inbox atomically
This commit is contained in:
1 parent
fc35e27af5
commit
1a067221f7
46 files changed
+3276
-113
No files matched your search
@@ -34,6 +34,8 @@ import (
|
||||
"lincodex/backend/internal/usecase/identity"
|
||||
invitationusecase "lincodex/backend/internal/usecase/invitation"
|
||||
needusecase "lincodex/backend/internal/usecase/need"
|
||||
"lincodex/backend/internal/usecase/notification"
|
||||
"lincodex/backend/internal/usecase/notification/mailtemplate"
|
||||
"lincodex/backend/internal/usecase/organization"
|
||||
"lincodex/backend/internal/usecase/policy"
|
||||
)
|
||||
@@ -104,12 +106,29 @@ func newInvitationHTTPHarness(ctx context.Context, t *testing.T, env *testEnviro
|
||||
if err != nil {
|
||||
t.Fatalf("candidateview.NewService() error = %v", err)
|
||||
}
|
||||
templates, err := mailtemplate.NewRenderer(env.Config.AppPublicURL)
|
||||
if err != nil {
|
||||
t.Fatalf("NewRenderer() error = %v", err)
|
||||
}
|
||||
notifier, err := notification.NewInvitationNotifier(notification.NewMailRequester(notification.NewTemplateRenderer(templates), clock.Now))
|
||||
if err != nil {
|
||||
t.Fatalf("NewInvitationNotifier() error = %v", err)
|
||||
}
|
||||
invitationService, err := invitationusecase.NewService(invitationusecase.Dependencies{
|
||||
Transactor: transactor, Keyring: keyring, PseudonymKey: key, Candidates: views.ResolveCandidateHandle, Clock: clock.Now,
|
||||
Transactor: transactor, Keyring: keyring, PseudonymKey: key, Candidates: views.ResolveCandidateHandle,
|
||||
Quota: func(ctx context.Context, unit outbound.UnitOfWork, organization domain.Organization, invitationID uuid.UUID) (outbound.CompanyQuotaDecision, error) {
|
||||
return quota.ReserveInvitation(ctx, unit, organization, invitationID)
|
||||
},
|
||||
Notifier: notifier, Clock: clock.Now,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("invitation.NewService() error = %v", err)
|
||||
}
|
||||
inbox, err := notification.NewInboxService(transactor,
|
||||
notification.NewInboxContentResolver(notification.DefaultInboxSourceResolvers(false)), clock.Now)
|
||||
if err != nil {
|
||||
t.Fatalf("notification.NewInboxService() error = %v", err)
|
||||
}
|
||||
logs := &strings.Builder{}
|
||||
logger := slog.New(slog.NewJSONHandler(logs, nil))
|
||||
responder := problem.NewResponder(logger)
|
||||
@@ -119,6 +138,7 @@ func newInvitationHTTPHarness(ctx context.Context, t *testing.T, env *testEnviro
|
||||
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)),
|
||||
)
|
||||
router, err := httpadapter.NewRouter(healthHandler, handler, identityHandler.SessionSecurity(), responder,
|
||||
prometheus.New(), logger, nil, httpadapter.NewCompanyContextMiddleware(organizationHandler))
|
||||
|
||||
Reference in new issue
Block a user