courrier refactor rebuild 2
This commit is contained in:
parent
a51a4c303d
commit
19cff1ce7c
@ -9,8 +9,29 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import DOMPurify from 'isomorphic-dompurify';
|
import DOMPurify from 'isomorphic-dompurify';
|
||||||
import sanitizeHtml from 'sanitize-html';
|
// Instead of importing, implement the formatDateRelative function directly
|
||||||
import { formatDateRelative } from './date-formatter';
|
// import { formatDateRelative } from './date-formatter';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format a date in a relative format
|
||||||
|
* Simple implementation for email display
|
||||||
|
*/
|
||||||
|
function formatDateRelative(date: Date): string {
|
||||||
|
if (!date) return '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
return date.toLocaleString('en-US', {
|
||||||
|
weekday: 'short',
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'short',
|
||||||
|
day: 'numeric',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit'
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
return date.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Reset any existing hooks to start clean
|
// Reset any existing hooks to start clean
|
||||||
DOMPurify.removeAllHooks();
|
DOMPurify.removeAllHooks();
|
||||||
@ -368,18 +389,13 @@ export function encodeComposeContent(content: string): string {
|
|||||||
.join('\n') + '\n\n' + content;
|
.join('\n') + '\n\n' + content;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Email formatter functions for various email actions
|
// Legacy email formatter functions - renamed to avoid conflicts
|
||||||
export function formatReplyEmail(email: any): string {
|
export function formatReplyEmailLegacy(email: any): string {
|
||||||
const originalSender = email.sender?.name || email.sender?.email || 'Unknown Sender';
|
const originalSender = email.sender?.name || email.sender?.email || 'Unknown Sender';
|
||||||
const originalDate = formatDateRelative(new Date(email.date));
|
const originalDate = formatDateRelative(new Date(email.date));
|
||||||
|
|
||||||
const sanitizedBody = sanitizeHtml(email.content || '', {
|
// Use our own sanitizeHtml function consistently
|
||||||
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']),
|
const sanitizedBody = sanitizeHtml(email.content || '');
|
||||||
allowedAttributes: {
|
|
||||||
...sanitizeHtml.defaults.allowedAttributes,
|
|
||||||
img: ['src', 'alt', 'width', 'height']
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<p></p>
|
<p></p>
|
||||||
@ -390,7 +406,7 @@ export function formatReplyEmail(email: any): string {
|
|||||||
`.trim();
|
`.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatForwardedEmail(email: any): string {
|
export function formatForwardedEmailLegacy(email: any): string {
|
||||||
const originalSender = email.sender?.name || email.sender?.email || 'Unknown Sender';
|
const originalSender = email.sender?.name || email.sender?.email || 'Unknown Sender';
|
||||||
const originalRecipients = email.to?.map((recipient: any) =>
|
const originalRecipients = email.to?.map((recipient: any) =>
|
||||||
recipient.name || recipient.email
|
recipient.name || recipient.email
|
||||||
@ -398,13 +414,8 @@ export function formatForwardedEmail(email: any): string {
|
|||||||
const originalDate = formatDateRelative(new Date(email.date));
|
const originalDate = formatDateRelative(new Date(email.date));
|
||||||
const originalSubject = email.subject || 'No Subject';
|
const originalSubject = email.subject || 'No Subject';
|
||||||
|
|
||||||
const sanitizedBody = sanitizeHtml(email.content || '', {
|
// Use our own sanitizeHtml function consistently
|
||||||
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']),
|
const sanitizedBody = sanitizeHtml(email.content || '');
|
||||||
allowedAttributes: {
|
|
||||||
...sanitizeHtml.defaults.allowedAttributes,
|
|
||||||
img: ['src', 'alt', 'width', 'height']
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<p></p>
|
<p></p>
|
||||||
@ -422,7 +433,7 @@ export function formatForwardedEmail(email: any): string {
|
|||||||
|
|
||||||
export function formatReplyToAllEmail(email: any): string {
|
export function formatReplyToAllEmail(email: any): string {
|
||||||
// For reply all, we use the same format as regular reply
|
// For reply all, we use the same format as regular reply
|
||||||
return formatReplyEmail(email);
|
return formatReplyEmailLegacy(email);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utility function to get the reply subject line
|
// Utility function to get the reply subject line
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user