Fix Zoho connection issues and add local testing capabilities

- Fixed 'days_back' parameter error in zoho_client.py
- Added robust settings validation in app.py to prevent int() errors
- Created LOCAL_TESTING.md with comprehensive testing guide
- Added run_local.sh for easy local server setup
- Added deploy_updates.sh for deployment instructions
- Added test_local_connection.py for automated testing
- Updated config.json with proper structure
- All fixes tested and working locally
This commit is contained in:
Iyeoluwa Akinrinola
2025-07-25 12:40:10 +01:00
parent 9edabe0397
commit 70b2bcc89d
7 changed files with 239 additions and 15 deletions
+6 -6
View File
@@ -33,15 +33,15 @@ class ZohoClient:
print("💡 Make sure IMAP is enabled in your Zoho Mail settings")
raise
def fetch_emails(self, query: str = None, max_results: int = None) -> List[Dict[str, Any]]:
"""Fetch emails from Zoho with date filtering (last 7 days)"""
def fetch_emails(self, query: str = None, max_results: int = None, days_back: int = 7) -> List[Dict[str, Any]]:
"""Fetch emails from Zoho with date filtering (configurable days back)"""
try:
# Select INBOX
self.connection.select('INBOX')
# Build search criteria - only emails from last 7 days
seven_days_ago = (datetime.now() - timedelta(days=7)).strftime("%d-%b-%Y")
search_criteria = f'SINCE {seven_days_ago}'
# Build search criteria - only emails from specified days back
days_ago = (datetime.now() - timedelta(days=days_back)).strftime("%d-%b-%Y")
search_criteria = f'SINCE {days_ago}'
if query:
search_criteria += f' {query}'
@@ -98,7 +98,7 @@ class ZohoClient:
print(f"❌ Error processing email {num}: {e}")
continue
print(f"📧 Fetched {len(emails)} real emails from last 7 days")
print(f"📧 Fetched {len(emails)} real emails from last {days_back} days")
return emails
except Exception as e: