diff options
author | Raphael <mail@raphaelkabo.com> | 2025-04-23 10:45:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-23 10:45:02 +0100 |
commit | 8553c6a78ab81fec8972bf49ae06533f437373cd (patch) | |
tree | 0dc1454d6a1e9733d48a3fedc0636b789e9b0ae9 /src/routes.js | |
parent | 96a65ab5f9c7d6e6e4c54d00f9f8200c9ff378a3 (diff) | |
parent | ebe7a6182fe84ac0ed49b75e40e60b54d414fe36 (diff) |
Merge branch 'main' into fix-issue-197
Diffstat (limited to 'src/routes.js')
-rwxr-xr-x | src/routes.js | 44 |
1 files changed, 4 insertions, 40 deletions
diff --git a/src/routes.js b/src/routes.js index 1c132ca..e758e6b 100755 --- a/src/routes.js +++ b/src/routes.js @@ -24,6 +24,7 @@ import EventGroup from "./models/EventGroup.js"; import path from "path"; import { activityPubContentType } from "./lib/activitypub.js"; import { hashString } from "./util/generator.js"; +import { initEmailService } from "./lib/email.js"; const config = getConfig(); const domain = config.general.domain; @@ -43,46 +44,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()); |