mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
subscriptions: Migrate notification setting defaults model.
This commit migrates the Subscription's notification fields from a BooleanField to a NullBooleanField where a value of None means to inherit the value from user's profile. Also includes a migrations to set the corresponding settings to None if they match the user profile's values. This migration helps us in getting rid of the weird "Apply to all" widget that we offered on subscription settings page. The mobile apps can't handle None appearing as the stream-level notification settings, so for backwards-compatibility we arrange to only send True/False to the mobile apps by applying those defaults server-side. We introduce a notification_settings_null value within a client_capabilities structure that newer versions of the mobile apps can use to request the new model. This mobile compatibility code is pretty effectively tested by the existing test_events tests for the subscriptions subsystem.
This commit is contained in:
committed by
Tim Abbott
parent
8a2057e3cf
commit
b553507412
@@ -297,6 +297,28 @@ exports.update_calculated_fields = function (sub) {
|
||||
sub.rendered_description = sub.rendered_description.replace('<p>', '').replace('</p>', '');
|
||||
}
|
||||
exports.update_subscribers_count(sub);
|
||||
|
||||
// Apply the defaults for our notification settings for rendering.
|
||||
if (sub.email_notifications === null) {
|
||||
sub.email_notifications_display = page_params.enable_stream_email_notifications;
|
||||
} else {
|
||||
sub.email_notifications_display = sub.email_notifications;
|
||||
}
|
||||
if (sub.push_notifications === null) {
|
||||
sub.push_notifications_display = page_params.enable_stream_push_notifications;
|
||||
} else {
|
||||
sub.push_notifications_display = sub.push_notifications;
|
||||
}
|
||||
if (sub.desktop_notifications === null) {
|
||||
sub.desktop_notifications_display = page_params.enable_stream_desktop_notifications;
|
||||
} else {
|
||||
sub.desktop_notifications_display = sub.desktop_notifications;
|
||||
}
|
||||
if (sub.audible_notifications === null) {
|
||||
sub.audible_notifications_display = page_params.enable_stream_sounds;
|
||||
} else {
|
||||
sub.audible_notifications_display = sub.audible_notifications;
|
||||
}
|
||||
};
|
||||
|
||||
exports.all_subscribed_streams_are_in_home_view = function () {
|
||||
@@ -581,7 +603,10 @@ exports.receives_desktop_notifications = function (stream_name) {
|
||||
if (sub === undefined) {
|
||||
return false;
|
||||
}
|
||||
return sub.desktop_notifications;
|
||||
if (sub.desktop_notifications !== null) {
|
||||
return sub.desktop_notifications;
|
||||
}
|
||||
return page_params.enable_stream_desktop_notifications;
|
||||
};
|
||||
|
||||
exports.receives_audible_notifications = function (stream_name) {
|
||||
@@ -589,7 +614,10 @@ exports.receives_audible_notifications = function (stream_name) {
|
||||
if (sub === undefined) {
|
||||
return false;
|
||||
}
|
||||
return sub.audible_notifications;
|
||||
if (sub.audible_notifications !== null) {
|
||||
return sub.audible_notifications;
|
||||
}
|
||||
return page_params.enable_stream_sounds;
|
||||
};
|
||||
|
||||
exports.get_streams_for_settings_page = function () {
|
||||
|
||||
Reference in New Issue
Block a user