Use NOREPLY_EMAIL_ADDRESS if email gateway not enabled.

This fixes a regression where missed message emails would not be sent
at all in the event that EMAIL_GATEWAY_PATTERN was unset.

The overall experience still isn't great, but it's better than crashing.

Fixes: #1411

[commit message expanded by tabbott]
This commit is contained in:
Umair Khan
2016-07-31 19:49:31 +05:00
committed by Tim Abbott
parent 25c0710800
commit 2c07f1b19a

View File

@@ -88,6 +88,11 @@ def get_missed_message_token_from_address(address):
def create_missed_message_address(user_profile, message):
# type: (UserProfile, Message) -> text_type
if settings.EMAIL_GATEWAY_PATTERN == '':
logging.warning("EMAIL_GATEWAY_PATTERN is an empty string, using "
"NOREPLY_EMAIL_ADDRESS in the 'from' field.")
return settings.NOREPLY_EMAIL_ADDRESS
if message.recipient.type == Recipient.PERSONAL:
# We need to reply to the sender so look up their personal recipient_id
recipient_id = get_recipient(Recipient.PERSONAL, message.sender_id).id