Add the reusable RMS core application (server, web UI, plugins, tests, tools) with generic defaults, GPL licensing, and maintainer context documentation so deployments can consume this repo as software source independent of station-specific overlays.
33 lines
984 B
JavaScript
33 lines
984 B
JavaScript
async function createPlugin(ctx) {
|
|
return {
|
|
async execute(action, input) {
|
|
if (action !== "send_challenge") {
|
|
throw new Error(`Unknown action: ${action}`);
|
|
}
|
|
const payload = input && input.payload ? input.payload : {};
|
|
const recipient = input && input.recipient ? String(input.recipient) : "";
|
|
if (!recipient) {
|
|
throw new Error("recipient missing");
|
|
}
|
|
const entry = {
|
|
at: new Date().toISOString(),
|
|
via: "rms.auth.otp_email",
|
|
to: recipient,
|
|
from: String(ctx.getSetting("from", ctx.env.SMTP_FROM || "noreply@arcg.at")),
|
|
subject: String(payload.subject || "ARCG OTP"),
|
|
text: String(payload.text || ""),
|
|
html: String(payload.html || "")
|
|
};
|
|
await ctx.appendMailOutbox(entry);
|
|
return { ok: true, delivered: true, transport: "otp-email-plugin" };
|
|
},
|
|
async health() {
|
|
return { ok: true };
|
|
}
|
|
};
|
|
}
|
|
|
|
module.exports = {
|
|
createPlugin
|
|
};
|