mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 08:56:10 +00:00
push: Rename received_pm to private_message.
This is a clearer name for this now more broadly used interface.
This commit is contained in:
@@ -3332,8 +3332,8 @@ def get_userids_for_missed_messages(realm, sender_id, message_type, active_user_
|
|||||||
for user_id in active_user_ids:
|
for user_id in active_user_ids:
|
||||||
flags = user_flags.get(user_id, []) # type: Iterable[str]
|
flags = user_flags.get(user_id, []) # type: Iterable[str]
|
||||||
mentioned = 'mentioned' in flags
|
mentioned = 'mentioned' in flags
|
||||||
received_pm = is_pm and user_id != sender_id
|
private_message = is_pm and user_id != sender_id
|
||||||
if mentioned or received_pm:
|
if mentioned or private_message:
|
||||||
user_ids.add(user_id)
|
user_ids.add(user_id)
|
||||||
|
|
||||||
if not user_ids:
|
if not user_ids:
|
||||||
|
|||||||
@@ -329,9 +329,9 @@ def get_alert_from_message(message):
|
|||||||
Determine what alert string to display based on the missed messages.
|
Determine what alert string to display based on the missed messages.
|
||||||
"""
|
"""
|
||||||
sender_str = message.sender.full_name
|
sender_str = message.sender.full_name
|
||||||
if message.recipient.type == Recipient.HUDDLE and message.triggers['received_pm']:
|
if message.recipient.type == Recipient.HUDDLE and message.triggers['private_message']:
|
||||||
return "New private group message from %s" % (sender_str,)
|
return "New private group message from %s" % (sender_str,)
|
||||||
elif message.recipient.type == Recipient.PERSONAL and message.triggers['received_pm']:
|
elif message.recipient.type == Recipient.PERSONAL and message.triggers['private_message']:
|
||||||
return "New private message from %s" % (sender_str,)
|
return "New private message from %s" % (sender_str,)
|
||||||
elif message.recipient.type == Recipient.STREAM and message.triggers['mentioned']:
|
elif message.recipient.type == Recipient.STREAM and message.triggers['mentioned']:
|
||||||
return "New mention from %s" % (sender_str,)
|
return "New mention from %s" % (sender_str,)
|
||||||
@@ -401,7 +401,7 @@ def handle_push_notification(user_profile_id, missed_message):
|
|||||||
message = umessage.message
|
message = umessage.message
|
||||||
triggers = missed_message.get('triggers')
|
triggers = missed_message.get('triggers')
|
||||||
message.triggers = {
|
message.triggers = {
|
||||||
'received_pm': triggers.get('received_pm', False),
|
'private_message': triggers.get('private_message', False),
|
||||||
'mentioned': triggers.get('mentioned', False),
|
'mentioned': triggers.get('mentioned', False),
|
||||||
'stream_push_notify': triggers.get('stream_push_notify', False),
|
'stream_push_notify': triggers.get('stream_push_notify', False),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ class HandlePushNotificationTest(PushNotificationTest):
|
|||||||
missed_message = {
|
missed_message = {
|
||||||
'message_id': message.id,
|
'message_id': message.id,
|
||||||
'triggers': {
|
'triggers': {
|
||||||
'received_pm': True,
|
'private_message': True,
|
||||||
'mentioned': False,
|
'mentioned': False,
|
||||||
'stream_push_notify': False,
|
'stream_push_notify': False,
|
||||||
},
|
},
|
||||||
@@ -399,7 +399,7 @@ class HandlePushNotificationTest(PushNotificationTest):
|
|||||||
'user_profile_id': self.user_profile.id,
|
'user_profile_id': self.user_profile.id,
|
||||||
'message_id': message.id,
|
'message_id': message.id,
|
||||||
'triggers': {
|
'triggers': {
|
||||||
'received_pm': True,
|
'private_message': True,
|
||||||
'mentioned': False,
|
'mentioned': False,
|
||||||
'stream_push_notify': False,
|
'stream_push_notify': False,
|
||||||
},
|
},
|
||||||
@@ -450,7 +450,7 @@ class HandlePushNotificationTest(PushNotificationTest):
|
|||||||
missed_message = {
|
missed_message = {
|
||||||
'message_id': message.id,
|
'message_id': message.id,
|
||||||
'triggers': {
|
'triggers': {
|
||||||
'received_pm': True,
|
'private_message': True,
|
||||||
'mentioned': False,
|
'mentioned': False,
|
||||||
'stream_push_notify': False,
|
'stream_push_notify': False,
|
||||||
},
|
},
|
||||||
@@ -469,7 +469,7 @@ class HandlePushNotificationTest(PushNotificationTest):
|
|||||||
missed_message = {
|
missed_message = {
|
||||||
'message_id': message.id,
|
'message_id': message.id,
|
||||||
'triggers': {
|
'triggers': {
|
||||||
'received_pm': True,
|
'private_message': True,
|
||||||
'mentioned': False,
|
'mentioned': False,
|
||||||
'stream_push_notify': False,
|
'stream_push_notify': False,
|
||||||
},
|
},
|
||||||
@@ -512,7 +512,7 @@ class HandlePushNotificationTest(PushNotificationTest):
|
|||||||
missed_message = {
|
missed_message = {
|
||||||
'message_id': message.id,
|
'message_id': message.id,
|
||||||
'triggers': {
|
'triggers': {
|
||||||
'received_pm': True,
|
'private_message': True,
|
||||||
'mentioned': False,
|
'mentioned': False,
|
||||||
'stream_push_notify': False,
|
'stream_push_notify': False,
|
||||||
},
|
},
|
||||||
@@ -586,7 +586,7 @@ class TestGetAlertFromMessage(PushNotificationTest):
|
|||||||
# type: () -> None
|
# type: () -> None
|
||||||
message = self.get_message(Recipient.HUDDLE)
|
message = self.get_message(Recipient.HUDDLE)
|
||||||
message.triggers = {
|
message.triggers = {
|
||||||
'received_pm': True,
|
'private_message': True,
|
||||||
'mentioned': False,
|
'mentioned': False,
|
||||||
'stream_push_notify': False,
|
'stream_push_notify': False,
|
||||||
}
|
}
|
||||||
@@ -597,7 +597,7 @@ class TestGetAlertFromMessage(PushNotificationTest):
|
|||||||
# type: () -> None
|
# type: () -> None
|
||||||
message = self.get_message(Recipient.PERSONAL)
|
message = self.get_message(Recipient.PERSONAL)
|
||||||
message.triggers = {
|
message.triggers = {
|
||||||
'received_pm': True,
|
'private_message': True,
|
||||||
'mentioned': False,
|
'mentioned': False,
|
||||||
'stream_push_notify': False,
|
'stream_push_notify': False,
|
||||||
}
|
}
|
||||||
@@ -608,7 +608,7 @@ class TestGetAlertFromMessage(PushNotificationTest):
|
|||||||
# type: () -> None
|
# type: () -> None
|
||||||
message = self.get_message(Recipient.STREAM)
|
message = self.get_message(Recipient.STREAM)
|
||||||
message.triggers = {
|
message.triggers = {
|
||||||
'received_pm': False,
|
'private_message': False,
|
||||||
'mentioned': True,
|
'mentioned': True,
|
||||||
'stream_push_notify': False,
|
'stream_push_notify': False,
|
||||||
}
|
}
|
||||||
@@ -619,7 +619,7 @@ class TestGetAlertFromMessage(PushNotificationTest):
|
|||||||
# type: () -> None
|
# type: () -> None
|
||||||
message = self.get_message(Recipient.STREAM)
|
message = self.get_message(Recipient.STREAM)
|
||||||
message.triggers = {
|
message.triggers = {
|
||||||
'received_pm': False,
|
'private_message': False,
|
||||||
'mentioned': False,
|
'mentioned': False,
|
||||||
'stream_push_notify': True,
|
'stream_push_notify': True,
|
||||||
}
|
}
|
||||||
@@ -631,7 +631,7 @@ class TestGetAlertFromMessage(PushNotificationTest):
|
|||||||
# type: () -> None
|
# type: () -> None
|
||||||
message = self.get_message(0)
|
message = self.get_message(0)
|
||||||
message.triggers = {
|
message.triggers = {
|
||||||
'received_pm': False,
|
'private_message': False,
|
||||||
'mentioned': False,
|
'mentioned': False,
|
||||||
'stream_push_notify': False,
|
'stream_push_notify': False,
|
||||||
}
|
}
|
||||||
@@ -646,7 +646,7 @@ class TestGetAPNsPayload(PushNotificationTest):
|
|||||||
# type: () -> None
|
# type: () -> None
|
||||||
message = self.get_message(Recipient.HUDDLE)
|
message = self.get_message(Recipient.HUDDLE)
|
||||||
message.triggers = {
|
message.triggers = {
|
||||||
'received_pm': True,
|
'private_message': True,
|
||||||
'mentioned': False,
|
'mentioned': False,
|
||||||
'stream_push_notify': False,
|
'stream_push_notify': False,
|
||||||
}
|
}
|
||||||
@@ -670,7 +670,7 @@ class TestGetGCMPayload(PushNotificationTest):
|
|||||||
message.content = 'a' * 210
|
message.content = 'a' * 210
|
||||||
message.save()
|
message.save()
|
||||||
message.triggers = {
|
message.triggers = {
|
||||||
'received_pm': False,
|
'private_message': False,
|
||||||
'mentioned': True,
|
'mentioned': True,
|
||||||
'stream_push_notify': False,
|
'stream_push_notify': False,
|
||||||
}
|
}
|
||||||
@@ -698,7 +698,7 @@ class TestGetGCMPayload(PushNotificationTest):
|
|||||||
# type: () -> None
|
# type: () -> None
|
||||||
message = self.get_message(Recipient.PERSONAL, 1)
|
message = self.get_message(Recipient.PERSONAL, 1)
|
||||||
message.triggers = {
|
message.triggers = {
|
||||||
'received_pm': True,
|
'private_message': True,
|
||||||
'mentioned': False,
|
'mentioned': False,
|
||||||
'stream_push_notify': False,
|
'stream_push_notify': False,
|
||||||
}
|
}
|
||||||
@@ -723,7 +723,7 @@ class TestGetGCMPayload(PushNotificationTest):
|
|||||||
# type: () -> None
|
# type: () -> None
|
||||||
message = self.get_message(Recipient.STREAM, 1)
|
message = self.get_message(Recipient.STREAM, 1)
|
||||||
message.triggers = {
|
message.triggers = {
|
||||||
'received_pm': False,
|
'private_message': False,
|
||||||
'mentioned': False,
|
'mentioned': False,
|
||||||
'stream_push_notify': True,
|
'stream_push_notify': True,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -688,18 +688,18 @@ def process_message_event(event_template, users):
|
|||||||
|
|
||||||
# If the recipient was offline and the message was a single or group PM to them
|
# If the recipient was offline and the message was a single or group PM to them
|
||||||
# or they were @-notified potentially notify more immediately
|
# or they were @-notified potentially notify more immediately
|
||||||
received_pm = message_type == "private" and user_profile_id != sender_id
|
private_message = message_type == "private" and user_profile_id != sender_id
|
||||||
mentioned = 'mentioned' in flags
|
mentioned = 'mentioned' in flags
|
||||||
stream_push_notify = user_data.get('stream_push_notify', False)
|
stream_push_notify = user_data.get('stream_push_notify', False)
|
||||||
|
|
||||||
if (received_pm or mentioned or stream_push_notify):
|
if (private_message or mentioned or stream_push_notify):
|
||||||
idle = receiver_is_off_zulip(user_profile_id) or (user_profile_id in missed_message_userids)
|
idle = receiver_is_off_zulip(user_profile_id) or (user_profile_id in missed_message_userids)
|
||||||
always_push_notify = user_data.get('always_push_notify', False)
|
always_push_notify = user_data.get('always_push_notify', False)
|
||||||
|
|
||||||
if (idle or always_push_notify):
|
if (idle or always_push_notify):
|
||||||
notice = build_offline_notification(user_profile_id, message_id)
|
notice = build_offline_notification(user_profile_id, message_id)
|
||||||
notice['triggers'] = {
|
notice['triggers'] = {
|
||||||
'received_pm': received_pm,
|
'private_message': private_message,
|
||||||
'mentioned': mentioned,
|
'mentioned': mentioned,
|
||||||
'stream_push_notify': stream_push_notify,
|
'stream_push_notify': stream_push_notify,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user