mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 18:06:44 +00:00
stream_data: Move stream_*_policy_values to settings_config.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
0f0fd3f07d
commit
d17c0dabc8
@@ -4,6 +4,7 @@ import {$t, $t_html} from "./i18n";
|
|||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import type {RealmDefaultSettings} from "./realm_user_settings_defaults";
|
import type {RealmDefaultSettings} from "./realm_user_settings_defaults";
|
||||||
import type {StreamSpecificNotificationSettings} from "./sub_store";
|
import type {StreamSpecificNotificationSettings} from "./sub_store";
|
||||||
|
import {StreamPostPolicy} from "./sub_store";
|
||||||
import type {
|
import type {
|
||||||
FollowedTopicNotificationSettings,
|
FollowedTopicNotificationSettings,
|
||||||
PmNotificationSettings,
|
PmNotificationSettings,
|
||||||
@@ -949,3 +950,61 @@ export const automatically_follow_or_unmute_topics_policy_values = {
|
|||||||
description: $t({defaultMessage: "Never"}),
|
description: $t({defaultMessage: "Never"}),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const stream_privacy_policy_values = {
|
||||||
|
web_public: {
|
||||||
|
code: "web-public",
|
||||||
|
name: $t({defaultMessage: "Web-public"}),
|
||||||
|
description: $t({
|
||||||
|
defaultMessage:
|
||||||
|
"Organization members can join (guests must be invited by a subscriber); anyone on the Internet can view complete message history without creating an account",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
public: {
|
||||||
|
code: "public",
|
||||||
|
name: $t({defaultMessage: "Public"}),
|
||||||
|
description: $t({
|
||||||
|
defaultMessage:
|
||||||
|
"Organization members can join (guests must be invited by a subscriber); organization members can view complete message history without joining",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
private_with_public_history: {
|
||||||
|
code: "invite-only-public-history",
|
||||||
|
name: $t({defaultMessage: "Private, shared history"}),
|
||||||
|
description: $t({
|
||||||
|
defaultMessage:
|
||||||
|
"Must be invited by a subscriber; new subscribers can view complete message history; hidden from non-administrator users",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
private: {
|
||||||
|
code: "invite-only",
|
||||||
|
name: $t({defaultMessage: "Private, protected history"}),
|
||||||
|
description: $t({
|
||||||
|
defaultMessage:
|
||||||
|
"Must be invited by a subscriber; new subscribers can only see messages sent after they join; hidden from non-administrator users",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const stream_post_policy_values = {
|
||||||
|
// These strings should match the strings in the
|
||||||
|
// Stream.POST_POLICIES object in zerver/models.py.
|
||||||
|
everyone: {
|
||||||
|
code: StreamPostPolicy.EVERYONE,
|
||||||
|
description: $t({defaultMessage: "Everyone"}),
|
||||||
|
},
|
||||||
|
non_new_members: {
|
||||||
|
code: StreamPostPolicy.RESTRICT_NEW_MEMBERS,
|
||||||
|
description: $t({defaultMessage: "Admins, moderators and full members"}),
|
||||||
|
},
|
||||||
|
moderators: {
|
||||||
|
code: StreamPostPolicy.MODERATORS,
|
||||||
|
description: $t({
|
||||||
|
defaultMessage: "Admins and moderators",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
admins: {
|
||||||
|
code: StreamPostPolicy.ADMINS,
|
||||||
|
description: $t({defaultMessage: "Admins only"}),
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
import * as blueslip from "./blueslip";
|
import * as blueslip from "./blueslip";
|
||||||
import * as color_data from "./color_data";
|
import * as color_data from "./color_data";
|
||||||
import {FoldDict} from "./fold_dict";
|
import {FoldDict} from "./fold_dict";
|
||||||
import {$t} from "./i18n";
|
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as peer_data from "./peer_data";
|
import * as peer_data from "./peer_data";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as settings_config from "./settings_config";
|
import * as settings_config from "./settings_config";
|
||||||
import * as settings_data from "./settings_data";
|
import * as settings_data from "./settings_data";
|
||||||
import * as sub_store from "./sub_store";
|
import * as sub_store from "./sub_store";
|
||||||
import {StreamPostPolicy} from "./sub_store";
|
|
||||||
import type {
|
import type {
|
||||||
ApiStreamSubscription,
|
ApiStreamSubscription,
|
||||||
NeverSubscribedStream,
|
NeverSubscribedStream,
|
||||||
Stream,
|
Stream,
|
||||||
|
StreamPostPolicy,
|
||||||
StreamSpecificNotificationSettings,
|
StreamSpecificNotificationSettings,
|
||||||
StreamSubscription,
|
StreamSubscription,
|
||||||
} from "./sub_store";
|
} from "./sub_store";
|
||||||
@@ -129,64 +128,6 @@ const stream_ids_by_name = new FoldDict<number>();
|
|||||||
const stream_ids_by_old_names = new FoldDict<number>();
|
const stream_ids_by_old_names = new FoldDict<number>();
|
||||||
const default_stream_ids = new Set<number>();
|
const default_stream_ids = new Set<number>();
|
||||||
|
|
||||||
export const stream_privacy_policy_values = {
|
|
||||||
web_public: {
|
|
||||||
code: "web-public",
|
|
||||||
name: $t({defaultMessage: "Web-public"}),
|
|
||||||
description: $t({
|
|
||||||
defaultMessage:
|
|
||||||
"Organization members can join (guests must be invited by a subscriber); anyone on the Internet can view complete message history without creating an account",
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
public: {
|
|
||||||
code: "public",
|
|
||||||
name: $t({defaultMessage: "Public"}),
|
|
||||||
description: $t({
|
|
||||||
defaultMessage:
|
|
||||||
"Organization members can join (guests must be invited by a subscriber); organization members can view complete message history without joining",
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
private_with_public_history: {
|
|
||||||
code: "invite-only-public-history",
|
|
||||||
name: $t({defaultMessage: "Private, shared history"}),
|
|
||||||
description: $t({
|
|
||||||
defaultMessage:
|
|
||||||
"Must be invited by a subscriber; new subscribers can view complete message history; hidden from non-administrator users",
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
private: {
|
|
||||||
code: "invite-only",
|
|
||||||
name: $t({defaultMessage: "Private, protected history"}),
|
|
||||||
description: $t({
|
|
||||||
defaultMessage:
|
|
||||||
"Must be invited by a subscriber; new subscribers can only see messages sent after they join; hidden from non-administrator users",
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export const stream_post_policy_values = {
|
|
||||||
// These strings should match the strings in the
|
|
||||||
// Stream.POST_POLICIES object in zerver/models.py.
|
|
||||||
everyone: {
|
|
||||||
code: StreamPostPolicy.EVERYONE,
|
|
||||||
description: $t({defaultMessage: "Everyone"}),
|
|
||||||
},
|
|
||||||
non_new_members: {
|
|
||||||
code: StreamPostPolicy.RESTRICT_NEW_MEMBERS,
|
|
||||||
description: $t({defaultMessage: "Admins, moderators and full members"}),
|
|
||||||
},
|
|
||||||
moderators: {
|
|
||||||
code: StreamPostPolicy.MODERATORS,
|
|
||||||
description: $t({
|
|
||||||
defaultMessage: "Admins and moderators",
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
admins: {
|
|
||||||
code: StreamPostPolicy.ADMINS,
|
|
||||||
description: $t({defaultMessage: "Admins only"}),
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
export function clear_subscriptions(): void {
|
export function clear_subscriptions(): void {
|
||||||
// This function is only used once at page load, and then
|
// This function is only used once at page load, and then
|
||||||
// it should only be used in tests.
|
// it should only be used in tests.
|
||||||
@@ -630,7 +571,7 @@ export function can_post_messages_in_stream(stream: StreamSubscription): boolean
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream.stream_post_policy === stream_post_policy_values.admins.code) {
|
if (stream.stream_post_policy === settings_config.stream_post_policy_values.admins.code) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -638,13 +579,13 @@ export function can_post_messages_in_stream(stream: StreamSubscription): boolean
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream.stream_post_policy === stream_post_policy_values.moderators.code) {
|
if (stream.stream_post_policy === settings_config.stream_post_policy_values.moderators.code) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
page_params.is_guest &&
|
page_params.is_guest &&
|
||||||
stream.stream_post_policy !== stream_post_policy_values.everyone.code
|
stream.stream_post_policy !== settings_config.stream_post_policy_values.everyone.code
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -654,7 +595,8 @@ export function can_post_messages_in_stream(stream: StreamSubscription): boolean
|
|||||||
const person_date_joined = new Date(person.date_joined).getTime();
|
const person_date_joined = new Date(person.date_joined).getTime();
|
||||||
const days = (current_datetime - person_date_joined) / 1000 / 86400;
|
const days = (current_datetime - person_date_joined) / 1000 / 86400;
|
||||||
if (
|
if (
|
||||||
stream.stream_post_policy === stream_post_policy_values.non_new_members.code &&
|
stream.stream_post_policy ===
|
||||||
|
settings_config.stream_post_policy_values.non_new_members.code &&
|
||||||
days < page_params.realm_waiting_period_threshold
|
days < page_params.realm_waiting_period_threshold
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
@@ -676,15 +618,15 @@ export function get_stream_privacy_policy(stream_id: number): string {
|
|||||||
const sub = sub_store.get(stream_id)!;
|
const sub = sub_store.get(stream_id)!;
|
||||||
|
|
||||||
if (sub.is_web_public) {
|
if (sub.is_web_public) {
|
||||||
return stream_privacy_policy_values.web_public.code;
|
return settings_config.stream_privacy_policy_values.web_public.code;
|
||||||
}
|
}
|
||||||
if (!sub.invite_only) {
|
if (!sub.invite_only) {
|
||||||
return stream_privacy_policy_values.public.code;
|
return settings_config.stream_privacy_policy_values.public.code;
|
||||||
}
|
}
|
||||||
if (sub.invite_only && !sub.history_public_to_subscribers) {
|
if (sub.invite_only && !sub.history_public_to_subscribers) {
|
||||||
return stream_privacy_policy_values.private.code;
|
return settings_config.stream_privacy_policy_values.private.code;
|
||||||
}
|
}
|
||||||
return stream_privacy_policy_values.private_with_public_history.code;
|
return settings_config.stream_privacy_policy_values.private_with_public_history.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function is_web_public(stream_id: number): boolean {
|
export function is_web_public(stream_id: number): boolean {
|
||||||
|
|||||||
@@ -244,8 +244,8 @@ export function show_settings_for(node) {
|
|||||||
sub,
|
sub,
|
||||||
notification_settings,
|
notification_settings,
|
||||||
other_settings,
|
other_settings,
|
||||||
stream_post_policy_values: stream_data.stream_post_policy_values,
|
stream_post_policy_values: settings_config.stream_post_policy_values,
|
||||||
stream_privacy_policy_values: stream_data.stream_privacy_policy_values,
|
stream_privacy_policy_values: settings_config.stream_privacy_policy_values,
|
||||||
stream_privacy_policy: stream_data.get_stream_privacy_policy(stream_id),
|
stream_privacy_policy: stream_data.get_stream_privacy_policy(stream_id),
|
||||||
check_default_stream: stream_data.is_default_stream_id(stream_id),
|
check_default_stream: stream_data.is_default_stream_id(stream_id),
|
||||||
zulip_plan_is_not_limited: page_params.zulip_plan_is_not_limited,
|
zulip_plan_is_not_limited: page_params.zulip_plan_is_not_limited,
|
||||||
@@ -341,21 +341,21 @@ export function stream_setting_changed(e, from_notification_settings) {
|
|||||||
|
|
||||||
export function get_request_data_for_stream_privacy(selected_val) {
|
export function get_request_data_for_stream_privacy(selected_val) {
|
||||||
switch (selected_val) {
|
switch (selected_val) {
|
||||||
case stream_data.stream_privacy_policy_values.public.code: {
|
case settings_config.stream_privacy_policy_values.public.code: {
|
||||||
return {
|
return {
|
||||||
is_private: false,
|
is_private: false,
|
||||||
history_public_to_subscribers: true,
|
history_public_to_subscribers: true,
|
||||||
is_web_public: false,
|
is_web_public: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case stream_data.stream_privacy_policy_values.private.code: {
|
case settings_config.stream_privacy_policy_values.private.code: {
|
||||||
return {
|
return {
|
||||||
is_private: true,
|
is_private: true,
|
||||||
history_public_to_subscribers: false,
|
history_public_to_subscribers: false,
|
||||||
is_web_public: false,
|
is_web_public: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case stream_data.stream_privacy_policy_values.web_public.code: {
|
case settings_config.stream_privacy_policy_values.web_public.code: {
|
||||||
return {
|
return {
|
||||||
is_private: false,
|
is_private: false,
|
||||||
history_public_to_subscribers: true,
|
history_public_to_subscribers: true,
|
||||||
|
|||||||
@@ -695,7 +695,7 @@ export function setup_page(callback) {
|
|||||||
|
|
||||||
// TODO: Ideally we'd indicate in some way what stream types
|
// TODO: Ideally we'd indicate in some way what stream types
|
||||||
// the user can create, by showing other options as disabled.
|
// the user can create, by showing other options as disabled.
|
||||||
const stream_privacy_policy = stream_data.stream_privacy_policy_values.public.code;
|
const stream_privacy_policy = settings_config.stream_privacy_policy_values.public.code;
|
||||||
const notifications_stream = stream_data.get_notifications_stream();
|
const notifications_stream = stream_data.get_notifications_stream();
|
||||||
const notifications_stream_sub = stream_data.get_sub_by_name(notifications_stream);
|
const notifications_stream_sub = stream_data.get_sub_by_name(notifications_stream);
|
||||||
|
|
||||||
@@ -710,9 +710,9 @@ export function setup_page(callback) {
|
|||||||
max_stream_name_length: page_params.max_stream_name_length,
|
max_stream_name_length: page_params.max_stream_name_length,
|
||||||
max_stream_description_length: page_params.max_stream_description_length,
|
max_stream_description_length: page_params.max_stream_description_length,
|
||||||
is_owner: page_params.is_owner,
|
is_owner: page_params.is_owner,
|
||||||
stream_privacy_policy_values: stream_data.stream_privacy_policy_values,
|
stream_privacy_policy_values: settings_config.stream_privacy_policy_values,
|
||||||
stream_privacy_policy,
|
stream_privacy_policy,
|
||||||
stream_post_policy_values: stream_data.stream_post_policy_values,
|
stream_post_policy_values: settings_config.stream_post_policy_values,
|
||||||
check_default_stream: false,
|
check_default_stream: false,
|
||||||
zulip_plan_is_not_limited: page_params.zulip_plan_is_not_limited,
|
zulip_plan_is_not_limited: page_params.zulip_plan_is_not_limited,
|
||||||
org_level_message_retention_setting:
|
org_level_message_retention_setting:
|
||||||
@@ -1106,7 +1106,9 @@ export function sub_or_unsub(sub, $stream_row) {
|
|||||||
|
|
||||||
export function update_web_public_stream_privacy_option_state($container) {
|
export function update_web_public_stream_privacy_option_state($container) {
|
||||||
const $web_public_stream_elem = $container.find(
|
const $web_public_stream_elem = $container.find(
|
||||||
`input[value='${CSS.escape(stream_data.stream_privacy_policy_values.web_public.code)}']`,
|
`input[value='${CSS.escape(
|
||||||
|
settings_config.stream_privacy_policy_values.web_public.code,
|
||||||
|
)}']`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const for_stream_edit_panel = $container.attr("id") === "stream_permission_settings";
|
const for_stream_edit_panel = $container.attr("id") === "stream_permission_settings";
|
||||||
@@ -1156,7 +1158,7 @@ export function update_web_public_stream_privacy_option_state($container) {
|
|||||||
|
|
||||||
export function update_public_stream_privacy_option_state($container) {
|
export function update_public_stream_privacy_option_state($container) {
|
||||||
const $public_stream_elem = $container.find(
|
const $public_stream_elem = $container.find(
|
||||||
`input[value='${CSS.escape(stream_data.stream_privacy_policy_values.public.code)}']`,
|
`input[value='${CSS.escape(settings_config.stream_privacy_policy_values.public.code)}']`,
|
||||||
);
|
);
|
||||||
$public_stream_elem.prop("disabled", !settings_data.user_can_create_public_streams());
|
$public_stream_elem.prop("disabled", !settings_data.user_can_create_public_streams());
|
||||||
}
|
}
|
||||||
@@ -1164,11 +1166,11 @@ export function update_public_stream_privacy_option_state($container) {
|
|||||||
export function update_private_stream_privacy_option_state($container, is_default_stream = false) {
|
export function update_private_stream_privacy_option_state($container, is_default_stream = false) {
|
||||||
// Disable both "Private, shared history" and "Private, protected history" options.
|
// Disable both "Private, shared history" and "Private, protected history" options.
|
||||||
const $private_stream_elem = $container.find(
|
const $private_stream_elem = $container.find(
|
||||||
`input[value='${CSS.escape(stream_data.stream_privacy_policy_values.private.code)}']`,
|
`input[value='${CSS.escape(settings_config.stream_privacy_policy_values.private.code)}']`,
|
||||||
);
|
);
|
||||||
const $private_with_public_history_elem = $container.find(
|
const $private_with_public_history_elem = $container.find(
|
||||||
`input[value='${CSS.escape(
|
`input[value='${CSS.escape(
|
||||||
stream_data.stream_privacy_policy_values.private_with_public_history.code,
|
settings_config.stream_privacy_policy_values.private_with_public_history.code,
|
||||||
)}']`,
|
)}']`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -447,7 +447,7 @@ test_ui(
|
|||||||
stream_id: 102,
|
stream_id: 102,
|
||||||
name: "stream102",
|
name: "stream102",
|
||||||
subscribed: true,
|
subscribed: true,
|
||||||
stream_post_policy: stream_data.stream_post_policy_values.admins.code,
|
stream_post_policy: settings_config.stream_post_policy_values.admins.code,
|
||||||
};
|
};
|
||||||
|
|
||||||
stream_data.add_sub(sub_stream_102);
|
stream_data.add_sub(sub_stream_102);
|
||||||
@@ -496,7 +496,7 @@ test_ui(
|
|||||||
stream_id: 104,
|
stream_id: 104,
|
||||||
name: "stream104",
|
name: "stream104",
|
||||||
subscribed: true,
|
subscribed: true,
|
||||||
stream_post_policy: stream_data.stream_post_policy_values.moderators.code,
|
stream_post_policy: settings_config.stream_post_policy_values.moderators.code,
|
||||||
};
|
};
|
||||||
|
|
||||||
stream_data.add_sub(sub);
|
stream_data.add_sub(sub);
|
||||||
@@ -535,7 +535,7 @@ test_ui(
|
|||||||
stream_id: 103,
|
stream_id: 103,
|
||||||
name: "stream103",
|
name: "stream103",
|
||||||
subscribed: true,
|
subscribed: true,
|
||||||
stream_post_policy: stream_data.stream_post_policy_values.non_new_members.code,
|
stream_post_policy: settings_config.stream_post_policy_values.non_new_members.code,
|
||||||
};
|
};
|
||||||
|
|
||||||
stream_data.add_sub(sub);
|
stream_data.add_sub(sub);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ page_params.development_environment = true;
|
|||||||
const color_data = zrequire("color_data");
|
const color_data = zrequire("color_data");
|
||||||
const peer_data = zrequire("peer_data");
|
const peer_data = zrequire("peer_data");
|
||||||
const people = zrequire("people");
|
const people = zrequire("people");
|
||||||
|
const settings_config = zrequire("settings_config");
|
||||||
const sub_store = zrequire("sub_store");
|
const sub_store = zrequire("sub_store");
|
||||||
const stream_data = zrequire("stream_data");
|
const stream_data = zrequire("stream_data");
|
||||||
const stream_settings_data = zrequire("stream_settings_data");
|
const stream_settings_data = zrequire("stream_settings_data");
|
||||||
@@ -80,7 +81,7 @@ test("basics", () => {
|
|||||||
is_muted: false,
|
is_muted: false,
|
||||||
invite_only: true,
|
invite_only: true,
|
||||||
history_public_to_subscribers: false,
|
history_public_to_subscribers: false,
|
||||||
stream_post_policy: stream_data.stream_post_policy_values.admins.code,
|
stream_post_policy: settings_config.stream_post_policy_values.admins.code,
|
||||||
};
|
};
|
||||||
const test = {
|
const test = {
|
||||||
subscribed: true,
|
subscribed: true,
|
||||||
@@ -218,7 +219,7 @@ test("get_streams_for_user", () => {
|
|||||||
is_muted: false,
|
is_muted: false,
|
||||||
invite_only: false,
|
invite_only: false,
|
||||||
history_public_to_subscribers: false,
|
history_public_to_subscribers: false,
|
||||||
stream_post_policy: stream_data.stream_post_policy_values.admins.code,
|
stream_post_policy: settings_config.stream_post_policy_values.admins.code,
|
||||||
};
|
};
|
||||||
const test = {
|
const test = {
|
||||||
color: "yellow",
|
color: "yellow",
|
||||||
@@ -234,7 +235,7 @@ test("get_streams_for_user", () => {
|
|||||||
is_muted: false,
|
is_muted: false,
|
||||||
invite_only: false,
|
invite_only: false,
|
||||||
history_public_to_subscribers: false,
|
history_public_to_subscribers: false,
|
||||||
stream_post_policy: stream_data.stream_post_policy_values.admins.code,
|
stream_post_policy: settings_config.stream_post_policy_values.admins.code,
|
||||||
};
|
};
|
||||||
const subs = [denmark, social, test, world];
|
const subs = [denmark, social, test, world];
|
||||||
for (const sub of subs) {
|
for (const sub of subs) {
|
||||||
@@ -374,7 +375,7 @@ test("stream_settings", () => {
|
|||||||
subscribed: true,
|
subscribed: true,
|
||||||
invite_only: true,
|
invite_only: true,
|
||||||
history_public_to_subscribers: true,
|
history_public_to_subscribers: true,
|
||||||
stream_post_policy: stream_data.stream_post_policy_values.admins.code,
|
stream_post_policy: settings_config.stream_post_policy_values.admins.code,
|
||||||
message_retention_days: 10,
|
message_retention_days: 10,
|
||||||
can_remove_subscribers_group: admins_group.id,
|
can_remove_subscribers_group: admins_group.id,
|
||||||
};
|
};
|
||||||
@@ -397,7 +398,7 @@ test("stream_settings", () => {
|
|||||||
|
|
||||||
assert.equal(sub_rows[0].history_public_to_subscribers, true);
|
assert.equal(sub_rows[0].history_public_to_subscribers, true);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
sub_rows[0].stream_post_policy === stream_data.stream_post_policy_values.admins.code,
|
sub_rows[0].stream_post_policy === settings_config.stream_post_policy_values.admins.code,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
assert.equal(sub_rows[0].message_retention_days, 10);
|
assert.equal(sub_rows[0].message_retention_days, 10);
|
||||||
@@ -412,7 +413,7 @@ test("stream_settings", () => {
|
|||||||
stream_data.update_can_remove_subscribers_group_id(sub, moderators_group.id);
|
stream_data.update_can_remove_subscribers_group_id(sub, moderators_group.id);
|
||||||
assert.equal(sub.invite_only, false);
|
assert.equal(sub.invite_only, false);
|
||||||
assert.equal(sub.history_public_to_subscribers, false);
|
assert.equal(sub.history_public_to_subscribers, false);
|
||||||
assert.equal(sub.stream_post_policy, stream_data.stream_post_policy_values.everyone.code);
|
assert.equal(sub.stream_post_policy, settings_config.stream_post_policy_values.everyone.code);
|
||||||
assert.equal(sub.message_retention_days, -1);
|
assert.equal(sub.message_retention_days, -1);
|
||||||
assert.equal(sub.can_remove_subscribers_group, moderators_group.id);
|
assert.equal(sub.can_remove_subscribers_group, moderators_group.id);
|
||||||
|
|
||||||
@@ -696,7 +697,7 @@ test("muted_stream_ids", () => {
|
|||||||
is_muted: false,
|
is_muted: false,
|
||||||
invite_only: true,
|
invite_only: true,
|
||||||
history_public_to_subscribers: false,
|
history_public_to_subscribers: false,
|
||||||
stream_post_policy: stream_data.stream_post_policy_values.admins.code,
|
stream_post_policy: settings_config.stream_post_policy_values.admins.code,
|
||||||
};
|
};
|
||||||
const test = {
|
const test = {
|
||||||
subscribed: true,
|
subscribed: true,
|
||||||
@@ -909,7 +910,7 @@ test("can_post_messages_in_stream", () => {
|
|||||||
is_muted: false,
|
is_muted: false,
|
||||||
invite_only: true,
|
invite_only: true,
|
||||||
history_public_to_subscribers: false,
|
history_public_to_subscribers: false,
|
||||||
stream_post_policy: stream_data.stream_post_policy_values.admins.code,
|
stream_post_policy: settings_config.stream_post_policy_values.admins.code,
|
||||||
};
|
};
|
||||||
page_params.is_admin = false;
|
page_params.is_admin = false;
|
||||||
assert.equal(stream_data.can_post_messages_in_stream(social), false);
|
assert.equal(stream_data.can_post_messages_in_stream(social), false);
|
||||||
@@ -917,7 +918,7 @@ test("can_post_messages_in_stream", () => {
|
|||||||
page_params.is_admin = true;
|
page_params.is_admin = true;
|
||||||
assert.equal(stream_data.can_post_messages_in_stream(social), true);
|
assert.equal(stream_data.can_post_messages_in_stream(social), true);
|
||||||
|
|
||||||
social.stream_post_policy = stream_data.stream_post_policy_values.moderators.code;
|
social.stream_post_policy = settings_config.stream_post_policy_values.moderators.code;
|
||||||
page_params.is_moderator = false;
|
page_params.is_moderator = false;
|
||||||
page_params.is_admin = false;
|
page_params.is_admin = false;
|
||||||
|
|
||||||
@@ -926,7 +927,7 @@ test("can_post_messages_in_stream", () => {
|
|||||||
page_params.is_moderator = true;
|
page_params.is_moderator = true;
|
||||||
assert.equal(stream_data.can_post_messages_in_stream(social), true);
|
assert.equal(stream_data.can_post_messages_in_stream(social), true);
|
||||||
|
|
||||||
social.stream_post_policy = stream_data.stream_post_policy_values.non_new_members.code;
|
social.stream_post_policy = settings_config.stream_post_policy_values.non_new_members.code;
|
||||||
page_params.is_moderator = false;
|
page_params.is_moderator = false;
|
||||||
me.date_joined = new Date(Date.now());
|
me.date_joined = new Date(Date.now());
|
||||||
page_params.realm_waiting_period_threshold = 10;
|
page_params.realm_waiting_period_threshold = 10;
|
||||||
@@ -938,7 +939,7 @@ test("can_post_messages_in_stream", () => {
|
|||||||
page_params.is_guest = true;
|
page_params.is_guest = true;
|
||||||
assert.equal(stream_data.can_post_messages_in_stream(social), false);
|
assert.equal(stream_data.can_post_messages_in_stream(social), false);
|
||||||
|
|
||||||
social.stream_post_policy = stream_data.stream_post_policy_values.everyone.code;
|
social.stream_post_policy = settings_config.stream_post_policy_values.everyone.code;
|
||||||
assert.equal(stream_data.can_post_messages_in_stream(social), true);
|
assert.equal(stream_data.can_post_messages_in_stream(social), true);
|
||||||
|
|
||||||
page_params.is_spectator = true;
|
page_params.is_spectator = true;
|
||||||
@@ -1045,7 +1046,7 @@ test("options for dropdown widget", () => {
|
|||||||
is_muted: false,
|
is_muted: false,
|
||||||
invite_only: true,
|
invite_only: true,
|
||||||
history_public_to_subscribers: false,
|
history_public_to_subscribers: false,
|
||||||
stream_post_policy: stream_data.stream_post_policy_values.admins.code,
|
stream_post_policy: settings_config.stream_post_policy_values.admins.code,
|
||||||
};
|
};
|
||||||
const test = {
|
const test = {
|
||||||
subscribed: true,
|
subscribed: true,
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ const {Filter} = zrequire("../src/filter");
|
|||||||
const narrow_state = zrequire("narrow_state");
|
const narrow_state = zrequire("narrow_state");
|
||||||
const peer_data = zrequire("peer_data");
|
const peer_data = zrequire("peer_data");
|
||||||
const people = zrequire("people");
|
const people = zrequire("people");
|
||||||
|
const settings_config = zrequire("settings_config");
|
||||||
const stream_data = zrequire("stream_data");
|
const stream_data = zrequire("stream_data");
|
||||||
const stream_events = zrequire("stream_events");
|
const stream_events = zrequire("stream_events");
|
||||||
const compose_recipient = zrequire("compose_recipient");
|
const compose_recipient = zrequire("compose_recipient");
|
||||||
@@ -232,12 +233,12 @@ test("update_property", ({override, override_rewire}) => {
|
|||||||
stream_events.update_property(
|
stream_events.update_property(
|
||||||
stream_id,
|
stream_id,
|
||||||
"stream_post_policy",
|
"stream_post_policy",
|
||||||
stream_data.stream_post_policy_values.admins.code,
|
settings_config.stream_post_policy_values.admins.code,
|
||||||
);
|
);
|
||||||
assert.equal(stub.num_calls, 1);
|
assert.equal(stub.num_calls, 1);
|
||||||
const args = stub.get_args("sub", "val");
|
const args = stub.get_args("sub", "val");
|
||||||
assert.equal(args.sub.stream_id, stream_id);
|
assert.equal(args.sub.stream_id, stream_id);
|
||||||
assert.equal(args.val, stream_data.stream_post_policy_values.admins.code);
|
assert.equal(args.val, settings_config.stream_post_policy_values.admins.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test stream message_retention_days change event
|
// Test stream message_retention_days change event
|
||||||
|
|||||||
Reference in New Issue
Block a user