Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
justinh-rahb committed Jul 26, 2023
1 parent 9bbcb6d commit c66e7a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions email_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def parse_email_content(service, email, user_email_address):
log_email_data = {k: v for k, v in email_data.items() if k != 'Body'}

# Skip emails that are not directly addressed to the user
if user_email_address not in email_data['To']:
if user_email_address not in (email_data['To'] or ''):
logging.info(f"Skipping email not directly addressed to the user. Email data: {log_email_data}")
return None

Expand All @@ -68,8 +68,8 @@ def parse_email_content(service, email, user_email_address):
return None

# Skip emails from or reply-to a noreply or donotreply address
if any((substring in email_data['From'] for substring in ['noreply@', 'no-reply@', 'donotreply@', 'do-not-reply@'])) or \
any((substring in email_data['Reply-to'] for substring in ['noreply@', 'no-reply@', 'donotreply@', 'do-not-reply@'])):
if any((substring in (email_data.get('From') or '') for substring in ['noreply@', 'no-reply@', 'donotreply@', 'do-not-reply@'])) or \
any((substring in (email_data.get('Reply-to') or '') for substring in ['noreply@', 'no-reply@', 'donotreply@', 'do-not-reply@'])):
logging.info(f"Skipping email from or reply-to a noreply or donotreply address. Email data: {log_email_data}")
return None

Expand Down
2 changes: 1 addition & 1 deletion oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_gmail_service(config):
pickle.dump(creds, token)

try:
service = build('gmail', 'v1', credentials=creds)
service = build('gmail', 'v1', credentials=creds, cache_discovery=False)
except Exception as e:
logging.error(f'An error occurred: {e}')
return None
Expand Down

0 comments on commit c66e7a2

Please sign in to comment.