Remove hardcoded Zoho credentials - now users input credentials through frontend
This commit is contained in:
@@ -25,6 +25,8 @@ def load_config():
|
||||
# Default configuration
|
||||
default_config = {
|
||||
'email_address': 'projects@manaknightdigital.com',
|
||||
'zoho_email': '', # Will be set by user through frontend
|
||||
'zoho_app_password': '', # Will be set by user through frontend
|
||||
'time_frames': [
|
||||
{'name': '1-24 hours', 'hours': 24, 'alert_level': 1},
|
||||
{'name': '24-48 hours', 'hours': 48, 'alert_level': 2},
|
||||
@@ -93,6 +95,10 @@ def update_settings():
|
||||
# Update email address
|
||||
config['email_address'] = request.form.get('email_address', config['email_address'])
|
||||
|
||||
# Update Zoho credentials
|
||||
config['zoho_email'] = request.form.get('zoho_email', config.get('zoho_email', ''))
|
||||
config['zoho_app_password'] = request.form.get('zoho_app_password', config.get('zoho_app_password', ''))
|
||||
|
||||
# Update email days back
|
||||
config['email_days_back'] = int(request.form.get('email_days_back', 7))
|
||||
|
||||
|
||||
+16
-4
@@ -12,13 +12,25 @@ from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
class EmailProcessor:
|
||||
def __init__(self, agency_domains: List[str] = None):
|
||||
self.zoho_client = ZohoClient()
|
||||
self.triage = EmailTriage()
|
||||
def __init__(self, agency_domains=None):
|
||||
"""Initialize the email processor"""
|
||||
self.agency_domains = agency_domains or ['projects@manaknightdigital.com']
|
||||
|
||||
# Load config to get Zoho credentials
|
||||
from app import load_config
|
||||
config = load_config()
|
||||
|
||||
# Initialize Zoho client with credentials from config
|
||||
self.zoho_client = ZohoClient(
|
||||
email=config.get('zoho_email'),
|
||||
app_password=config.get('zoho_app_password')
|
||||
)
|
||||
|
||||
# Initialize thread tracker
|
||||
self.tracker = ThreadTracker()
|
||||
self.triage = EmailTriage()
|
||||
self.ai_analyzer = AIAnalyzer()
|
||||
self.whatsapp_sender = WhatsAppSender()
|
||||
self.agency_domains = agency_domains or ['projects@manaknightdigital.com']
|
||||
|
||||
def process_emails(self, max_results: int = 100, send_alerts: bool = True, days_back: int = 7, time_frames: List[Dict] = None) -> Dict[str, Any]:
|
||||
"""Main processing pipeline with optional WhatsApp alerts"""
|
||||
|
||||
@@ -30,6 +30,20 @@
|
||||
<div class="form-text">The email address that will be checked for new messages.</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="zoho_email" class="form-label">Zoho Email Address</label>
|
||||
<input type="email" class="form-control" id="zoho_email" name="zoho_email"
|
||||
value="{{ config.zoho_email }}" required>
|
||||
<div class="form-text">Your Zoho email address for IMAP access.</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="zoho_app_password" class="form-label">Zoho App Password</label>
|
||||
<input type="password" class="form-control" id="zoho_app_password" name="zoho_app_password"
|
||||
value="{{ config.zoho_app_password }}" required>
|
||||
<div class="form-text">App password for Zoho IMAP access (not your regular password).</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="email_days_back" class="form-label">Email Range (Days)</label>
|
||||
<input type="number" class="form-control" id="email_days_back" name="email_days_back"
|
||||
|
||||
+8
-4
@@ -9,12 +9,16 @@ from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
class ZohoClient:
|
||||
def __init__(self):
|
||||
def __init__(self, email=None, app_password=None):
|
||||
self.imap_server = "imap.zoho.com"
|
||||
self.imap_port = 993
|
||||
self.email = os.getenv("ZOHO_EMAIL", "projects@manaknightdigital.com")
|
||||
# Use app password instead of regular password
|
||||
self.app_password = os.getenv("ZOHO_APP_PASSWORD", "s7t8t9j6ebjm")
|
||||
# Use provided credentials or fall back to environment variables
|
||||
self.email = email or os.getenv("ZOHO_EMAIL", "")
|
||||
self.app_password = app_password or os.getenv("ZOHO_APP_PASSWORD", "")
|
||||
|
||||
if not self.email or not self.app_password:
|
||||
raise ValueError("Zoho email and app password must be provided")
|
||||
|
||||
self.connection = None
|
||||
self._connect()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user