2024-05-02 16:43:18 +02:00
|
|
|
export const INotificationRepository = 'INotificationRepository';
|
|
|
|
|
|
2024-05-28 09:16:46 +07:00
|
|
|
export type EmailImageAttachment = {
|
|
|
|
|
filename: string;
|
|
|
|
|
path: string;
|
|
|
|
|
cid: string;
|
|
|
|
|
};
|
|
|
|
|
|
2024-05-02 16:43:18 +02:00
|
|
|
export type SendEmailOptions = {
|
|
|
|
|
from: string;
|
|
|
|
|
to: string;
|
|
|
|
|
replyTo?: string;
|
|
|
|
|
subject: string;
|
|
|
|
|
html: string;
|
|
|
|
|
text: string;
|
2024-05-28 09:16:46 +07:00
|
|
|
imageAttachments?: EmailImageAttachment[];
|
2024-05-02 16:43:18 +02:00
|
|
|
smtp: SmtpOptions;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type SmtpOptions = {
|
|
|
|
|
host: string;
|
|
|
|
|
port?: number;
|
|
|
|
|
username?: string;
|
|
|
|
|
password?: string;
|
|
|
|
|
ignoreCert?: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export enum EmailTemplate {
|
2024-05-28 09:16:46 +07:00
|
|
|
// AUTH
|
2024-05-02 16:43:18 +02:00
|
|
|
WELCOME = 'welcome',
|
|
|
|
|
RESET_PASSWORD = 'reset-password',
|
2024-05-28 09:16:46 +07:00
|
|
|
|
|
|
|
|
// ALBUM
|
|
|
|
|
ALBUM_INVITE = 'album-invite',
|
|
|
|
|
ALBUM_UPDATE = 'album-update',
|
2024-05-02 16:43:18 +02:00
|
|
|
}
|
|
|
|
|
|
2024-05-28 09:16:46 +07:00
|
|
|
interface BaseEmailProps {
|
2024-05-02 16:43:18 +02:00
|
|
|
baseUrl: string;
|
2024-05-28 09:16:46 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface WelcomeEmailProps extends BaseEmailProps {
|
2024-05-02 16:43:18 +02:00
|
|
|
displayName: string;
|
|
|
|
|
username: string;
|
|
|
|
|
password?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-28 09:16:46 +07:00
|
|
|
export interface AlbumInviteEmailProps extends BaseEmailProps {
|
|
|
|
|
albumName: string;
|
|
|
|
|
albumId: string;
|
|
|
|
|
senderName: string;
|
|
|
|
|
recipientName: string;
|
|
|
|
|
cid?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface AlbumUpdateEmailProps extends BaseEmailProps {
|
|
|
|
|
albumName: string;
|
|
|
|
|
albumId: string;
|
|
|
|
|
recipientName: string;
|
|
|
|
|
cid?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type EmailRenderRequest =
|
|
|
|
|
| {
|
|
|
|
|
template: EmailTemplate.WELCOME;
|
|
|
|
|
data: WelcomeEmailProps;
|
|
|
|
|
}
|
|
|
|
|
| {
|
|
|
|
|
template: EmailTemplate.ALBUM_INVITE;
|
|
|
|
|
data: AlbumInviteEmailProps;
|
|
|
|
|
}
|
|
|
|
|
| {
|
|
|
|
|
template: EmailTemplate.ALBUM_UPDATE;
|
|
|
|
|
data: AlbumUpdateEmailProps;
|
|
|
|
|
};
|
2024-05-02 16:43:18 +02:00
|
|
|
|
|
|
|
|
export type SendEmailResponse = {
|
|
|
|
|
messageId: string;
|
|
|
|
|
response: any;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export interface INotificationRepository {
|
|
|
|
|
renderEmail(request: EmailRenderRequest): { html: string; text: string };
|
|
|
|
|
sendEmail(options: SendEmailOptions): Promise<SendEmailResponse>;
|
|
|
|
|
verifySmtp(options: SmtpOptions): Promise<true>;
|
|
|
|
|
}
|