summaryrefslogtreecommitdiff
path: root/src/routes.js
diff options
context:
space:
mode:
authorINOUE Daisuke <1407574+dinoue@users.noreply.github.com>2025-04-28 21:01:02 +0900
committerGitHub <noreply@github.com>2025-04-28 21:01:02 +0900
commitc5a527e63c16c17a18d4452952fa17fe045abc67 (patch)
tree8bd6c35cce70d1af280ae48f0d7bcf85b1d91201 /src/routes.js
parent9f0c750c05a6ae53a00e7f238b9b1610f3dc05c6 (diff)
parentb04e6394c5c5d882800f5215feae89d76a18af23 (diff)
Merge branch 'main' into feature/localization-again
Diffstat (limited to 'src/routes.js')
-rwxr-xr-xsrc/routes.js44
1 files changed, 4 insertions, 40 deletions
diff --git a/src/routes.js b/src/routes.js
index b85452f..3a6d8a4 100755
--- a/src/routes.js
+++ b/src/routes.js
@@ -25,6 +25,7 @@ import path from "path";
import { activityPubContentType } from "./lib/activitypub.js";
import { hashString } from "./util/generator.js";
import i18next from "i18next";
+import { initEmailService } from "./lib/email.js";
const config = getConfig();
const domain = config.general.domain;
@@ -44,46 +45,9 @@ const nanoid = customAlphabet(
const router = express.Router();
let sendEmails = false;
-let nodemailerTransporter;
-if (config.general.mail_service) {
- switch (config.general.mail_service) {
- case "sendgrid":
- sgMail.setApiKey(config.sendgrid?.api_key);
- console.log("Sendgrid is ready to send emails.");
- sendEmails = true;
- break;
- case "nodemailer":
- const nodemailerConfig = {
- host: config.nodemailer?.smtp_server,
- port: Number(config.nodemailer?.smtp_port) || 587,
- };
-
- if (config.nodemailer?.smtp_username) {
- nodemailerConfig.auth = {
- user: config.nodemailer?.smtp_username,
- pass: config.nodemailer?.smtp_password
- };
- }
-
- nodemailerTransporter = nodemailer.createTransport(nodemailerConfig);
-
- nodemailerTransporter.verify((error, success) => {
- if (error) {
- console.log(error);
- } else {
- console.log(
- "Nodemailer SMTP server is ready to send emails.",
- );
- sendEmails = true;
- }
- });
- break;
- default:
- console.error(
- "You have not configured this Gathio instance to send emails! This means that event creators will not receive emails when their events are created, which means they may end up locked out of editing events. Consider setting up an email service.",
- );
- }
-}
+initEmailService().then((emailService) => {
+ sendEmails = emailService
+});
router.use(fileUpload());