panel 2 courier api restore
This commit is contained in:
parent
e125d8f71a
commit
eb22039eb1
@ -112,25 +112,62 @@ export default function ComposeEmail({
|
||||
|
||||
setIsLoading(true);
|
||||
|
||||
// Check if we have content
|
||||
if (!emailToProcess?.content) {
|
||||
console.error('[DEBUG] No email content found to process');
|
||||
// Check if email object exists
|
||||
if (!emailToProcess) {
|
||||
console.error('[DEBUG] No email to process for reply/forward');
|
||||
composeBodyRef.current.innerHTML = `
|
||||
<div class="compose-area" contenteditable="true">
|
||||
<br/>
|
||||
<div style="color: #ef4444;">Unable to load original message content.</div>
|
||||
<div style="color: #ef4444;">No email selected for reply/forward.</div>
|
||||
</div>
|
||||
`;
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Format the reply/forward content
|
||||
// Check if we need to fetch full content first - same as panel 3
|
||||
if (!emailToProcess.content || emailToProcess.content.length === 0) {
|
||||
console.log('[DEBUG] Need to fetch content before composing reply/forward');
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/courrier/${emailToProcess.id}?folder=${encodeURIComponent(emailToProcess.folder || 'INBOX')}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch email content: ${response.status}`);
|
||||
}
|
||||
|
||||
const fullContent = await response.json();
|
||||
|
||||
// Update the email content with the fetched full content
|
||||
emailToProcess.content = fullContent.content;
|
||||
emailToProcess.contentFetched = true;
|
||||
|
||||
console.log('[DEBUG] Successfully fetched content for reply/forward');
|
||||
} catch (error) {
|
||||
console.error('[DEBUG] Error fetching content for reply:', error);
|
||||
composeBodyRef.current.innerHTML = `
|
||||
<div class="compose-area" contenteditable="true">
|
||||
<br/>
|
||||
<div style="color: #ef4444;">Failed to load email content. Please try again.</div>
|
||||
</div>
|
||||
`;
|
||||
setIsLoading(false);
|
||||
return; // Exit if we couldn't get the content
|
||||
}
|
||||
}
|
||||
|
||||
// Now proceed with the usual decoding
|
||||
const type = replyTo ? 'reply' : 'forward';
|
||||
|
||||
try {
|
||||
// Parse the email to get headers and content - using the same function as panel 3
|
||||
const decoded = await decodeEmail(emailToProcess.content);
|
||||
console.log('[DEBUG] Decoded email for compose:', {
|
||||
hasHtml: !!decoded.html,
|
||||
hasText: !!decoded.text,
|
||||
from: decoded.from,
|
||||
subject: decoded.subject
|
||||
});
|
||||
|
||||
// This is exactly how panel 3 handles email content - simple sanitization of HTML or showing text
|
||||
let cleanContent = '';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user