fix: Incorrect role information in collection added email

This commit is contained in:
Tom Moor
2024-04-02 19:05:42 -04:00
parent 365f4c4b1f
commit 4311aac4ff
4 changed files with 15 additions and 2 deletions

View File

@@ -112,6 +112,7 @@ router.get(
if (user.isInvited) {
await new WelcomeEmail({
to: user.email,
role: user.role,
teamUrl: user.team.url,
}).schedule();

View File

@@ -153,6 +153,7 @@ async function accountProvisioner({
if (isNewUser) {
await new WelcomeEmail({
to: user.email,
role: user.role,
teamUrl: team.url,
}).schedule();
}

View File

@@ -75,7 +75,7 @@ View Document: ${teamUrl}${collection.path}
const permission =
membership.permission === CollectionPermission.ReadWrite
? "view and edit"
: CollectionPermission.Admin
: membership.permission === CollectionPermission.Admin
? "manage"
: "view";

View File

@@ -1,4 +1,5 @@
import * as React from "react";
import { UserRole } from "@shared/types";
import env from "@server/env";
import BaseEmail, { EmailProps } from "./BaseEmail";
import Body from "./components/Body";
@@ -10,18 +11,28 @@ import Header from "./components/Header";
import Heading from "./components/Heading";
type Props = EmailProps & {
role: UserRole;
teamUrl: string;
};
type BeforeSend = Record<string, never>;
/**
* Email sent to a user when their account has just been created, or they signed
* in for the first time from an invite.
*/
export default class WelcomeEmail extends BaseEmail<Props> {
export default class WelcomeEmail extends BaseEmail<Props, BeforeSend> {
protected subject() {
return `Welcome to ${env.APP_NAME}`;
}
protected async beforeSend(props: Props) {
if (props.role === UserRole.Guest) {
return false;
}
return {};
}
protected preview() {
return `${env.APP_NAME} is a place for your team to build and share knowledge.`;
}