@cocalc/server
Version:
CoCalc server functionality: functions used by either the hub and the next.js server
31 lines • 1.32 kB
JavaScript
;
/*
* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
* License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const smtp_1 = __importDefault(require("./smtp"));
const sendgrid_1 = __importDefault(require("./sendgrid"));
const throttle_1 = __importDefault(require("./throttle"));
const server_settings_1 = require("../settings/server-settings");
async function sendEmail(message, account_id // account that we are sending this email *on behalf of*, if any (used for throttling).
) {
await (0, throttle_1.default)(account_id);
const { email_backend } = await (0, server_settings_1.getServerSettings)();
switch (email_backend) {
case "":
case "none":
throw Error(`no email backend configured`);
case "smtp":
return await (0, smtp_1.default)(message);
case "sendgrid":
return await (0, sendgrid_1.default)(message);
default:
throw Error(`no valid email backend configured: ${email_backend}`);
}
}
exports.default = sendEmail;
//# sourceMappingURL=send-email.js.map