mirror of https://github.com/zulip/zulip.git
settings: Add realm-level setting 'zulip_update_announcements_stream'.
This commit adds a realm-level setting named 'zulip_update_announcements_stream' that configures the stream to which zulip updates should be posted. Fixes part of #28604.
This commit is contained in:
parent
e6109ba192
commit
fe1a20ebb3
|
@ -20,6 +20,13 @@ format used by the Zulip server that they are interacting with.
|
||||||
|
|
||||||
## Changes in Zulip 9.0
|
## Changes in Zulip 9.0
|
||||||
|
|
||||||
|
**Feature level 242**
|
||||||
|
|
||||||
|
* [`POST /register`](/api/register-queue), [`POST /events`](/api/get-events),
|
||||||
|
`PATCH /realm`: Added `zulip_update_announcements_stream_id` realm setting,
|
||||||
|
which is the ID of the of the stream to which automated messages announcing
|
||||||
|
new features or other end-user updates about the Zulip software are sent.
|
||||||
|
|
||||||
**Feature level 241**
|
**Feature level 241**
|
||||||
|
|
||||||
* [`POST /register`](/api/register-queue), [`POST /events`](/api/get-events),
|
* [`POST /register`](/api/register-queue), [`POST /events`](/api/get-events),
|
||||||
|
|
|
@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
|
||||||
# Changes should be accompanied by documentation explaining what the
|
# Changes should be accompanied by documentation explaining what the
|
||||||
# new level means in api_docs/changelog.md, as well as "**Changes**"
|
# new level means in api_docs/changelog.md, as well as "**Changes**"
|
||||||
# entries in the endpoint's documentation in `zulip.yaml`.
|
# entries in the endpoint's documentation in `zulip.yaml`.
|
||||||
API_FEATURE_LEVEL = 241
|
API_FEATURE_LEVEL = 242
|
||||||
|
|
||||||
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
||||||
# only when going from an old version of the code to a newer version. Bump
|
# only when going from an old version of the code to a newer version. Bump
|
||||||
|
|
|
@ -60,6 +60,24 @@ async function test_change_signup_announcements_stream(page: Page): Promise<void
|
||||||
await submit_announcements_stream_settings(page);
|
await submit_announcements_stream_settings(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function test_change_zulip_update_announcements_stream(page: Page): Promise<void> {
|
||||||
|
await page.click("#realm_zulip_update_announcements_stream_id_widget.dropdown-widget-button");
|
||||||
|
await page.waitForSelector(".dropdown-list-container", {
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.type(".dropdown-list-search-input", "rome");
|
||||||
|
|
||||||
|
const rome_in_dropdown = await page.waitForSelector(
|
||||||
|
`xpath///*[${common.has_class_x("list-item")}][normalize-space()="Rome"]`,
|
||||||
|
{visible: true},
|
||||||
|
);
|
||||||
|
assert.ok(rome_in_dropdown);
|
||||||
|
await rome_in_dropdown.click();
|
||||||
|
|
||||||
|
await submit_announcements_stream_settings(page);
|
||||||
|
}
|
||||||
|
|
||||||
async function test_permissions_change_save_worked(page: Page): Promise<void> {
|
async function test_permissions_change_save_worked(page: Page): Promise<void> {
|
||||||
const saved_status = '#org-stream-permissions .save-button[data-status="saved"]';
|
const saved_status = '#org-stream-permissions .save-button[data-status="saved"]';
|
||||||
await page.waitForSelector(saved_status, {
|
await page.waitForSelector(saved_status, {
|
||||||
|
@ -265,6 +283,7 @@ async function admin_test(page: Page): Promise<void> {
|
||||||
await common.manage_organization(page);
|
await common.manage_organization(page);
|
||||||
await test_change_new_stream_announcements_stream(page);
|
await test_change_new_stream_announcements_stream(page);
|
||||||
await test_change_signup_announcements_stream(page);
|
await test_change_signup_announcements_stream(page);
|
||||||
|
await test_change_zulip_update_announcements_stream(page);
|
||||||
|
|
||||||
await test_organization_permissions(page);
|
await test_organization_permissions(page);
|
||||||
// Currently, Firefox (with puppeteer) does not support file upload:
|
// Currently, Firefox (with puppeteer) does not support file upload:
|
||||||
|
|
|
@ -32,6 +32,7 @@ const admin_settings_label = {
|
||||||
realm_mandatory_topics: $t({defaultMessage: "Require topics in stream messages"}),
|
realm_mandatory_topics: $t({defaultMessage: "Require topics in stream messages"}),
|
||||||
realm_new_stream_announcements_stream: $t({defaultMessage: "New stream announcements"}),
|
realm_new_stream_announcements_stream: $t({defaultMessage: "New stream announcements"}),
|
||||||
realm_signup_announcements_stream: $t({defaultMessage: "New user announcements"}),
|
realm_signup_announcements_stream: $t({defaultMessage: "New user announcements"}),
|
||||||
|
realm_zulip_update_announcements_stream: $t({defaultMessage: "Zulip update announcements"}),
|
||||||
realm_inline_image_preview: $t({
|
realm_inline_image_preview: $t({
|
||||||
defaultMessage: "Show previews of uploaded and linked images and videos",
|
defaultMessage: "Show previews of uploaded and linked images and videos",
|
||||||
}),
|
}),
|
||||||
|
@ -139,6 +140,8 @@ export function build_page() {
|
||||||
realm_waiting_period_threshold: realm.realm_waiting_period_threshold,
|
realm_waiting_period_threshold: realm.realm_waiting_period_threshold,
|
||||||
realm_new_stream_announcements_stream_id: realm.realm_new_stream_announcements_stream_id,
|
realm_new_stream_announcements_stream_id: realm.realm_new_stream_announcements_stream_id,
|
||||||
realm_signup_announcements_stream_id: realm.realm_signup_announcements_stream_id,
|
realm_signup_announcements_stream_id: realm.realm_signup_announcements_stream_id,
|
||||||
|
realm_zulip_update_announcements_stream_id:
|
||||||
|
realm.realm_zulip_update_announcements_stream_id,
|
||||||
is_admin: current_user.is_admin,
|
is_admin: current_user.is_admin,
|
||||||
is_guest: current_user.is_guest,
|
is_guest: current_user.is_guest,
|
||||||
is_owner: current_user.is_owner,
|
is_owner: current_user.is_owner,
|
||||||
|
|
|
@ -242,6 +242,7 @@ export function dispatch_normal_event(event) {
|
||||||
message_content_allowed_in_email_notifications: noop,
|
message_content_allowed_in_email_notifications: noop,
|
||||||
enable_spectator_access: noop,
|
enable_spectator_access: noop,
|
||||||
signup_announcements_stream_id: noop,
|
signup_announcements_stream_id: noop,
|
||||||
|
zulip_update_announcements_stream_id: noop,
|
||||||
emails_restricted_to_domains: noop,
|
emails_restricted_to_domains: noop,
|
||||||
video_chat_provider: compose_call_ui.update_audio_and_video_chat_button_display,
|
video_chat_provider: compose_call_ui.update_audio_and_video_chat_button_display,
|
||||||
jitsi_server_url: compose_call_ui.update_audio_and_video_chat_button_display,
|
jitsi_server_url: compose_call_ui.update_audio_and_video_chat_button_display,
|
||||||
|
@ -570,6 +571,12 @@ export function dispatch_normal_event(event) {
|
||||||
realm.realm_signup_announcements_stream_id = -1;
|
realm.realm_signup_announcements_stream_id = -1;
|
||||||
settings_org.sync_realm_settings("signup_announcements_stream_id");
|
settings_org.sync_realm_settings("signup_announcements_stream_id");
|
||||||
}
|
}
|
||||||
|
if (realm.realm_zulip_update_announcements_stream_id === stream.stream_id) {
|
||||||
|
realm.realm_zulip_update_announcements_stream_id = -1;
|
||||||
|
settings_org.sync_realm_settings(
|
||||||
|
"zulip_update_announcements_stream_id",
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
stream_list.update_subscribe_to_more_streams_link();
|
stream_list.update_subscribe_to_more_streams_link();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -241,6 +241,7 @@ export function sort_object_by_key(obj) {
|
||||||
export let default_code_language_widget = null;
|
export let default_code_language_widget = null;
|
||||||
export let new_stream_announcements_stream_widget = null;
|
export let new_stream_announcements_stream_widget = null;
|
||||||
export let signup_announcements_stream_widget = null;
|
export let signup_announcements_stream_widget = null;
|
||||||
|
export let zulip_update_announcements_stream_widget = null;
|
||||||
export let create_multiuse_invite_group_widget = null;
|
export let create_multiuse_invite_group_widget = null;
|
||||||
export let can_remove_subscribers_group_widget = null;
|
export let can_remove_subscribers_group_widget = null;
|
||||||
export let can_access_all_users_group_widget = null;
|
export let can_access_all_users_group_widget = null;
|
||||||
|
@ -253,6 +254,8 @@ export function get_widget_for_dropdown_list_settings(property_name) {
|
||||||
return new_stream_announcements_stream_widget;
|
return new_stream_announcements_stream_widget;
|
||||||
case "realm_signup_announcements_stream_id":
|
case "realm_signup_announcements_stream_id":
|
||||||
return signup_announcements_stream_widget;
|
return signup_announcements_stream_widget;
|
||||||
|
case "realm_zulip_update_announcements_stream_id":
|
||||||
|
return zulip_update_announcements_stream_widget;
|
||||||
case "realm_default_code_block_language":
|
case "realm_default_code_block_language":
|
||||||
return default_code_language_widget;
|
return default_code_language_widget;
|
||||||
case "realm_create_multiuse_invite_group":
|
case "realm_create_multiuse_invite_group":
|
||||||
|
@ -281,6 +284,10 @@ export function set_signup_announcements_stream_widget(widget) {
|
||||||
signup_announcements_stream_widget = widget;
|
signup_announcements_stream_widget = widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function set_zulip_update_announcements_stream_widget(widget) {
|
||||||
|
zulip_update_announcements_stream_widget = widget;
|
||||||
|
}
|
||||||
|
|
||||||
export function set_create_multiuse_invite_group_widget(widget) {
|
export function set_create_multiuse_invite_group_widget(widget) {
|
||||||
create_multiuse_invite_group_widget = widget;
|
create_multiuse_invite_group_widget = widget;
|
||||||
}
|
}
|
||||||
|
@ -506,6 +513,7 @@ export function check_property_changed(elem, for_realm_default_settings, sub, gr
|
||||||
break;
|
break;
|
||||||
case "realm_new_stream_announcements_stream_id":
|
case "realm_new_stream_announcements_stream_id":
|
||||||
case "realm_signup_announcements_stream_id":
|
case "realm_signup_announcements_stream_id":
|
||||||
|
case "realm_zulip_update_announcements_stream_id":
|
||||||
case "realm_default_code_block_language":
|
case "realm_default_code_block_language":
|
||||||
case "can_remove_subscribers_group":
|
case "can_remove_subscribers_group":
|
||||||
case "realm_create_multiuse_invite_group":
|
case "realm_create_multiuse_invite_group":
|
||||||
|
|
|
@ -476,6 +476,7 @@ export function discard_property_element_changes(elem, for_realm_default_setting
|
||||||
break;
|
break;
|
||||||
case "realm_new_stream_announcements_stream_id":
|
case "realm_new_stream_announcements_stream_id":
|
||||||
case "realm_signup_announcements_stream_id":
|
case "realm_signup_announcements_stream_id":
|
||||||
|
case "realm_zulip_update_announcements_stream_id":
|
||||||
case "realm_default_code_block_language":
|
case "realm_default_code_block_language":
|
||||||
case "can_remove_subscribers_group":
|
case "can_remove_subscribers_group":
|
||||||
case "realm_create_multiuse_invite_group":
|
case "realm_create_multiuse_invite_group":
|
||||||
|
@ -681,6 +682,29 @@ export function init_dropdown_widgets() {
|
||||||
settings_components.set_signup_announcements_stream_widget(signup_announcements_stream_widget);
|
settings_components.set_signup_announcements_stream_widget(signup_announcements_stream_widget);
|
||||||
signup_announcements_stream_widget.setup();
|
signup_announcements_stream_widget.setup();
|
||||||
|
|
||||||
|
const zulip_update_announcements_stream_widget = new dropdown_widget.DropdownWidget({
|
||||||
|
widget_name: "realm_zulip_update_announcements_stream_id",
|
||||||
|
get_options: notification_stream_options,
|
||||||
|
$events_container: $("#settings_overlay_container #organization-settings"),
|
||||||
|
item_click_callback(event, dropdown) {
|
||||||
|
dropdown.hide();
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
settings_components.zulip_update_announcements_stream_widget.render();
|
||||||
|
settings_components.save_discard_widget_status_handler($("#org-notifications"));
|
||||||
|
},
|
||||||
|
tippy_props: {
|
||||||
|
placement: "bottom-start",
|
||||||
|
},
|
||||||
|
default_id: realm.realm_zulip_update_announcements_stream_id,
|
||||||
|
unique_id_type: dropdown_widget.DataTypes.NUMBER,
|
||||||
|
text_if_current_value_not_in_options: $t({defaultMessage: "Cannot view stream"}),
|
||||||
|
});
|
||||||
|
settings_components.set_zulip_update_announcements_stream_widget(
|
||||||
|
zulip_update_announcements_stream_widget,
|
||||||
|
);
|
||||||
|
zulip_update_announcements_stream_widget.setup();
|
||||||
|
|
||||||
const default_code_language_widget = new dropdown_widget.DropdownWidget({
|
const default_code_language_widget = new dropdown_widget.DropdownWidget({
|
||||||
widget_name: "realm_default_code_block_language",
|
widget_name: "realm_default_code_block_language",
|
||||||
get_options() {
|
get_options() {
|
||||||
|
|
|
@ -610,13 +610,18 @@ export function initialize() {
|
||||||
stream_id === realm.realm_new_stream_announcements_stream_id;
|
stream_id === realm.realm_new_stream_announcements_stream_id;
|
||||||
const is_signup_announcements_stream =
|
const is_signup_announcements_stream =
|
||||||
stream_id === realm.realm_signup_announcements_stream_id;
|
stream_id === realm.realm_signup_announcements_stream_id;
|
||||||
|
const is_zulip_update_announcements_stream =
|
||||||
|
stream_id === realm.realm_zulip_update_announcements_stream_id;
|
||||||
const is_announcement_stream =
|
const is_announcement_stream =
|
||||||
is_new_stream_announcements_stream || is_signup_announcements_stream;
|
is_new_stream_announcements_stream ||
|
||||||
|
is_signup_announcements_stream ||
|
||||||
|
is_zulip_update_announcements_stream;
|
||||||
|
|
||||||
const html_body = render_settings_deactivation_stream_modal({
|
const html_body = render_settings_deactivation_stream_modal({
|
||||||
stream_name_with_privacy_symbol_html,
|
stream_name_with_privacy_symbol_html,
|
||||||
is_new_stream_announcements_stream,
|
is_new_stream_announcements_stream,
|
||||||
is_signup_announcements_stream,
|
is_signup_announcements_stream,
|
||||||
|
is_zulip_update_announcements_stream,
|
||||||
is_announcement_stream,
|
is_announcement_stream,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -606,6 +606,7 @@ export function initialize_everything(state_data) {
|
||||||
"realm_waiting_period_threshold",
|
"realm_waiting_period_threshold",
|
||||||
"realm_want_advertise_in_communities_directory",
|
"realm_want_advertise_in_communities_directory",
|
||||||
"realm_wildcard_mention_policy",
|
"realm_wildcard_mention_policy",
|
||||||
|
"realm_zulip_update_announcements_stream_id",
|
||||||
"server_avatar_changes_disabled",
|
"server_avatar_changes_disabled",
|
||||||
"server_emoji_data_url",
|
"server_emoji_data_url",
|
||||||
"server_inline_image_preview",
|
"server_inline_image_preview",
|
||||||
|
|
|
@ -13,5 +13,8 @@
|
||||||
{{#if is_signup_announcements_stream}}
|
{{#if is_signup_announcements_stream}}
|
||||||
<li>{{#tr}}New user notifications{{/tr}}</li>
|
<li>{{#tr}}New user notifications{{/tr}}</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#if is_zulip_update_announcements_stream}}
|
||||||
|
<li>{{#tr}}Zulip update announcements{{/tr}}</li>
|
||||||
|
{{/if}}
|
||||||
</ul>
|
</ul>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -26,6 +26,10 @@
|
||||||
label=admin_settings_label.realm_signup_announcements_stream
|
label=admin_settings_label.realm_signup_announcements_stream
|
||||||
value_type="number"}}
|
value_type="number"}}
|
||||||
|
|
||||||
|
{{> ../dropdown_widget_with_label
|
||||||
|
widget_name="realm_zulip_update_announcements_stream_id"
|
||||||
|
label=admin_settings_label.realm_zulip_update_announcements_stream
|
||||||
|
value_type="number"}}
|
||||||
|
|
||||||
{{> settings_checkbox
|
{{> settings_checkbox
|
||||||
setting_name="realm_message_content_allowed_in_email_notifications"
|
setting_name="realm_message_content_allowed_in_email_notifications"
|
||||||
|
|
|
@ -540,6 +540,11 @@ run_test("realm settings", ({override}) => {
|
||||||
assert_same(realm.realm_signup_announcements_stream_id, 41);
|
assert_same(realm.realm_signup_announcements_stream_id, 41);
|
||||||
realm.realm_signup_announcements_stream_id = -1; // make sure to reset for future tests
|
realm.realm_signup_announcements_stream_id = -1; // make sure to reset for future tests
|
||||||
|
|
||||||
|
event = event_fixtures.realm__update__zulip_update_announcements_stream_id;
|
||||||
|
dispatch(event);
|
||||||
|
assert_same(realm.realm_zulip_update_announcements_stream_id, 42);
|
||||||
|
realm.realm_zulip_update_announcements_stream_id = -1; // make sure to reset for future tests
|
||||||
|
|
||||||
event = event_fixtures.realm__update__default_code_block_language;
|
event = event_fixtures.realm__update__default_code_block_language;
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
assert_same(realm.realm_default_code_block_language, "javascript");
|
assert_same(realm.realm_default_code_block_language, "javascript");
|
||||||
|
|
|
@ -243,6 +243,7 @@ test("stream delete (special streams)", ({override}) => {
|
||||||
assert.equal(event.streams.length, 2);
|
assert.equal(event.streams.length, 2);
|
||||||
realm.realm_new_stream_announcements_stream_id = event.streams[0].stream_id;
|
realm.realm_new_stream_announcements_stream_id = event.streams[0].stream_id;
|
||||||
realm.realm_signup_announcements_stream_id = event.streams[1].stream_id;
|
realm.realm_signup_announcements_stream_id = event.streams[1].stream_id;
|
||||||
|
realm.realm_zulip_update_announcements_stream_id = event.streams[0].stream_id;
|
||||||
|
|
||||||
override(stream_settings_ui, "remove_stream", noop);
|
override(stream_settings_ui, "remove_stream", noop);
|
||||||
override(settings_org, "sync_realm_settings", noop);
|
override(settings_org, "sync_realm_settings", noop);
|
||||||
|
@ -255,6 +256,7 @@ test("stream delete (special streams)", ({override}) => {
|
||||||
|
|
||||||
assert.equal(realm.realm_new_stream_announcements_stream_id, -1);
|
assert.equal(realm.realm_new_stream_announcements_stream_id, -1);
|
||||||
assert.equal(realm.realm_signup_announcements_stream_id, -1);
|
assert.equal(realm.realm_signup_announcements_stream_id, -1);
|
||||||
|
assert.equal(realm.realm_zulip_update_announcements_stream_id, -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("stream delete (stream is selected in compose)", ({override, override_rewire}) => {
|
test("stream delete (stream is selected in compose)", ({override, override_rewire}) => {
|
||||||
|
|
|
@ -372,6 +372,13 @@ exports.fixtures = {
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
realm__update__zulip_update_announcements_stream_id: {
|
||||||
|
type: "realm",
|
||||||
|
op: "update",
|
||||||
|
property: "zulip_update_announcements_stream_id",
|
||||||
|
value: 42,
|
||||||
|
},
|
||||||
|
|
||||||
realm__update_dict__default: {
|
realm__update_dict__default: {
|
||||||
type: "realm",
|
type: "realm",
|
||||||
op: "update_dict",
|
op: "update_dict",
|
||||||
|
|
|
@ -278,7 +278,9 @@ def do_create_realm(
|
||||||
stream_description="Everyone is added to this stream by default. Welcome! :octopus:",
|
stream_description="Everyone is added to this stream by default. Welcome! :octopus:",
|
||||||
acting_user=None,
|
acting_user=None,
|
||||||
)
|
)
|
||||||
|
# By default, 'New stream' & 'Zulip update' announcements are sent to the same stream.
|
||||||
realm.new_stream_announcements_stream = new_stream_announcements_stream
|
realm.new_stream_announcements_stream = new_stream_announcements_stream
|
||||||
|
realm.zulip_update_announcements_stream = new_stream_announcements_stream
|
||||||
|
|
||||||
# With the current initial streams situation, the only public
|
# With the current initial streams situation, the only public
|
||||||
# stream is the new_stream_announcements_stream.
|
# stream is the new_stream_announcements_stream.
|
||||||
|
@ -293,7 +295,13 @@ def do_create_realm(
|
||||||
)
|
)
|
||||||
realm.signup_announcements_stream = signup_announcements_stream
|
realm.signup_announcements_stream = signup_announcements_stream
|
||||||
|
|
||||||
realm.save(update_fields=["new_stream_announcements_stream", "signup_announcements_stream"])
|
realm.save(
|
||||||
|
update_fields=[
|
||||||
|
"new_stream_announcements_stream",
|
||||||
|
"signup_announcements_stream",
|
||||||
|
"zulip_update_announcements_stream",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
if plan_type is None and settings.BILLING_ENABLED:
|
if plan_type is None and settings.BILLING_ENABLED:
|
||||||
# We use acting_user=None for setting the initial plan type.
|
# We use acting_user=None for setting the initial plan type.
|
||||||
|
|
|
@ -260,7 +260,11 @@ def do_set_realm_authentication_methods(
|
||||||
|
|
||||||
def do_set_realm_stream(
|
def do_set_realm_stream(
|
||||||
realm: Realm,
|
realm: Realm,
|
||||||
field: Literal["new_stream_announcements_stream", "signup_announcements_stream"],
|
field: Literal[
|
||||||
|
"new_stream_announcements_stream",
|
||||||
|
"signup_announcements_stream",
|
||||||
|
"zulip_update_announcements_stream",
|
||||||
|
],
|
||||||
stream: Optional[Stream],
|
stream: Optional[Stream],
|
||||||
stream_id: int,
|
stream_id: int,
|
||||||
*,
|
*,
|
||||||
|
@ -276,6 +280,10 @@ def do_set_realm_stream(
|
||||||
old_value = realm.signup_announcements_stream_id
|
old_value = realm.signup_announcements_stream_id
|
||||||
realm.signup_announcements_stream = stream
|
realm.signup_announcements_stream = stream
|
||||||
property = "signup_announcements_stream_id"
|
property = "signup_announcements_stream_id"
|
||||||
|
elif field == "zulip_update_announcements_stream":
|
||||||
|
old_value = realm.zulip_update_announcements_stream_id
|
||||||
|
realm.zulip_update_announcements_stream = stream
|
||||||
|
property = "zulip_update_announcements_stream_id"
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Invalid realm stream field.")
|
raise AssertionError("Invalid realm stream field.")
|
||||||
|
|
||||||
|
@ -320,6 +328,14 @@ def do_set_realm_signup_announcements_stream(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def do_set_realm_zulip_update_announcements_stream(
|
||||||
|
realm: Realm, stream: Optional[Stream], stream_id: int, *, acting_user: Optional[UserProfile]
|
||||||
|
) -> None:
|
||||||
|
do_set_realm_stream(
|
||||||
|
realm, "zulip_update_announcements_stream", stream, stream_id, acting_user=acting_user
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def do_set_realm_user_default_setting(
|
def do_set_realm_user_default_setting(
|
||||||
realm_user_default: RealmUserDefault,
|
realm_user_default: RealmUserDefault,
|
||||||
name: str,
|
name: str,
|
||||||
|
|
|
@ -918,7 +918,12 @@ def check_realm_update(
|
||||||
|
|
||||||
assert "extra_data" not in event
|
assert "extra_data" not in event
|
||||||
|
|
||||||
if prop in ["new_stream_announcements_stream_id", "signup_announcements_stream_id", "org_type"]:
|
if prop in [
|
||||||
|
"new_stream_announcements_stream_id",
|
||||||
|
"signup_announcements_stream_id",
|
||||||
|
"zulip_update_announcements_stream_id",
|
||||||
|
"org_type",
|
||||||
|
]:
|
||||||
assert isinstance(value, int)
|
assert isinstance(value, int)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -374,6 +374,14 @@ def fetch_initial_state_data(
|
||||||
else:
|
else:
|
||||||
state["realm_signup_announcements_stream_id"] = -1
|
state["realm_signup_announcements_stream_id"] = -1
|
||||||
|
|
||||||
|
zulip_update_announcements_stream = realm.get_zulip_update_announcements_stream()
|
||||||
|
if zulip_update_announcements_stream:
|
||||||
|
state["realm_zulip_update_announcements_stream_id"] = (
|
||||||
|
zulip_update_announcements_stream.id
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
state["realm_zulip_update_announcements_stream_id"] = -1
|
||||||
|
|
||||||
state["max_stream_name_length"] = Stream.MAX_NAME_LENGTH
|
state["max_stream_name_length"] = Stream.MAX_NAME_LENGTH
|
||||||
state["max_stream_description_length"] = Stream.MAX_DESCRIPTION_LENGTH
|
state["max_stream_description_length"] = Stream.MAX_DESCRIPTION_LENGTH
|
||||||
state["max_topic_length"] = MAX_TOPIC_NAME_LENGTH
|
state["max_topic_length"] = MAX_TOPIC_NAME_LENGTH
|
||||||
|
|
|
@ -957,6 +957,9 @@ def do_import_realm(import_dir: Path, subdomain: str, processes: int = 1) -> Rea
|
||||||
data, "zerver_realm", "new_stream_announcements_stream", related_table="stream"
|
data, "zerver_realm", "new_stream_announcements_stream", related_table="stream"
|
||||||
)
|
)
|
||||||
re_map_foreign_keys(data, "zerver_realm", "signup_announcements_stream", related_table="stream")
|
re_map_foreign_keys(data, "zerver_realm", "signup_announcements_stream", related_table="stream")
|
||||||
|
re_map_foreign_keys(
|
||||||
|
data, "zerver_realm", "zulip_update_announcements_stream", related_table="stream"
|
||||||
|
)
|
||||||
if "zerver_usergroup" in data:
|
if "zerver_usergroup" in data:
|
||||||
update_model_ids(UserGroup, data, "usergroup")
|
update_model_ids(UserGroup, data, "usergroup")
|
||||||
for setting_name in Realm.REALM_PERMISSION_GROUP_SETTINGS:
|
for setting_name in Realm.REALM_PERMISSION_GROUP_SETTINGS:
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
# Generated by Django 4.2.9 on 2024-02-08 07:34
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
||||||
|
from django.db.migrations.state import StateApps
|
||||||
|
from django.db.models import F
|
||||||
|
|
||||||
|
|
||||||
|
def set_initial_value_for_zulip_update_announcements_stream(
|
||||||
|
apps: StateApps, schema_editor: BaseDatabaseSchemaEditor
|
||||||
|
) -> None:
|
||||||
|
Realm = apps.get_model("zerver", "Realm")
|
||||||
|
Realm.objects.exclude(new_stream_announcements_stream__isnull=True).update(
|
||||||
|
zulip_update_announcements_stream=F("new_stream_announcements_stream")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("zerver", "0499_rename_signup_notifications_stream_realm_signup_announcements_stream"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="realm",
|
||||||
|
name="zulip_update_announcements_stream",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.SET_NULL,
|
||||||
|
related_name="+",
|
||||||
|
to="zerver.stream",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.RunPython(
|
||||||
|
set_initial_value_for_zulip_update_announcements_stream,
|
||||||
|
reverse_code=migrations.RunPython.noop,
|
||||||
|
),
|
||||||
|
]
|
|
@ -350,6 +350,15 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ZULIP_UPDATE_ANNOUNCEMENTS_TOPIC_NAME = gettext_lazy("Zulip updates")
|
||||||
|
zulip_update_announcements_stream = models.ForeignKey(
|
||||||
|
"Stream",
|
||||||
|
related_name="+",
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
)
|
||||||
|
|
||||||
MESSAGE_RETENTION_SPECIAL_VALUES_MAP = {
|
MESSAGE_RETENTION_SPECIAL_VALUES_MAP = {
|
||||||
"unlimited": -1,
|
"unlimited": -1,
|
||||||
}
|
}
|
||||||
|
@ -800,6 +809,14 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
|
||||||
return self.signup_announcements_stream
|
return self.signup_announcements_stream
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_zulip_update_announcements_stream(self) -> Optional["Stream"]:
|
||||||
|
if (
|
||||||
|
self.zulip_update_announcements_stream is not None
|
||||||
|
and not self.zulip_update_announcements_stream.deactivated
|
||||||
|
):
|
||||||
|
return self.zulip_update_announcements_stream
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_invites(self) -> int:
|
def max_invites(self) -> int:
|
||||||
if self._max_invites is None:
|
if self._max_invites is None:
|
||||||
|
|
|
@ -4555,6 +4555,18 @@ paths:
|
||||||
|
|
||||||
**Changes**: In Zulip 9.0 (feature level 241), renamed
|
**Changes**: In Zulip 9.0 (feature level 241), renamed
|
||||||
'signup_notifications_stream_id' to `signup_announcements_stream_id`.
|
'signup_notifications_stream_id' to `signup_announcements_stream_id`.
|
||||||
|
zulip_update_announcements_stream_id:
|
||||||
|
type: integer
|
||||||
|
description: |
|
||||||
|
The ID of the stream to which automated messages announcing
|
||||||
|
new features or other end-user updates about the Zulip software are sent.
|
||||||
|
|
||||||
|
Will be `-1` if such automated messages are disabled.
|
||||||
|
|
||||||
|
Since these automated messages are sent by the server, this field is
|
||||||
|
primarily relevant to clients containing UI for changing it.
|
||||||
|
|
||||||
|
**Changes**: New in Zulip 9.0 (feature level 242).
|
||||||
user_group_edit_policy:
|
user_group_edit_policy:
|
||||||
type: integer
|
type: integer
|
||||||
description: |
|
description: |
|
||||||
|
@ -15154,6 +15166,20 @@ paths:
|
||||||
|
|
||||||
**Changes**: In Zulip 9.0 (feature level 241), renamed
|
**Changes**: In Zulip 9.0 (feature level 241), renamed
|
||||||
'realm_signup_notifications_stream_id' to `realm_signup_announcements_stream_id`.
|
'realm_signup_notifications_stream_id' to `realm_signup_announcements_stream_id`.
|
||||||
|
realm_zulip_update_announcements_stream_id:
|
||||||
|
type: integer
|
||||||
|
description: |
|
||||||
|
Present if `realm` is present in `fetch_event_types`.
|
||||||
|
|
||||||
|
The ID of the stream to which automated messages announcing
|
||||||
|
new features or other end-user updates about the Zulip software are sent.
|
||||||
|
|
||||||
|
Will be `-1` if such automated messages are disabled.
|
||||||
|
|
||||||
|
Since these automated messages are sent by the server, this field is
|
||||||
|
primarily relevant to clients containing UI for changing it.
|
||||||
|
|
||||||
|
**Changes**: New in Zulip 9.0 (feature level 242).
|
||||||
realm_user_settings_defaults:
|
realm_user_settings_defaults:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
|
|
|
@ -37,6 +37,7 @@ from zerver.actions.realm_settings import (
|
||||||
do_set_realm_new_stream_announcements_stream,
|
do_set_realm_new_stream_announcements_stream,
|
||||||
do_set_realm_property,
|
do_set_realm_property,
|
||||||
do_set_realm_signup_announcements_stream,
|
do_set_realm_signup_announcements_stream,
|
||||||
|
do_set_realm_zulip_update_announcements_stream,
|
||||||
)
|
)
|
||||||
from zerver.actions.streams import (
|
from zerver.actions.streams import (
|
||||||
bulk_add_subscriptions,
|
bulk_add_subscriptions,
|
||||||
|
@ -604,6 +605,30 @@ class TestRealmAuditLog(ZulipTestCase):
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_set_realm_zulip_update_announcements_stream(self) -> None:
|
||||||
|
now = timezone_now()
|
||||||
|
realm = get_realm("zulip")
|
||||||
|
user = self.example_user("hamlet")
|
||||||
|
old_value = realm.zulip_update_announcements_stream_id
|
||||||
|
stream_name = "test"
|
||||||
|
stream = self.make_stream(stream_name, realm)
|
||||||
|
|
||||||
|
do_set_realm_zulip_update_announcements_stream(realm, stream, stream.id, acting_user=user)
|
||||||
|
self.assertEqual(
|
||||||
|
RealmAuditLog.objects.filter(
|
||||||
|
realm=realm,
|
||||||
|
event_type=RealmAuditLog.REALM_PROPERTY_CHANGED,
|
||||||
|
event_time__gte=now,
|
||||||
|
acting_user=user,
|
||||||
|
extra_data={
|
||||||
|
RealmAuditLog.OLD_VALUE: old_value,
|
||||||
|
RealmAuditLog.NEW_VALUE: stream.id,
|
||||||
|
"property": "zulip_update_announcements_stream",
|
||||||
|
},
|
||||||
|
).count(),
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
|
||||||
def test_change_icon_source(self) -> None:
|
def test_change_icon_source(self) -> None:
|
||||||
test_start = timezone_now()
|
test_start = timezone_now()
|
||||||
realm = get_realm("zulip")
|
realm = get_realm("zulip")
|
||||||
|
|
|
@ -1154,7 +1154,7 @@ class FetchQueriesTest(ZulipTestCase):
|
||||||
|
|
||||||
self.login_user(user)
|
self.login_user(user)
|
||||||
|
|
||||||
with self.assert_database_query_count(40):
|
with self.assert_database_query_count(41):
|
||||||
with mock.patch("zerver.lib.events.always_want") as want_mock:
|
with mock.patch("zerver.lib.events.always_want") as want_mock:
|
||||||
fetch_initial_state_data(user)
|
fetch_initial_state_data(user)
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ from zerver.actions.realm_settings import (
|
||||||
do_set_realm_property,
|
do_set_realm_property,
|
||||||
do_set_realm_signup_announcements_stream,
|
do_set_realm_signup_announcements_stream,
|
||||||
do_set_realm_user_default_setting,
|
do_set_realm_user_default_setting,
|
||||||
|
do_set_realm_zulip_update_announcements_stream,
|
||||||
)
|
)
|
||||||
from zerver.actions.scheduled_messages import (
|
from zerver.actions.scheduled_messages import (
|
||||||
check_schedule_message,
|
check_schedule_message,
|
||||||
|
@ -2325,6 +2326,24 @@ class NormalActionsTest(BaseAction):
|
||||||
)
|
)
|
||||||
check_realm_update("events[0]", events[0], "signup_announcements_stream_id")
|
check_realm_update("events[0]", events[0], "signup_announcements_stream_id")
|
||||||
|
|
||||||
|
def test_change_realm_zulip_update_announcements_stream(self) -> None:
|
||||||
|
stream = get_stream("Rome", self.user_profile.realm)
|
||||||
|
|
||||||
|
for zulip_update_announcements_stream, zulip_update_announcements_stream_id in (
|
||||||
|
(stream, stream.id),
|
||||||
|
(None, -1),
|
||||||
|
):
|
||||||
|
events = self.verify_action(
|
||||||
|
partial(
|
||||||
|
do_set_realm_zulip_update_announcements_stream,
|
||||||
|
self.user_profile.realm,
|
||||||
|
zulip_update_announcements_stream,
|
||||||
|
zulip_update_announcements_stream_id,
|
||||||
|
acting_user=None,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
check_realm_update("events[0]", events[0], "zulip_update_announcements_stream_id")
|
||||||
|
|
||||||
def test_change_is_admin(self) -> None:
|
def test_change_is_admin(self) -> None:
|
||||||
reset_email_visibility_to_everyone_in_zulip_realm()
|
reset_email_visibility_to_everyone_in_zulip_realm()
|
||||||
|
|
||||||
|
|
|
@ -199,6 +199,7 @@ class HomeTest(ZulipTestCase):
|
||||||
"realm_waiting_period_threshold",
|
"realm_waiting_period_threshold",
|
||||||
"realm_want_advertise_in_communities_directory",
|
"realm_want_advertise_in_communities_directory",
|
||||||
"realm_wildcard_mention_policy",
|
"realm_wildcard_mention_policy",
|
||||||
|
"realm_zulip_update_announcements_stream_id",
|
||||||
"recent_private_conversations",
|
"recent_private_conversations",
|
||||||
"scheduled_messages",
|
"scheduled_messages",
|
||||||
"server_avatar_changes_disabled",
|
"server_avatar_changes_disabled",
|
||||||
|
@ -254,7 +255,7 @@ class HomeTest(ZulipTestCase):
|
||||||
self.client_post("/json/bots", bot_info)
|
self.client_post("/json/bots", bot_info)
|
||||||
|
|
||||||
# Verify succeeds once logged-in
|
# Verify succeeds once logged-in
|
||||||
with self.assert_database_query_count(50):
|
with self.assert_database_query_count(51):
|
||||||
with patch("zerver.lib.cache.cache_set") as cache_mock:
|
with patch("zerver.lib.cache.cache_set") as cache_mock:
|
||||||
result = self._get_home_page(stream="Denmark")
|
result = self._get_home_page(stream="Denmark")
|
||||||
self.check_rendered_logged_in_app(result)
|
self.check_rendered_logged_in_app(result)
|
||||||
|
@ -437,7 +438,7 @@ class HomeTest(ZulipTestCase):
|
||||||
def test_num_queries_for_realm_admin(self) -> None:
|
def test_num_queries_for_realm_admin(self) -> None:
|
||||||
# Verify number of queries for Realm admin isn't much higher than for normal users.
|
# Verify number of queries for Realm admin isn't much higher than for normal users.
|
||||||
self.login("iago")
|
self.login("iago")
|
||||||
with self.assert_database_query_count(50):
|
with self.assert_database_query_count(51):
|
||||||
with patch("zerver.lib.cache.cache_set") as cache_mock:
|
with patch("zerver.lib.cache.cache_set") as cache_mock:
|
||||||
result = self._get_home_page()
|
result = self._get_home_page()
|
||||||
self.check_rendered_logged_in_app(result)
|
self.check_rendered_logged_in_app(result)
|
||||||
|
@ -468,7 +469,7 @@ class HomeTest(ZulipTestCase):
|
||||||
self._get_home_page()
|
self._get_home_page()
|
||||||
|
|
||||||
# Then for the second page load, measure the number of queries.
|
# Then for the second page load, measure the number of queries.
|
||||||
with self.assert_database_query_count(45):
|
with self.assert_database_query_count(46):
|
||||||
result = self._get_home_page()
|
result = self._get_home_page()
|
||||||
|
|
||||||
# Do a sanity check that our new streams were in the payload.
|
# Do a sanity check that our new streams were in the payload.
|
||||||
|
@ -673,6 +674,18 @@ class HomeTest(ZulipTestCase):
|
||||||
get_stream("Denmark", realm).id,
|
get_stream("Denmark", realm).id,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_zulip_update_announcements_stream(self) -> None:
|
||||||
|
realm = get_realm("zulip")
|
||||||
|
realm.zulip_update_announcements_stream = get_stream("Denmark", realm)
|
||||||
|
realm.save()
|
||||||
|
self.login("hamlet")
|
||||||
|
result = self._get_home_page()
|
||||||
|
page_params = self._get_page_params(result)
|
||||||
|
self.assertEqual(
|
||||||
|
page_params["state_data"]["realm_zulip_update_announcements_stream_id"],
|
||||||
|
get_stream("Denmark", realm).id,
|
||||||
|
)
|
||||||
|
|
||||||
def test_people(self) -> None:
|
def test_people(self) -> None:
|
||||||
hamlet = self.example_user("hamlet")
|
hamlet = self.example_user("hamlet")
|
||||||
realm = get_realm("zulip")
|
realm = get_realm("zulip")
|
||||||
|
|
|
@ -619,6 +619,80 @@ class RealmTest(ZulipTestCase):
|
||||||
do_deactivate_stream(signup_announcements_stream, acting_user=None)
|
do_deactivate_stream(signup_announcements_stream, acting_user=None)
|
||||||
self.assertIsNone(realm.get_signup_announcements_stream())
|
self.assertIsNone(realm.get_signup_announcements_stream())
|
||||||
|
|
||||||
|
def test_change_zulip_update_announcements_stream(self) -> None:
|
||||||
|
# We need an admin user.
|
||||||
|
self.login("iago")
|
||||||
|
|
||||||
|
disabled_zulip_update_announcements_stream_id = -1
|
||||||
|
req = dict(
|
||||||
|
zulip_update_announcements_stream_id=orjson.dumps(
|
||||||
|
disabled_zulip_update_announcements_stream_id
|
||||||
|
).decode()
|
||||||
|
)
|
||||||
|
result = self.client_patch("/json/realm", req)
|
||||||
|
self.assert_json_success(result)
|
||||||
|
realm = get_realm("zulip")
|
||||||
|
self.assertEqual(realm.zulip_update_announcements_stream, None)
|
||||||
|
|
||||||
|
new_zulip_update_announcements_stream_id = Stream.objects.get(name="Denmark").id
|
||||||
|
req = dict(
|
||||||
|
zulip_update_announcements_stream_id=orjson.dumps(
|
||||||
|
new_zulip_update_announcements_stream_id
|
||||||
|
).decode()
|
||||||
|
)
|
||||||
|
|
||||||
|
result = self.client_patch("/json/realm", req)
|
||||||
|
self.assert_json_success(result)
|
||||||
|
realm = get_realm("zulip")
|
||||||
|
assert realm.zulip_update_announcements_stream is not None
|
||||||
|
self.assertEqual(
|
||||||
|
realm.zulip_update_announcements_stream.id, new_zulip_update_announcements_stream_id
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test that admin can set the setting to an unsubscribed private stream as well.
|
||||||
|
new_zulip_update_announcements_stream_id = self.make_stream(
|
||||||
|
"private_stream", invite_only=True
|
||||||
|
).id
|
||||||
|
req = dict(
|
||||||
|
zulip_update_announcements_stream_id=orjson.dumps(
|
||||||
|
new_zulip_update_announcements_stream_id
|
||||||
|
).decode()
|
||||||
|
)
|
||||||
|
|
||||||
|
result = self.client_patch("/json/realm", req)
|
||||||
|
self.assert_json_success(result)
|
||||||
|
realm = get_realm("zulip")
|
||||||
|
assert realm.zulip_update_announcements_stream is not None
|
||||||
|
self.assertEqual(
|
||||||
|
realm.zulip_update_announcements_stream.id, new_zulip_update_announcements_stream_id
|
||||||
|
)
|
||||||
|
|
||||||
|
invalid_zulip_update_announcements_stream_id = 1234
|
||||||
|
req = dict(
|
||||||
|
zulip_update_announcements_stream_id=orjson.dumps(
|
||||||
|
invalid_zulip_update_announcements_stream_id
|
||||||
|
).decode()
|
||||||
|
)
|
||||||
|
result = self.client_patch("/json/realm", req)
|
||||||
|
self.assert_json_error(result, "Invalid stream ID")
|
||||||
|
realm = get_realm("zulip")
|
||||||
|
assert realm.zulip_update_announcements_stream is not None
|
||||||
|
self.assertNotEqual(
|
||||||
|
realm.zulip_update_announcements_stream.id, invalid_zulip_update_announcements_stream_id
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_get_default_zulip_update_announcements_stream(self) -> None:
|
||||||
|
realm = get_realm("zulip")
|
||||||
|
verona = get_stream("verona", realm)
|
||||||
|
realm.zulip_update_announcements_stream = verona
|
||||||
|
realm.save(update_fields=["zulip_update_announcements_stream"])
|
||||||
|
|
||||||
|
zulip_update_announcements_stream = realm.get_zulip_update_announcements_stream()
|
||||||
|
assert zulip_update_announcements_stream is not None
|
||||||
|
self.assertEqual(zulip_update_announcements_stream, verona)
|
||||||
|
do_deactivate_stream(zulip_update_announcements_stream, acting_user=None)
|
||||||
|
self.assertIsNone(realm.get_zulip_update_announcements_stream())
|
||||||
|
|
||||||
def test_change_realm_default_language(self) -> None:
|
def test_change_realm_default_language(self) -> None:
|
||||||
# we need an admin user.
|
# we need an admin user.
|
||||||
self.login("iago")
|
self.login("iago")
|
||||||
|
|
|
@ -18,6 +18,7 @@ from zerver.actions.realm_settings import (
|
||||||
do_set_realm_property,
|
do_set_realm_property,
|
||||||
do_set_realm_signup_announcements_stream,
|
do_set_realm_signup_announcements_stream,
|
||||||
do_set_realm_user_default_setting,
|
do_set_realm_user_default_setting,
|
||||||
|
do_set_realm_zulip_update_announcements_stream,
|
||||||
parse_and_set_setting_value_if_required,
|
parse_and_set_setting_value_if_required,
|
||||||
validate_authentication_methods_dict_from_api,
|
validate_authentication_methods_dict_from_api,
|
||||||
)
|
)
|
||||||
|
@ -112,6 +113,9 @@ def update_realm(
|
||||||
# are not offered here as it is maintained by the server, not via the API.
|
# are not offered here as it is maintained by the server, not via the API.
|
||||||
new_stream_announcements_stream_id: Optional[int] = REQ(json_validator=check_int, default=None),
|
new_stream_announcements_stream_id: Optional[int] = REQ(json_validator=check_int, default=None),
|
||||||
signup_announcements_stream_id: Optional[int] = REQ(json_validator=check_int, default=None),
|
signup_announcements_stream_id: Optional[int] = REQ(json_validator=check_int, default=None),
|
||||||
|
zulip_update_announcements_stream_id: Optional[int] = REQ(
|
||||||
|
json_validator=check_int, default=None
|
||||||
|
),
|
||||||
message_retention_days_raw: Optional[Union[int, str]] = REQ(
|
message_retention_days_raw: Optional[Union[int, str]] = REQ(
|
||||||
"message_retention_days", json_validator=check_string_or_int, default=None
|
"message_retention_days", json_validator=check_string_or_int, default=None
|
||||||
),
|
),
|
||||||
|
@ -389,8 +393,9 @@ def update_realm(
|
||||||
do_set_realm_authentication_methods(realm, authentication_methods, acting_user=user_profile)
|
do_set_realm_authentication_methods(realm, authentication_methods, acting_user=user_profile)
|
||||||
data["authentication_methods"] = authentication_methods
|
data["authentication_methods"] = authentication_methods
|
||||||
|
|
||||||
# Realm.new_stream_announcements_stream and Realm.signup_announcements_stream are not boolean,
|
# Realm.new_stream_announcements_stream, Realm.signup_announcements_stream,
|
||||||
# str or integer field, and thus doesn't fit into the do_set_realm_property framework.
|
# and Realm.zulip_update_announcements_stream are not boolean, str or integer field,
|
||||||
|
# and thus doesn't fit into the do_set_realm_property framework.
|
||||||
if new_stream_announcements_stream_id is not None and (
|
if new_stream_announcements_stream_id is not None and (
|
||||||
realm.new_stream_announcements_stream is None
|
realm.new_stream_announcements_stream is None
|
||||||
or (realm.new_stream_announcements_stream.id != new_stream_announcements_stream_id)
|
or (realm.new_stream_announcements_stream.id != new_stream_announcements_stream_id)
|
||||||
|
@ -425,6 +430,23 @@ def update_realm(
|
||||||
)
|
)
|
||||||
data["signup_announcements_stream_id"] = signup_announcements_stream_id
|
data["signup_announcements_stream_id"] = signup_announcements_stream_id
|
||||||
|
|
||||||
|
if zulip_update_announcements_stream_id is not None and (
|
||||||
|
realm.zulip_update_announcements_stream is None
|
||||||
|
or realm.zulip_update_announcements_stream.id != zulip_update_announcements_stream_id
|
||||||
|
):
|
||||||
|
new_zulip_update_announcements_stream = None
|
||||||
|
if zulip_update_announcements_stream_id >= 0:
|
||||||
|
(new_zulip_update_announcements_stream, sub) = access_stream_by_id(
|
||||||
|
user_profile, zulip_update_announcements_stream_id, allow_realm_admin=True
|
||||||
|
)
|
||||||
|
do_set_realm_zulip_update_announcements_stream(
|
||||||
|
realm,
|
||||||
|
new_zulip_update_announcements_stream,
|
||||||
|
zulip_update_announcements_stream_id,
|
||||||
|
acting_user=user_profile,
|
||||||
|
)
|
||||||
|
data["zulip_update_announcements_stream_id"] = zulip_update_announcements_stream_id
|
||||||
|
|
||||||
if string_id is not None:
|
if string_id is not None:
|
||||||
if not user_profile.is_realm_owner:
|
if not user_profile.is_realm_owner:
|
||||||
raise OrganizationOwnerRequiredError
|
raise OrganizationOwnerRequiredError
|
||||||
|
|
|
@ -1028,8 +1028,16 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
bulk_create_streams(zulip_realm, zulip_stream_dict)
|
bulk_create_streams(zulip_realm, zulip_stream_dict)
|
||||||
# Now that we've created the new_stream_announcements_stream, configure it properly.
|
# Now that we've created the new_stream_announcements_stream, configure it properly.
|
||||||
zulip_realm.new_stream_announcements_stream = get_stream("announce", zulip_realm)
|
# By default, 'New stream' & 'Zulip update' announcements are sent to the same stream.
|
||||||
zulip_realm.save(update_fields=["new_stream_announcements_stream"])
|
announce_stream = get_stream("announce", zulip_realm)
|
||||||
|
zulip_realm.new_stream_announcements_stream = announce_stream
|
||||||
|
zulip_realm.zulip_update_announcements_stream = announce_stream
|
||||||
|
zulip_realm.save(
|
||||||
|
update_fields=[
|
||||||
|
"new_stream_announcements_stream",
|
||||||
|
"zulip_update_announcements_stream",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
# Add a few default streams
|
# Add a few default streams
|
||||||
for default_stream_name in ["design", "devel", "social", "support"]:
|
for default_stream_name in ["design", "devel", "social", "support"]:
|
||||||
|
|
Loading…
Reference in New Issue