Fix email system error handling and remove hardcoded credentials

- Handle missing email sessions gracefully without throwing errors
- Clear partial session data when no valid session exists
- Return empty results instead of 401 errors for missing credentials
- Remove hardcoded Documenso API key and require env variables
- Reduce email fetch limit from 50 to 20 for performance
- Add documentation for email system fixes
This commit is contained in:
2025-06-09 22:50:06 +02:00
parent f7cc2973e1
commit 5f10e9fb54
5 changed files with 103 additions and 9 deletions

View File

@@ -76,6 +76,12 @@ const checkConnection = () => {
if (sessionId && email) {
isConnected.value = true;
connectedEmail.value = email;
} else {
// Clear any partial session data
sessionStorage.removeItem('emailSessionId');
sessionStorage.removeItem('connectedEmail');
isConnected.value = false;
connectedEmail.value = '';
}
};

View File

@@ -181,6 +181,15 @@ const truncateText = (text: string, maxLength: number = 200) => {
};
const loadEmails = async () => {
// Check if we have a session ID before trying to fetch emails
const sessionId = getSessionId();
if (!sessionId) {
// No credentials, don't try to fetch
threads.value = [];
loading.value = false;
return;
}
loading.value = true;
try {
@@ -196,18 +205,19 @@ const loadEmails = async () => {
body: {
clientEmail: props.interest['Email Address'],
interestId: props.interest.Id,
sessionId: getSessionId(),
limit: 50
sessionId: sessionId,
limit: 20
}
});
if (response.success) {
threads.value = response.threads;
threads.value = response.threads || [];
}
} catch (error: any) {
console.error('Failed to load emails:', error);
if (error.data?.statusMessage?.includes('Email credentials not found')) {
// Don't show error, parent component should handle reconnection
threads.value = [];
} else {
toast.error(error.data?.statusMessage || 'Failed to load email history');
}