From 1a0eefdaa5ce3f85e8ee8774bf531590bdcfa82e Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Wed, 22 May 2013 17:52:17 -0400 Subject: [PATCH] Send missed message email on @-notifications (imported from commit 4c29662ae45fd5e5932b5a6029b90afc7efbbd09) --- templates/zephyr/missed_message_email.txt | 4 +-- .../zephyr/missed_message_email_html.txt | 4 +-- templates/zephyr/settings.html | 2 +- zephyr/lib/actions.py | 27 ++++++++++++------- zephyr/tornado_callbacks.py | 13 ++++----- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/templates/zephyr/missed_message_email.txt b/templates/zephyr/missed_message_email.txt index 5e192dadb4..bd1c881193 100644 --- a/templates/zephyr/missed_message_email.txt +++ b/templates/zephyr/missed_message_email.txt @@ -1,10 +1,10 @@ {% comment %} -Mail sent to user when she was not logged in and received a PM +Mail sent to user when she was not logged in and received a PM or @-mention {% endcomment %} Hello {{ name }}, -While you were away you received {{ messages|length }} new message{{ messages|pluralize }}! +While you were away you received {{ messages|length }} new message{{ messages|pluralize }}{% if mention %} in which you were mentioned{% endif %}! {% for message in messages %} {{ message.sender }} diff --git a/templates/zephyr/missed_message_email_html.txt b/templates/zephyr/missed_message_email_html.txt index d51adbbd5d..fd5cfa4159 100644 --- a/templates/zephyr/missed_message_email_html.txt +++ b/templates/zephyr/missed_message_email_html.txt @@ -1,11 +1,11 @@ {% comment %} -Mail sent to user when she was not logged in and received a PM +Mail sent to user when she was not logged in and received a PM or @-mention {% endcomment %} Hello {{ name }},

-While you were away you received {{ messages|length }} new message{{ messages|pluralize }}! +While you were away you received {{ messages|length }} new message{{ messages|pluralize }}{% if mention %} in which you were mentioned{%endif %}!

diff --git a/templates/zephyr/settings.html b/templates/zephyr/settings.html index f79a4cd7c6..83e509dfe4 100644 --- a/templates/zephyr/settings.html +++ b/templates/zephyr/settings.html @@ -134,7 +134,7 @@
+ Notify on PMs and @-mentions when offline
1 else '', sender_str) diff --git a/zephyr/tornado_callbacks.py b/zephyr/tornado_callbacks.py index 21cbc5db82..cc3ac56817 100644 --- a/zephyr/tornado_callbacks.py +++ b/zephyr/tornado_callbacks.py @@ -286,12 +286,13 @@ def process_new_message(data): event = dict(type='message', message=message_dict, flags=flags) client.add_event(event) - # If the recipient was offline and the message was a single or group PM, - # potentially notify more immediately - if message.recipient.type in (Recipient.PERSONAL, Recipient.HUDDLE) and \ - user_profile_id != message.sender.id and \ - len(get_client_descriptors_for_user(user_profile_id)) == 0: - + # If the recipient was offline and the message was a single or group PM to him + # or she was @-notified potentially notify more immediately + received_pm = message.recipient.type in (Recipient.PERSONAL, Recipient.HUDDLE) and \ + user_profile_id != message.sender.id + mentioned = 'mentioned' in flags + idle = len(get_client_descriptors_for_user(user_profile_id)) == 0 + if (received_pm or mentioned) and idle: user_profile = get_user_profile_by_id(user_profile_id) if user_profile.enable_offline_email_notifications and \