panel 2 courier api restore
This commit is contained in:
parent
e125d8f71a
commit
eb22039eb1
@ -112,25 +112,62 @@ export default function ComposeEmail({
|
|||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|
||||||
// Check if we have content
|
// Check if email object exists
|
||||||
if (!emailToProcess?.content) {
|
if (!emailToProcess) {
|
||||||
console.error('[DEBUG] No email content found to process');
|
console.error('[DEBUG] No email to process for reply/forward');
|
||||||
composeBodyRef.current.innerHTML = `
|
composeBodyRef.current.innerHTML = `
|
||||||
<div class="compose-area" contenteditable="true">
|
<div class="compose-area" contenteditable="true">
|
||||||
<br/>
|
<br/>
|
||||||
<div style="color: #ef4444;">Unable to load original message content.</div>
|
<div style="color: #ef4444;">No email selected for reply/forward.</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
return;
|
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';
|
const type = replyTo ? 'reply' : 'forward';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Parse the email to get headers and content - using the same function as panel 3
|
// Parse the email to get headers and content - using the same function as panel 3
|
||||||
const decoded = await decodeEmail(emailToProcess.content);
|
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
|
// This is exactly how panel 3 handles email content - simple sanitization of HTML or showing text
|
||||||
let cleanContent = '';
|
let cleanContent = '';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user