mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 08:26:11 +00:00
message send: Rename always_push_notify -> online_push_enabled.
This is a better name, since it clearly denotes a user configured setting.
This commit is contained in:
committed by
Tim Abbott
parent
ddd123f133
commit
f236a0d10d
@@ -1961,7 +1961,7 @@ def do_send_messages(
|
|||||||
dict(
|
dict(
|
||||||
id=user_id,
|
id=user_id,
|
||||||
flags=user_flags.get(user_id, []),
|
flags=user_flags.get(user_id, []),
|
||||||
always_push_notify=(user_id in send_request.online_push_user_ids),
|
online_push_enabled=(user_id in send_request.online_push_user_ids),
|
||||||
stream_push_notify=(user_id in send_request.stream_push_user_ids),
|
stream_push_notify=(user_id in send_request.stream_push_user_ids),
|
||||||
stream_email_notify=(user_id in send_request.stream_email_user_ids),
|
stream_email_notify=(user_id in send_request.stream_email_user_ids),
|
||||||
wildcard_mention_notify=(user_id in send_request.wildcard_mention_user_ids),
|
wildcard_mention_notify=(user_id in send_request.wildcard_mention_user_ids),
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class MissedMessageNotificationsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=False,
|
stream_email_notify=False,
|
||||||
stream_name=None,
|
stream_name=None,
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=True,
|
idle=True,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
@@ -80,7 +80,7 @@ class MissedMessageNotificationsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=True,
|
stream_email_notify=True,
|
||||||
stream_name=None,
|
stream_name=None,
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=True,
|
idle=True,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
@@ -98,7 +98,7 @@ class MissedMessageNotificationsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=False,
|
stream_email_notify=False,
|
||||||
stream_name=None,
|
stream_name=None,
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=True,
|
idle=True,
|
||||||
already_notified={
|
already_notified={
|
||||||
"push_notified": True,
|
"push_notified": True,
|
||||||
@@ -117,7 +117,7 @@ class MissedMessageNotificationsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=False,
|
stream_email_notify=False,
|
||||||
stream_name=None,
|
stream_name=None,
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=True,
|
idle=True,
|
||||||
already_notified={
|
already_notified={
|
||||||
"push_notified": False,
|
"push_notified": False,
|
||||||
@@ -137,7 +137,7 @@ class MissedMessageNotificationsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=False,
|
stream_email_notify=False,
|
||||||
stream_name=None,
|
stream_name=None,
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=True,
|
idle=True,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
@@ -156,7 +156,7 @@ class MissedMessageNotificationsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=False,
|
stream_email_notify=False,
|
||||||
stream_name=None,
|
stream_name=None,
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=True,
|
idle=True,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
@@ -173,7 +173,7 @@ class MissedMessageNotificationsTest(ZulipTestCase):
|
|||||||
stream_push_notify=True,
|
stream_push_notify=True,
|
||||||
stream_email_notify=False,
|
stream_email_notify=False,
|
||||||
stream_name="Denmark",
|
stream_name="Denmark",
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=True,
|
idle=True,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
@@ -190,7 +190,7 @@ class MissedMessageNotificationsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=True,
|
stream_email_notify=True,
|
||||||
stream_name="Denmark",
|
stream_name="Denmark",
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=True,
|
idle=True,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
@@ -207,7 +207,7 @@ class MissedMessageNotificationsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=True,
|
stream_email_notify=True,
|
||||||
stream_name=None,
|
stream_name=None,
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=False,
|
idle=False,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
@@ -224,7 +224,7 @@ class MissedMessageNotificationsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=False,
|
stream_email_notify=False,
|
||||||
stream_name=None,
|
stream_name=None,
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=False,
|
idle=False,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
@@ -241,14 +241,14 @@ class MissedMessageNotificationsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=False,
|
stream_email_notify=False,
|
||||||
stream_name=None,
|
stream_name=None,
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=False,
|
idle=False,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
self.assertTrue(email_notice is None)
|
self.assertTrue(email_notice is None)
|
||||||
self.assertTrue(mobile_notice is None)
|
self.assertTrue(mobile_notice is None)
|
||||||
|
|
||||||
# Private message sends push but not email if not idle but always_push_notify
|
# Private message sends push but not email if not idle but online_push_enabled
|
||||||
email_notice, mobile_notice = self.check_will_notify(
|
email_notice, mobile_notice = self.check_will_notify(
|
||||||
user_profile.id,
|
user_profile.id,
|
||||||
message_id,
|
message_id,
|
||||||
@@ -258,14 +258,14 @@ class MissedMessageNotificationsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=True,
|
stream_email_notify=True,
|
||||||
stream_name=None,
|
stream_name=None,
|
||||||
always_push_notify=True,
|
online_push_enabled=True,
|
||||||
idle=False,
|
idle=False,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
self.assertTrue(email_notice is None)
|
self.assertTrue(email_notice is None)
|
||||||
self.assertTrue(mobile_notice is not None)
|
self.assertTrue(mobile_notice is not None)
|
||||||
|
|
||||||
# Stream message sends push but not email if not idle but always_push_notify
|
# Stream message sends push but not email if not idle but online_push_enabled
|
||||||
email_notice, mobile_notice = self.check_will_notify(
|
email_notice, mobile_notice = self.check_will_notify(
|
||||||
user_profile.id,
|
user_profile.id,
|
||||||
message_id,
|
message_id,
|
||||||
@@ -275,7 +275,7 @@ class MissedMessageNotificationsTest(ZulipTestCase):
|
|||||||
stream_push_notify=True,
|
stream_push_notify=True,
|
||||||
stream_email_notify=True,
|
stream_email_notify=True,
|
||||||
stream_name="Denmark",
|
stream_name="Denmark",
|
||||||
always_push_notify=True,
|
online_push_enabled=True,
|
||||||
idle=False,
|
idle=False,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class EditMessageSideEffectsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=False,
|
stream_email_notify=False,
|
||||||
stream_name="Scotland",
|
stream_name="Scotland",
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=True,
|
idle=True,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
@@ -299,7 +299,7 @@ class EditMessageSideEffectsTest(ZulipTestCase):
|
|||||||
present_on_web=True,
|
present_on_web=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_always_push_notify_for_fully_present_mentioned_user(self) -> None:
|
def test_online_push_enabled_for_fully_present_mentioned_user(self) -> None:
|
||||||
cordelia = self.example_user("cordelia")
|
cordelia = self.example_user("cordelia")
|
||||||
|
|
||||||
# Simulate Cordelia is FULLY present, not just in term of
|
# Simulate Cordelia is FULLY present, not just in term of
|
||||||
@@ -326,7 +326,7 @@ class EditMessageSideEffectsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=False,
|
stream_email_notify=False,
|
||||||
stream_name="Scotland",
|
stream_name="Scotland",
|
||||||
always_push_notify=True,
|
online_push_enabled=True,
|
||||||
idle=False,
|
idle=False,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
@@ -337,7 +337,7 @@ class EditMessageSideEffectsTest(ZulipTestCase):
|
|||||||
|
|
||||||
self.assert_length(queue_messages, 1)
|
self.assert_length(queue_messages, 1)
|
||||||
|
|
||||||
def test_always_push_notify_for_fully_present_boring_user(self) -> None:
|
def test_online_push_enabled_for_fully_present_boring_user(self) -> None:
|
||||||
cordelia = self.example_user("cordelia")
|
cordelia = self.example_user("cordelia")
|
||||||
|
|
||||||
# Simulate Cordelia is FULLY present, not just in term of
|
# Simulate Cordelia is FULLY present, not just in term of
|
||||||
@@ -364,7 +364,7 @@ class EditMessageSideEffectsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=False,
|
stream_email_notify=False,
|
||||||
stream_name="Scotland",
|
stream_name="Scotland",
|
||||||
always_push_notify=True,
|
online_push_enabled=True,
|
||||||
idle=False,
|
idle=False,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
@@ -404,7 +404,7 @@ class EditMessageSideEffectsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=False,
|
stream_email_notify=False,
|
||||||
stream_name="Scotland",
|
stream_name="Scotland",
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=True,
|
idle=True,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
@@ -440,7 +440,7 @@ class EditMessageSideEffectsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=False,
|
stream_email_notify=False,
|
||||||
stream_name="Scotland",
|
stream_name="Scotland",
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=True,
|
idle=True,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
@@ -501,7 +501,7 @@ class EditMessageSideEffectsTest(ZulipTestCase):
|
|||||||
stream_push_notify=False,
|
stream_push_notify=False,
|
||||||
stream_email_notify=False,
|
stream_email_notify=False,
|
||||||
stream_name="Scotland",
|
stream_name="Scotland",
|
||||||
always_push_notify=False,
|
online_push_enabled=False,
|
||||||
idle=False,
|
idle=False,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -753,8 +753,8 @@ def missedmessage_hook(
|
|||||||
if not private_message:
|
if not private_message:
|
||||||
stream_name = event["message"]["display_recipient"]
|
stream_name = event["message"]["display_recipient"]
|
||||||
|
|
||||||
# Since one is by definition idle, we don't need to check always_push_notify
|
# Since one is by definition idle, we don't need to check online_push_enabled
|
||||||
always_push_notify = False
|
online_push_enabled = False
|
||||||
# Since we just GC'd the last event queue, the user is definitely idle.
|
# Since we just GC'd the last event queue, the user is definitely idle.
|
||||||
idle = True
|
idle = True
|
||||||
|
|
||||||
@@ -773,7 +773,7 @@ def missedmessage_hook(
|
|||||||
stream_push_notify,
|
stream_push_notify,
|
||||||
stream_email_notify,
|
stream_email_notify,
|
||||||
stream_name,
|
stream_name,
|
||||||
always_push_notify,
|
online_push_enabled,
|
||||||
idle,
|
idle,
|
||||||
already_notified,
|
already_notified,
|
||||||
)
|
)
|
||||||
@@ -799,7 +799,7 @@ def maybe_enqueue_notifications(
|
|||||||
stream_push_notify: bool,
|
stream_push_notify: bool,
|
||||||
stream_email_notify: bool,
|
stream_email_notify: bool,
|
||||||
stream_name: Optional[str],
|
stream_name: Optional[str],
|
||||||
always_push_notify: bool,
|
online_push_enabled: bool,
|
||||||
idle: bool,
|
idle: bool,
|
||||||
already_notified: Dict[str, bool],
|
already_notified: Dict[str, bool],
|
||||||
) -> Dict[str, bool]:
|
) -> Dict[str, bool]:
|
||||||
@@ -812,7 +812,7 @@ def maybe_enqueue_notifications(
|
|||||||
"""
|
"""
|
||||||
notified: Dict[str, bool] = {}
|
notified: Dict[str, bool] = {}
|
||||||
|
|
||||||
if (idle or always_push_notify) and (
|
if (idle or online_push_enabled) and (
|
||||||
private_message or mentioned or wildcard_mention_notify or stream_push_notify
|
private_message or mentioned or wildcard_mention_notify or stream_push_notify
|
||||||
):
|
):
|
||||||
notice = build_offline_notification(user_profile_id, message_id)
|
notice = build_offline_notification(user_profile_id, message_id)
|
||||||
@@ -968,7 +968,17 @@ def process_message_event(
|
|||||||
idle = receiver_is_off_zulip(user_profile_id) or (
|
idle = receiver_is_off_zulip(user_profile_id) or (
|
||||||
user_profile_id in presence_idle_user_ids
|
user_profile_id in presence_idle_user_ids
|
||||||
)
|
)
|
||||||
always_push_notify = user_data.get("always_push_notify", False)
|
|
||||||
|
# TODO/compatibility: Translation code for the rename of
|
||||||
|
# `always_push_notify` to `online_push_enabled`. Remove this
|
||||||
|
# when one can no longer directly upgrade from 4.x to master.
|
||||||
|
if "online_push_enabled" in user_data:
|
||||||
|
online_push_enabled = user_data["online_push_enabled"]
|
||||||
|
elif "always_push_notify" in user_data:
|
||||||
|
online_push_enabled = user_data["always_push_notify"]
|
||||||
|
else:
|
||||||
|
online_push_enabled = False
|
||||||
|
|
||||||
stream_name = event_template.get("stream_name")
|
stream_name = event_template.get("stream_name")
|
||||||
|
|
||||||
result: Dict[str, Any] = {}
|
result: Dict[str, Any] = {}
|
||||||
@@ -981,7 +991,7 @@ def process_message_event(
|
|||||||
stream_push_notify,
|
stream_push_notify,
|
||||||
stream_email_notify,
|
stream_email_notify,
|
||||||
stream_name,
|
stream_name,
|
||||||
always_push_notify,
|
online_push_enabled,
|
||||||
idle,
|
idle,
|
||||||
{},
|
{},
|
||||||
)
|
)
|
||||||
@@ -1195,7 +1205,7 @@ def maybe_enqueue_notifications_for_message_update(
|
|||||||
# We can have newly mentioned people in an updated message.
|
# We can have newly mentioned people in an updated message.
|
||||||
mentioned = user_profile_id in mention_user_ids
|
mentioned = user_profile_id in mention_user_ids
|
||||||
|
|
||||||
always_push_notify = user_profile_id in online_push_user_ids
|
online_push_enabled = user_profile_id in online_push_user_ids
|
||||||
|
|
||||||
idle = (user_profile_id in presence_idle_user_ids) or receiver_is_off_zulip(user_profile_id)
|
idle = (user_profile_id in presence_idle_user_ids) or receiver_is_off_zulip(user_profile_id)
|
||||||
|
|
||||||
@@ -1208,7 +1218,7 @@ def maybe_enqueue_notifications_for_message_update(
|
|||||||
stream_push_notify=stream_push_notify,
|
stream_push_notify=stream_push_notify,
|
||||||
stream_email_notify=stream_email_notify,
|
stream_email_notify=stream_email_notify,
|
||||||
stream_name=stream_name,
|
stream_name=stream_name,
|
||||||
always_push_notify=always_push_notify,
|
online_push_enabled=online_push_enabled,
|
||||||
idle=idle,
|
idle=idle,
|
||||||
already_notified={},
|
already_notified={},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user