import os import logging from core_utilities.mail_service import send_mail logger = logging.getLogger(__name__) class EmailNotifier: def __init__(self): self.sender = os.getenv("MAIL_USERNAME") def notify_review(self, recipient_email: str, review_summary: str, pr_title: str): """ Send the AI review summary via email. """ if not recipient_email: logger.warning("No recipient email provided for notification.") return False subject = f"AI Code Review: {pr_title}" # The mail_service uses a template that formats {message} # We can pass our markdown/text as the message. # Note: If the template expects HTML, we might need to convert markdown to HTML. # For now, we'll send it as is. # Add tech@creditfair.in as a CC recipient recipients = list(set([recipient_email, "sunil@creditfair.in", "abhishek.shetty@creditfair.in", "suyog@creditfair.in", "rudraksha.vaity@creditfair.in", "vedant.jadhav@creditfair.in", "ashish.gupta@creditfair.in"])) success = send_mail(customer_mail=recipients, msg=review_summary, subject=subject) if success: logger.info(f"Review email sent to {recipient_email}") else: logger.error(f"Failed to send review email to {recipient_email}") return success