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.
This commit is contained in:
Rishi Gupta 2019-04-17 18:58:25 -07:00 committed by Tim Abbott
parent 8a2772adcf
commit 29d30ceab7
4 changed files with 20 additions and 21 deletions

View File

@ -13,12 +13,12 @@ var pm_mention_notification_settings = [
"enable_desktop_notifications", "enable_desktop_notifications",
"enable_offline_email_notifications", "enable_offline_email_notifications",
"enable_offline_push_notifications", "enable_offline_push_notifications",
"enable_online_push_notifications",
"enable_sounds", "enable_sounds",
"pm_content_in_desktop_notifications", "pm_content_in_desktop_notifications",
]; ];
var other_notification_settings = [ var other_notification_settings = [
"enable_online_push_notifications",
"notification_sound", "notification_sound",
"enable_digest_emails", "enable_digest_emails",
"enable_login_emails", "enable_login_emails",
@ -113,10 +113,6 @@ exports.set_up = function () {
$("#enable_desktop_notifications").change(function () { $("#enable_desktop_notifications").change(function () {
settings_ui.disable_sub_setting_onchange(this.checked, "pm_content_in_desktop_notifications", true); 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 () { exports.update_page = function () {

View File

@ -64,14 +64,6 @@
"label" settings_label.enable_offline_push_notifications "label" settings_label.enable_offline_push_notifications
"push_notifications_tooltip" true}} "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" {{partial "settings_checkbox"
"setting_name" "enable_offline_email_notifications" "setting_name" "enable_offline_email_notifications"
"is_checked" page_params.enable_offline_email_notifications "is_checked" page_params.enable_offline_email_notifications
@ -83,6 +75,12 @@
<h3 class="inline-block">{{t "Other notification settings" }}</h3> <h3 class="inline-block">{{t "Other notification settings" }}</h3>
<div class="alert-notification" id="other-notify-settings-status"></div> <div class="alert-notification" id="other-notify-settings-status"></div>
{{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" {{partial "settings_checkbox"
"setting_name" "enable_digest_emails" "setting_name" "enable_digest_emails"
"is_checked" page_params.enable_digest_emails "is_checked" page_params.enable_digest_emails

View File

@ -1,19 +1,16 @@
# Test mobile notifications # Test mobile notifications
Normally, mobile notifications are only sent if you're idle, which isn't Normally, mobile notifications are only sent after you've been idle for a
ideal for testing. few minutes, which isn't ideal for testing.
You can instead have mobile notifications sent for all [private messages](/help/private-messages), You can instead have mobile notifications sent regardless of how recently
regardless of whether you're online. you've been online.
{start_tabs} {start_tabs}
{settings_tab|notifications} {settings_tab|notifications}
1. Under **Private messages and @-mentions**, enable 1. Under **Other notification settings**, enable
**Mobile notifications**.
1. Under **Private messages, @-mentions, and alert words**, enable
**Send mobile notifications even if I'm online**. **Send mobile notifications even if I'm online**.
{end_tabs} {end_tabs}

View File

@ -122,6 +122,14 @@ class MissedMessageNotificationsTest(ZulipTestCase):
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
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], def tornado_call(self, view_func: Callable[[HttpRequest, UserProfile], HttpResponse],
user_profile: UserProfile, post_data: Dict[str, Any]) -> HttpResponse: user_profile: UserProfile, post_data: Dict[str, Any]) -> HttpResponse:
request = POSTRequestMock(post_data, user_profile) request = POSTRequestMock(post_data, user_profile)