From 29d30ceab78304ce29dc9faa0d3db8187564fb80 Mon Sep 17 00:00:00 2001 From: Rishi Gupta Date: Wed, 17 Apr 2019 18:58:25 -0700 Subject: [PATCH] settings: Decouple enable_push_notifications_offline from PM setting. Note that this setting has always applied to both streams and PMs; the test just clarifies that that is the case. --- static/js/settings_notifications.js | 6 +----- .../settings/notification-settings.handlebars | 14 ++++++-------- templates/zerver/help/test-mobile-notifications.md | 13 +++++-------- zerver/tests/test_event_queue.py | 8 ++++++++ 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/static/js/settings_notifications.js b/static/js/settings_notifications.js index 18e74833bb..2c7aece7d5 100644 --- a/static/js/settings_notifications.js +++ b/static/js/settings_notifications.js @@ -13,12 +13,12 @@ var pm_mention_notification_settings = [ "enable_desktop_notifications", "enable_offline_email_notifications", "enable_offline_push_notifications", - "enable_online_push_notifications", "enable_sounds", "pm_content_in_desktop_notifications", ]; var other_notification_settings = [ + "enable_online_push_notifications", "notification_sound", "enable_digest_emails", "enable_login_emails", @@ -113,10 +113,6 @@ exports.set_up = function () { $("#enable_desktop_notifications").change(function () { settings_ui.disable_sub_setting_onchange(this.checked, "pm_content_in_desktop_notifications", true); }); - - $("#enable_offline_push_notifications").change(function () { - settings_ui.disable_sub_setting_onchange(this.checked, "enable_online_push_notifications", true); - }); }; exports.update_page = function () { diff --git a/static/templates/settings/notification-settings.handlebars b/static/templates/settings/notification-settings.handlebars index 2f4c70389c..00f808719a 100644 --- a/static/templates/settings/notification-settings.handlebars +++ b/static/templates/settings/notification-settings.handlebars @@ -64,14 +64,6 @@ "label" settings_label.enable_offline_push_notifications "push_notifications_tooltip" true}} - {{partial "settings_checkbox" - "setting_name" "enable_online_push_notifications" - "is_checked" page_params.enable_online_push_notifications - "is_parent_setting_enabled" page_params.enable_offline_push_notifications - "is_nested" true - "label" settings_label.enable_online_push_notifications - "push_notifications_tooltip" true}} - {{partial "settings_checkbox" "setting_name" "enable_offline_email_notifications" "is_checked" page_params.enable_offline_email_notifications @@ -83,6 +75,12 @@

{{t "Other notification settings" }}

+ {{partial "settings_checkbox" + "setting_name" "enable_online_push_notifications" + "is_checked" page_params.enable_online_push_notifications + "label" settings_label.enable_online_push_notifications + "push_notifications_tooltip" true}} + {{partial "settings_checkbox" "setting_name" "enable_digest_emails" "is_checked" page_params.enable_digest_emails diff --git a/templates/zerver/help/test-mobile-notifications.md b/templates/zerver/help/test-mobile-notifications.md index 804a74e563..461f1a9e4d 100644 --- a/templates/zerver/help/test-mobile-notifications.md +++ b/templates/zerver/help/test-mobile-notifications.md @@ -1,19 +1,16 @@ # Test mobile notifications -Normally, mobile notifications are only sent if you're idle, which isn't -ideal for testing. +Normally, mobile notifications are only sent after you've been idle for a +few minutes, which isn't ideal for testing. -You can instead have mobile notifications sent for all [private messages](/help/private-messages), -regardless of whether you're online. +You can instead have mobile notifications sent regardless of how recently +you've been online. {start_tabs} {settings_tab|notifications} -1. Under **Private messages and @-mentions**, enable - **Mobile notifications**. - -1. Under **Private messages, @-mentions, and alert words**, enable +1. Under **Other notification settings**, enable **Send mobile notifications even if I'm online**. {end_tabs} diff --git a/zerver/tests/test_event_queue.py b/zerver/tests/test_event_queue.py index 1be460a3d9..0460ee28d7 100644 --- a/zerver/tests/test_event_queue.py +++ b/zerver/tests/test_event_queue.py @@ -122,6 +122,14 @@ class MissedMessageNotificationsTest(ZulipTestCase): self.assertTrue(email_notice is None) self.assertTrue(mobile_notice is not None) + # Stream message sends push but not email if not idle but always_push_notify + email_notice, mobile_notice = self.check_will_notify( + user_profile.id, message_id, private_message=False, + mentioned=False, stream_push_notify=True, stream_email_notify=True, + stream_name="Denmark", always_push_notify=True, idle=False, already_notified={}) + self.assertTrue(email_notice is None) + self.assertTrue(mobile_notice is not None) + def tornado_call(self, view_func: Callable[[HttpRequest, UserProfile], HttpResponse], user_profile: UserProfile, post_data: Dict[str, Any]) -> HttpResponse: request = POSTRequestMock(post_data, user_profile)