chore: Refactoring event processors and service architecture (#2495)

This commit is contained in:
Tom Moor
2021-08-27 21:42:13 -07:00
committed by GitHub
parent 86f008293a
commit 28aef82af9
61 changed files with 1610 additions and 1498 deletions

View File

@@ -4,7 +4,7 @@ import Router from "koa-router";
import { find } from "lodash";
import { parseDomain, isCustomSubdomain } from "../../../shared/utils/domains";
import { AuthorizationError } from "../../errors";
import mailer, { sendEmail } from "../../mailer";
import mailer from "../../mailer";
import errorHandling from "../../middlewares/errorHandling";
import methodOverride from "../../middlewares/methodOverride";
import validation from "../../middlewares/validation";
@@ -108,7 +108,7 @@ router.post("email", errorHandling(), async (ctx) => {
}
// send email to users registered address with a short-lived token
mailer.signin({
await mailer.sendTemplate("signin", {
to: user.email,
token: user.getEmailSigninToken(),
teamUrl: team.url,
@@ -138,7 +138,10 @@ router.get("email.callback", async (ctx) => {
return ctx.redirect("/?notice=suspended");
}
if (user.isInvited) {
sendEmail("welcome", user.email, { teamUrl: user.team.url });
await mailer.sendTemplate("welcome", {
to: user.email,
teamUrl: user.team.url,
});
}
await user.update({ lastActiveAt: new Date() });