feat(marketing-pages): sendWelcomeEmail job + handler enqueues it
sendWelcomeEmailJob takes IMailerService, validates the typed input (userId + email), and delegates to mailer.sendWelcome. The onAuthUserSignedUpHandler now takes IJobQueue and enqueues "marketing-pages.send-welcome-email" with the event payload. Both binders bind a RecordingMailerService at the IMailerService symbol (production placeholder until a real adapter ships) and pass mailer / queue into the wrapped factories. Dev-seed additionally queue.register()s the slug so the in-memory queue dispatches via the wrapped job; production relies on the generated Payload event-task to resolve the wrapped handler from the container.
This commit is contained in:
@@ -18,6 +18,9 @@ import { getSiteSettingsController } from "../interface-adapters/controllers/get
|
||||
import { getPageBySlugController } from "../interface-adapters/controllers/get-page-by-slug.controller";
|
||||
import { userSignedUpEvent } from "@repo/auth";
|
||||
import { onAuthUserSignedUpHandler } from "../events/handlers/on-auth-user-signed-up.handler";
|
||||
import { sendWelcomeEmailJob } from "../jobs/send-welcome-email.job";
|
||||
import { RecordingMailerService } from "../infrastructure/services/recording-mailer.service";
|
||||
import type { IMailerService } from "../application/services/mailer.service.interface";
|
||||
|
||||
export function bindProductionMarketingPages(
|
||||
config: SanitizedConfig,
|
||||
@@ -119,10 +122,17 @@ export function bindProductionMarketingPages(
|
||||
),
|
||||
),
|
||||
);
|
||||
// bus + queue are accept-and-forward in Phase 6; consumed by Phase 7 generator
|
||||
// output at the <gen:event-handlers> / <gen:jobs> anchors below.
|
||||
void bus;
|
||||
void queue;
|
||||
// Bind the production mailer. Until a real SMTP/SES adapter ships, this is
|
||||
// a placeholder RecordingMailerService — production wiring is structurally
|
||||
// identical to dev-seed but the impl is the seam where a real mailer plugs in.
|
||||
if (marketingPagesContainer.isBound(MARKETING_PAGES_SYMBOLS.IMailerService)) {
|
||||
marketingPagesContainer.unbind(MARKETING_PAGES_SYMBOLS.IMailerService);
|
||||
}
|
||||
const mailer = new RecordingMailerService();
|
||||
marketingPagesContainer
|
||||
.bind<IMailerService>(MARKETING_PAGES_SYMBOLS.IMailerService)
|
||||
.toConstantValue(mailer);
|
||||
|
||||
// <gen:event-handlers>
|
||||
// onAuthUserSignedUpHandler subscription — generated, edit the handler file (not this block) for behavior.
|
||||
const wrappedAuthUserSignedUp = withSpan(
|
||||
@@ -135,7 +145,7 @@ export function bindProductionMarketingPages(
|
||||
layer: "event-handler",
|
||||
name: "marketing-pages.onAuthUserSignedUpHandler",
|
||||
},
|
||||
onAuthUserSignedUpHandler(),
|
||||
onAuthUserSignedUpHandler(queue),
|
||||
),
|
||||
);
|
||||
if (marketingPagesContainer.isBound(MARKETING_PAGES_SYMBOLS.IOnAuthUserSignedUpHandler)) {
|
||||
@@ -144,4 +154,21 @@ export function bindProductionMarketingPages(
|
||||
marketingPagesContainer.bind(MARKETING_PAGES_SYMBOLS.IOnAuthUserSignedUpHandler).toConstantValue(wrappedAuthUserSignedUp);
|
||||
bus.subscribe(userSignedUpEvent, "marketing-pages", wrappedAuthUserSignedUp);
|
||||
// <gen:jobs>
|
||||
const wrappedSendWelcomeEmail = withSpan(
|
||||
tracer,
|
||||
{ name: "marketing-pages.sendWelcomeEmail", op: "job" },
|
||||
withCapture(
|
||||
logger,
|
||||
{
|
||||
feature: "marketing-pages",
|
||||
layer: "job",
|
||||
name: "marketing-pages.sendWelcomeEmail",
|
||||
},
|
||||
sendWelcomeEmailJob(mailer),
|
||||
),
|
||||
);
|
||||
if (marketingPagesContainer.isBound(MARKETING_PAGES_SYMBOLS.ISendWelcomeEmailJob)) {
|
||||
marketingPagesContainer.unbind(MARKETING_PAGES_SYMBOLS.ISendWelcomeEmailJob);
|
||||
}
|
||||
marketingPagesContainer.bind(MARKETING_PAGES_SYMBOLS.ISendWelcomeEmailJob).toConstantValue(wrappedSendWelcomeEmail);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user