mirror of https://github.com/zulip/zulip.git
Send missed message email on @-notifications
(imported from commit 4c29662ae45fd5e5932b5a6029b90afc7efbbd09)
This commit is contained in:
parent
10501c08cc
commit
1a0eefdaa5
|
@ -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 }}
|
||||
|
|
|
@ -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 }},
|
||||
|
||||
<p>
|
||||
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 %}!
|
||||
</p>
|
||||
|
||||
<div id='messages'>
|
||||
|
|
|
@ -134,7 +134,7 @@
|
|||
|
||||
<div class="control-group">
|
||||
<label for="enable_offline_email_notifications" class="control-label">
|
||||
Notify on receiving PMs when offline</label>
|
||||
Notify on PMs and @-mentions when offline</label>
|
||||
<div class="controls">
|
||||
<input type="checkbox" name="enable_offline_email_notifications" id="enable_offline_email_notifications"
|
||||
{% if user_profile.enable_offline_email_notifications %}
|
||||
|
|
|
@ -1172,17 +1172,24 @@ def do_send_missedmessage_email(user_profile, missed_messages):
|
|||
sender_str = ", ".join(senders)
|
||||
|
||||
headers = {}
|
||||
# If we have one huddle, set a reply-to to all of the members
|
||||
# of the huddle except the user herself
|
||||
disp_recipients = [", ".join(recipient['email']
|
||||
for recipient in get_display_recipient(msg.recipient)
|
||||
if recipient['email'] != user_profile.email)
|
||||
for msg in missed_messages]
|
||||
if all(msg.recipient.type == Recipient.HUDDLE for msg in missed_messages) and len(set(disp_recipients)) == 1:
|
||||
headers['Reply-To'] = disp_recipients[0]
|
||||
elif len(senders) == 1:
|
||||
headers['Reply-To'] = missed_messages[0].sender.email
|
||||
if all(msg.recipient.type in (Recipient.HUDDLE, Recipient.PERSONAL)
|
||||
for msg in missed_messages):
|
||||
# If we have one huddle, set a reply-to to all of the members
|
||||
# of the huddle except the user herself
|
||||
disp_recipients = [", ".join(recipient['email']
|
||||
for recipient in get_display_recipient(msg.recipient)
|
||||
if recipient['email'] != user_profile.email)
|
||||
for msg in missed_messages]
|
||||
if all(msg.recipient.type == Recipient.HUDDLE for msg in missed_messages) and \
|
||||
len(set(disp_recipients)) == 1:
|
||||
headers['Reply-To'] = disp_recipients[0]
|
||||
elif len(senders) == 1:
|
||||
headers['Reply-To'] = missed_messages[0].sender.email
|
||||
else:
|
||||
template_payload['reply_warning'] = True
|
||||
else:
|
||||
# There are some @-mentions mixed in with personals
|
||||
template_payload['mention'] = True
|
||||
template_payload['reply_warning'] = True
|
||||
|
||||
subject = "Missed Humbug PM%s from %s" % ('s' if len(senders) > 1 else '', sender_str)
|
||||
|
|
|
@ -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 \
|
||||
|
|
Loading…
Reference in New Issue