Files
outline/plugins/passkeys/server/processors/PasskeyCreatedProcessor.ts
Tom MoorandCopilot Autofix powered by AI 5693618de4 Add translation hooks to transactional emails (#11785)
* First pass

* fix: Missing translations

* fix: Missing translations

* welcome

* Apply suggestions from code review

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* translations

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-20 23:28:51 -04:00

30 lines
890 B
TypeScript

import { UserPasskey, User } from "@server/models";
import type { Event, UserPasskeyEvent } from "@server/types";
import BaseProcessor from "@server/queues/processors/BaseProcessor";
import { PasskeyCreatedEmail } from "../email/templates/PasskeyCreatedEmail";
export class PasskeyCreatedProcessor extends BaseProcessor {
static applicableEvents: Event["name"][] = ["passkeys.create"];
async perform(event: UserPasskeyEvent) {
const userPasskey = await UserPasskey.findByPk(event.modelId);
if (!userPasskey) {
return;
}
const user = await User.scope("withTeam").findByPk(event.userId);
if (!user) {
return;
}
await new PasskeyCreatedEmail({
to: user.email,
language: user.language,
userId: user.id,
passkeyId: userPasskey.id,
passkeyName: userPasskey.name,
teamUrl: user.team.url,
}).schedule();
}
}