209 lines
6.5 KiB
TypeScript
209 lines
6.5 KiB
TypeScript
interface SendEmailOptions {
|
|
to: string;
|
|
subject: string;
|
|
replyTo?: string;
|
|
html: string;
|
|
text: string;
|
|
}
|
|
interface SendEmailResult {
|
|
success: boolean;
|
|
messageId?: string;
|
|
testMode: boolean;
|
|
}
|
|
interface SendCampaignEmailOptions {
|
|
recipientEmail: string;
|
|
recipientName?: string;
|
|
recipientLevel?: string;
|
|
userEmail: string;
|
|
userName: string;
|
|
postalCode: string;
|
|
subject: string;
|
|
message: string;
|
|
campaignTitle: string;
|
|
}
|
|
declare class EmailService {
|
|
private transporter;
|
|
constructor();
|
|
private createTransporter;
|
|
/** Rebuild transporter from DB settings (with env fallback). Call after SMTP settings change. */
|
|
rebuildTransporter(): Promise<void>;
|
|
testConnection(): Promise<boolean>;
|
|
/**
|
|
* Load template from database (with caching)
|
|
*/
|
|
private loadTemplateFromDatabase;
|
|
/**
|
|
* Load template - checks database first, falls back to filesystem
|
|
* @param name Template key (e.g., "campaign-email")
|
|
* @param type File type (html or txt) - only used for filesystem fallback
|
|
*/
|
|
loadTemplate(name: string, type: 'html' | 'txt'): string;
|
|
/**
|
|
* Clear database template cache
|
|
* @param key Optional specific template key to clear. If not provided, clears all.
|
|
*/
|
|
clearDatabaseCache(key?: string): void;
|
|
escapeHtml(unsafe: string): string;
|
|
/**
|
|
* Fetch video metadata from Media API
|
|
*/
|
|
private getVideoMetadata;
|
|
private formatDuration;
|
|
private formatViewCount;
|
|
processTemplate(template: string, vars: Record<string, string>, variableDefinitions?: Array<{
|
|
key: string;
|
|
type: string;
|
|
videoId?: number;
|
|
}>): Promise<string>;
|
|
/**
|
|
* Process text template (for plain text emails)
|
|
*/
|
|
processTextTemplate(template: string, vars: Record<string, string>, variableDefinitions?: Array<{
|
|
key: string;
|
|
type: string;
|
|
videoId?: number;
|
|
}>): Promise<string>;
|
|
/**
|
|
* Process subject line template
|
|
* Same as processTemplate but without HTML escaping
|
|
*/
|
|
processSubject(subject: string, vars: Record<string, string>): string;
|
|
private getFromField;
|
|
private getOrganizationName;
|
|
private getEmailTestConfig;
|
|
sendEmail(options: SendEmailOptions): Promise<SendEmailResult>;
|
|
sendCampaignEmail(options: SendCampaignEmailOptions): Promise<SendEmailResult>;
|
|
/** Check whether production SMTP is configured (not mailhog test mode) */
|
|
isSmtpConfigured(): Promise<boolean>;
|
|
sendVerificationEmail(options: {
|
|
recipientEmail: string;
|
|
recipientName: string;
|
|
verificationUrl: string;
|
|
}): Promise<SendEmailResult>;
|
|
sendPasswordResetEmail(options: {
|
|
recipientEmail: string;
|
|
recipientName: string;
|
|
resetUrl: string;
|
|
}): Promise<SendEmailResult>;
|
|
sendAccountApprovedEmail(options: {
|
|
recipientEmail: string;
|
|
recipientName: string;
|
|
loginUrl: string;
|
|
}): Promise<SendEmailResult>;
|
|
sendPendingApprovalNotification(options: {
|
|
adminEmails: string[];
|
|
newUserEmail: string;
|
|
newUserName: string;
|
|
}): Promise<void>;
|
|
sendShiftSignupConfirmation(options: {
|
|
recipientEmail: string;
|
|
recipientName: string;
|
|
shiftTitle: string;
|
|
shiftDate: string;
|
|
shiftTime: string;
|
|
shiftLocation: string;
|
|
isNewUser: boolean;
|
|
tempPassword?: string;
|
|
loginUrl: string;
|
|
}): Promise<SendEmailResult>;
|
|
sendShiftDetailsEmail(options: {
|
|
recipientEmail: string;
|
|
recipientName: string;
|
|
shiftTitle: string;
|
|
shiftDate: string;
|
|
shiftStartTime: string;
|
|
shiftEndTime: string;
|
|
shiftLocation: string;
|
|
shiftDescription: string;
|
|
currentVolunteers: number;
|
|
maxVolunteers: number;
|
|
shiftStatus: string;
|
|
}): Promise<SendEmailResult>;
|
|
sendAdminShiftSignupAlert(options: {
|
|
adminEmails: string[];
|
|
shiftTitle: string;
|
|
shiftDate: string;
|
|
volunteerName: string;
|
|
volunteerEmail: string;
|
|
signupSource: string;
|
|
adminUrl: string;
|
|
}): Promise<void>;
|
|
sendAdminShiftCancellationAlert(options: {
|
|
adminEmails: string[];
|
|
shiftTitle: string;
|
|
shiftDate: string;
|
|
volunteerName: string;
|
|
volunteerEmail: string;
|
|
cancellationSource: string;
|
|
adminUrl: string;
|
|
}): Promise<void>;
|
|
sendAdminResponseSubmittedAlert(options: {
|
|
adminEmails: string[];
|
|
campaignTitle: string;
|
|
representativeName: string;
|
|
responseType: string;
|
|
submitterName: string;
|
|
adminUrl: string;
|
|
}): Promise<void>;
|
|
sendAdminSignRequestedAlert(options: {
|
|
adminEmails: string[];
|
|
volunteerName: string;
|
|
address: string;
|
|
shiftTitle: string;
|
|
signSize: string;
|
|
adminUrl: string;
|
|
}): Promise<void>;
|
|
sendVolunteerSessionSummary(options: {
|
|
volunteerEmail: string;
|
|
volunteerName: string;
|
|
cutName: string;
|
|
sessionDate: string;
|
|
visitCount: number;
|
|
durationMinutes: number;
|
|
distanceKm: number;
|
|
outcomeBreakdown: Record<string, number>;
|
|
}): Promise<void>;
|
|
sendVolunteerCancellationAck(options: {
|
|
volunteerEmail: string;
|
|
volunteerName: string;
|
|
shiftTitle: string;
|
|
shiftDate: string;
|
|
shiftTime: string;
|
|
signupUrl: string;
|
|
}): Promise<void>;
|
|
sendVolunteerShiftThankYou(options: {
|
|
volunteerEmail: string;
|
|
volunteerName: string;
|
|
shiftTitle: string;
|
|
shiftDate: string;
|
|
shiftTime: string;
|
|
shiftLocation: string;
|
|
signupUrl: string;
|
|
}): Promise<void>;
|
|
sendVolunteerReengagement(options: {
|
|
volunteerEmail: string;
|
|
volunteerName: string;
|
|
lastActivityDate: string;
|
|
lastActivityType: string;
|
|
signupUrl: string;
|
|
}): Promise<void>;
|
|
sendResponseVerification(options: {
|
|
recipientEmail: string;
|
|
campaignTitle: string;
|
|
responseType: string;
|
|
responseText: string;
|
|
submitterName: string;
|
|
verificationUrl: string;
|
|
reportUrl: string;
|
|
}): Promise<SendEmailResult>;
|
|
sendProfileLinkEmail(options: {
|
|
recipientEmail: string;
|
|
recipientName: string;
|
|
profileUrl: string;
|
|
organizationName: string;
|
|
extraNotes?: string;
|
|
}): Promise<SendEmailResult>;
|
|
}
|
|
export declare const emailService: EmailService;
|
|
export {};
|
|
//# sourceMappingURL=email.service.d.ts.map
|