Skip to content

Commit

Permalink
chore: extract and export type used by CR emails (#6234)
Browse files Browse the repository at this point in the history
This change takes the (now rather involved) type used to send CR
schedule suspension emails and extracts it into a proper exported type.

This will allow us to import it in enterprise as well instead of
redefining it.
  • Loading branch information
thomasheartman committed Feb 14, 2024
1 parent fd977c5 commit 7eb9a01
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions src/lib/services/email-service.ts
Expand Up @@ -38,6 +38,28 @@ const SCHEDULED_EXECUTION_FAILED_SUBJECT =

export const MAIL_ACCEPTED = '250 Accepted';

export type ChangeRequestScheduleConflictData =
| { reason: 'flag archived'; flagName: string }
| {
reason: 'strategy deleted';
flagName: string;
strategyId: string;
}
| {
reason: 'strategy updated';
flagName: string;
strategyId: string;
}
| {
reason: 'segment updated';
segment: { id: number; name: string };
}
| {
reason: 'environment variants updated';
flagName: string;
environment: string;
};

export class EmailService {
private logger: Logger;
private config: IUnleashConfig;
Expand Down Expand Up @@ -177,27 +199,8 @@ export class EmailService {

async sendScheduledChangeSuspendedEmail(
recipient: string,
conflictData:
| { reason: 'flag archived'; flagName: string }
| {
reason: 'strategy deleted';
flagName: string;
strategyId: string;
}
| {
reason: 'strategy updated';
flagName: string;
strategyId: string;
}
| {
reason: 'segment updated';
segment: { id: number; name: string };
}
| {
reason: 'environment variants updated';
flagName: string;
environment: string;
},
conflictData: ChangeRequestScheduleConflictData,

conflictingChangeRequestId: number | undefined,
changeRequests: {
id: number;
Expand Down

0 comments on commit 7eb9a01

Please sign in to comment.