Move emails to dedicated package (#3542)
* Add new package * Add twenty-emails package * Use generated files from twenty-emails in twenty-server * Fix deleted file * Import emails templates properly
This commit is contained in:
@ -3,6 +3,10 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { render } from '@react-email/render';
|
||||
import { Repository } from 'typeorm';
|
||||
import {
|
||||
CleanInactiveWorkspaceEmail,
|
||||
DeleteInactiveWorkspaceEmail,
|
||||
} from 'twenty-emails';
|
||||
|
||||
import { MessageQueueJob } from 'src/integrations/message-queue/interfaces/message-queue-job.interface';
|
||||
|
||||
@ -12,14 +16,12 @@ import { TypeORMService } from 'src/database/typeorm/typeorm.service';
|
||||
import { DataSourceEntity } from 'src/metadata/data-source/data-source.entity';
|
||||
import { UserService } from 'src/core/user/services/user.service';
|
||||
import { EmailService } from 'src/integrations/email/email.service';
|
||||
import CleanInactiveWorkspaceEmail from 'src/workspace/cron/clean-inactive-workspaces/clean-inactive-workspaces.email';
|
||||
import { EnvironmentService } from 'src/integrations/environment/environment.service';
|
||||
import {
|
||||
FeatureFlagEntity,
|
||||
FeatureFlagKeys,
|
||||
} from 'src/core/feature-flag/feature-flag.entity';
|
||||
import { ObjectMetadataEntity } from 'src/metadata/object-metadata/object-metadata.entity';
|
||||
import DeleteInactiveWorkspaceEmail from 'src/workspace/cron/clean-inactive-workspaces/delete-inactive-workspaces.email';
|
||||
import { computeObjectTargetTable } from 'src/workspace/utils/compute-object-target-table.util';
|
||||
|
||||
const MILLISECONDS_IN_ONE_DAY = 1000 * 3600 * 24;
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import { HighlightedText } from 'src/emails/components/HighlightedText';
|
||||
import { MainText } from 'src/emails/components/MainText';
|
||||
import { Title } from 'src/emails/components/Title';
|
||||
import { BaseEmail } from 'src/emails/components/BaseEmail';
|
||||
import { CallToAction } from 'src/emails/components/CallToAction';
|
||||
|
||||
type CleanInactiveWorkspaceEmailData = {
|
||||
daysLeft: number;
|
||||
userName: string;
|
||||
workspaceDisplayName: string;
|
||||
};
|
||||
|
||||
export const CleanInactiveWorkspaceEmail = ({
|
||||
daysLeft,
|
||||
userName,
|
||||
workspaceDisplayName,
|
||||
}: CleanInactiveWorkspaceEmailData) => {
|
||||
const dayOrDays = daysLeft > 1 ? 'days' : 'day';
|
||||
const remainingDays = daysLeft > 1 ? `${daysLeft} ` : '';
|
||||
|
||||
const helloString = userName?.length > 1 ? `Hello ${userName}` : 'Hello';
|
||||
|
||||
return (
|
||||
<BaseEmail>
|
||||
<Title value="Inactive Workspace 😴" />
|
||||
<HighlightedText value={`${daysLeft} ${dayOrDays} left`} />
|
||||
<MainText>
|
||||
{helloString},
|
||||
<br />
|
||||
<br />
|
||||
It appears that there has been a period of inactivity on your{' '}
|
||||
<b>{workspaceDisplayName}</b> workspace.
|
||||
<br />
|
||||
<br />
|
||||
Please note that the account is due for deactivation soon, and all
|
||||
associated data within this workspace will be deleted.
|
||||
<br />
|
||||
<br />
|
||||
No need for concern, though! Simply create or edit a record within the
|
||||
next {remainingDays}
|
||||
{dayOrDays} to retain access.
|
||||
</MainText>
|
||||
<CallToAction href="https://app.twenty.com" value="Connect to Twenty" />
|
||||
</BaseEmail>
|
||||
);
|
||||
};
|
||||
|
||||
export default CleanInactiveWorkspaceEmail;
|
||||
@ -1,30 +0,0 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import { HighlightedText } from 'src/emails/components/HighlightedText';
|
||||
import { MainText } from 'src/emails/components/MainText';
|
||||
import { Title } from 'src/emails/components/Title';
|
||||
import { BaseEmail } from 'src/emails/components/BaseEmail';
|
||||
import { CallToAction } from 'src/emails/components/CallToAction';
|
||||
|
||||
type DeleteInactiveWorkspaceEmailData = {
|
||||
daysSinceDead: number;
|
||||
workspaceId: string;
|
||||
};
|
||||
|
||||
export const DeleteInactiveWorkspaceEmail = ({
|
||||
daysSinceDead,
|
||||
workspaceId,
|
||||
}: DeleteInactiveWorkspaceEmailData) => {
|
||||
return (
|
||||
<BaseEmail>
|
||||
<Title value="Dead Workspace 😵" />
|
||||
<HighlightedText value={`Inactive since ${daysSinceDead} day(s)`} />
|
||||
<MainText>
|
||||
Workspace <b>{workspaceId}</b> should be deleted.
|
||||
</MainText>
|
||||
<CallToAction href="https://app.twenty.com" value="Connect to Twenty" />
|
||||
</BaseEmail>
|
||||
);
|
||||
};
|
||||
|
||||
export default DeleteInactiveWorkspaceEmail;
|
||||
Reference in New Issue
Block a user