panel 2 courier api restore
This commit is contained in:
parent
83cf04683c
commit
78c8823a01
@ -182,18 +182,56 @@ export default function ComposeEmail({
|
||||
cleanContent = '<div>No displayable content available</div>';
|
||||
}
|
||||
|
||||
// Helper function to safely extract email information
|
||||
const getSafeEmailInfo = (email: any) => {
|
||||
const fromValue = email && email.from ?
|
||||
(typeof email.from === 'object' && email.from.text) ? email.from.text :
|
||||
(Array.isArray(email.from) && email.from[0]) ?
|
||||
(email.from[0].name || email.from[0].address) : 'Unknown Sender'
|
||||
: 'Unknown Sender';
|
||||
|
||||
const dateValue = email && email.date ?
|
||||
new Date(email.date).toLocaleString() : new Date().toLocaleString();
|
||||
|
||||
const subjectValue = email && email.subject ? email.subject : 'No Subject';
|
||||
|
||||
const toValue = email && email.to ?
|
||||
(typeof email.to === 'object' && email.to.text) ? email.to.text :
|
||||
(Array.isArray(email.to)) ? email.to.map((t: any) => t.address || t.name || '').filter(Boolean).join(', ') : ''
|
||||
: '';
|
||||
|
||||
const ccValue = email && email.cc ?
|
||||
(typeof email.cc === 'object' && email.cc.text) ? email.cc.text :
|
||||
(Array.isArray(email.cc) && email.cc.length > 0) ?
|
||||
email.cc.map((c: any) => c.address || c.name || '').filter(Boolean).join(', ') : ''
|
||||
: '';
|
||||
|
||||
return { from: fromValue, date: dateValue, subject: subjectValue, to: toValue, cc: ccValue };
|
||||
};
|
||||
|
||||
// Get info from both sources and combine
|
||||
const decodedInfo = getSafeEmailInfo(decoded);
|
||||
const emailInfo = getSafeEmailInfo(emailToProcess);
|
||||
|
||||
// Use the most complete information available
|
||||
const from = decodedInfo.from !== 'Unknown Sender' ? decodedInfo.from : emailInfo.from;
|
||||
const date = decodedInfo.date;
|
||||
const subject = decodedInfo.subject !== 'No Subject' ? decodedInfo.subject : emailInfo.subject;
|
||||
const to = decodedInfo.to || emailInfo.to;
|
||||
const cc = decodedInfo.cc || emailInfo.cc;
|
||||
|
||||
// Format the content based on reply type
|
||||
const quotedContent = type === 'forward' ? `
|
||||
<div class="forwarded-message" style="border-top: 1px solid #e5e7eb; padding-top: 20px; margin-top: 20px; color: #6b7280; font-size: 0.875rem;">
|
||||
---------- Forwarded message ---------<br/>
|
||||
From: ${decoded.from || 'Unknown Sender'}<br/>
|
||||
Date: ${decoded.date ? decoded.date.toLocaleString() : new Date().toLocaleString()}<br/>
|
||||
Subject: ${decoded.subject || 'No Subject'}<br/>
|
||||
To: ${decoded.to || ''}<br/>
|
||||
${decoded.cc ? `Cc: ${decoded.cc}<br/>` : ''}
|
||||
From: ${from}<br/>
|
||||
Date: ${date}<br/>
|
||||
Subject: ${subject}<br/>
|
||||
To: ${to}<br/>
|
||||
${cc ? `Cc: ${cc}<br/>` : ''}
|
||||
</div>
|
||||
<div class="message-content prose prose-sm max-w-none" style="margin-top: 10px; border: 1px solid #e5e7eb; padding: 10px; border-radius: 4px; max-height: 300px; overflow-y: auto; color: #374151;">
|
||||
${cleanContent}
|
||||
${cleanContent || '<div>No content available</div>'}
|
||||
</div>
|
||||
` : `
|
||||
<div class="quoted-message" style="border-top: 1px solid #e5e7eb; padding-top: 20px; margin-top: 20px; color: #6b7280; font-size: 0.875rem;">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user