mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 19:31:58 +00:00
stream_data: Add web_public as a stream privacy mode.
Show web_public descriptions for web public streams. (Temporarily limited to development environments, since this feature is not available yet).
This commit is contained in:
@@ -9,6 +9,10 @@ const {run_test} = require("../zjsunit/test");
|
|||||||
const blueslip = require("../zjsunit/zblueslip");
|
const blueslip = require("../zjsunit/zblueslip");
|
||||||
const {page_params, user_settings} = require("../zjsunit/zpage_params");
|
const {page_params, user_settings} = require("../zjsunit/zpage_params");
|
||||||
|
|
||||||
|
// TODO: Remove after we enable support for
|
||||||
|
// web_public_streams in production.
|
||||||
|
page_params.development_environment = true;
|
||||||
|
|
||||||
const color_data = zrequire("color_data");
|
const color_data = zrequire("color_data");
|
||||||
const stream_topic_history = zrequire("stream_topic_history");
|
const stream_topic_history = zrequire("stream_topic_history");
|
||||||
const peer_data = zrequire("peer_data");
|
const peer_data = zrequire("peer_data");
|
||||||
@@ -76,14 +80,27 @@ test("basics", () => {
|
|||||||
is_muted: true,
|
is_muted: true,
|
||||||
invite_only: false,
|
invite_only: false,
|
||||||
};
|
};
|
||||||
|
const web_public_stream = {
|
||||||
|
subscribed: false,
|
||||||
|
color: "yellow",
|
||||||
|
name: "web_public_stream",
|
||||||
|
stream_id: 4,
|
||||||
|
is_muted: false,
|
||||||
|
invite_only: false,
|
||||||
|
history_public_to_subscribers: true,
|
||||||
|
is_web_public: true,
|
||||||
|
};
|
||||||
stream_data.add_sub(denmark);
|
stream_data.add_sub(denmark);
|
||||||
stream_data.add_sub(social);
|
stream_data.add_sub(social);
|
||||||
|
stream_data.add_sub(web_public_stream);
|
||||||
assert.ok(stream_data.all_subscribed_streams_are_in_home_view());
|
assert.ok(stream_data.all_subscribed_streams_are_in_home_view());
|
||||||
stream_data.add_sub(test);
|
stream_data.add_sub(test);
|
||||||
assert.ok(!stream_data.all_subscribed_streams_are_in_home_view());
|
assert.ok(!stream_data.all_subscribed_streams_are_in_home_view());
|
||||||
|
|
||||||
assert.equal(stream_data.get_sub("denmark"), denmark);
|
assert.equal(stream_data.get_sub("denmark"), denmark);
|
||||||
assert.equal(stream_data.get_sub("Social"), social);
|
assert.equal(stream_data.get_sub("Social"), social);
|
||||||
|
assert.equal(stream_data.get_sub("web_public_stream"), web_public_stream);
|
||||||
|
assert.ok(stream_data.is_web_public(web_public_stream.stream_id));
|
||||||
|
|
||||||
assert.deepEqual(stream_data.home_view_stream_names(), ["social"]);
|
assert.deepEqual(stream_data.home_view_stream_names(), ["social"]);
|
||||||
assert.deepEqual(stream_data.subscribed_streams(), ["social", "test"]);
|
assert.deepEqual(stream_data.subscribed_streams(), ["social", "test"]);
|
||||||
@@ -101,6 +118,7 @@ test("basics", () => {
|
|||||||
stream_data.get_stream_privacy_policy(denmark.stream_id),
|
stream_data.get_stream_privacy_policy(denmark.stream_id),
|
||||||
"invite-only-public-history",
|
"invite-only-public-history",
|
||||||
);
|
);
|
||||||
|
assert.equal(stream_data.get_stream_privacy_policy(web_public_stream.stream_id), "web-public");
|
||||||
|
|
||||||
assert.ok(stream_data.get_invite_only("social"));
|
assert.ok(stream_data.get_invite_only("social"));
|
||||||
assert.ok(!stream_data.get_invite_only("unknown"));
|
assert.ok(!stream_data.get_invite_only("unknown"));
|
||||||
|
|||||||
@@ -129,6 +129,17 @@ export const stream_privacy_policy_values = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (page_params.development_environment) {
|
||||||
|
stream_privacy_policy_values.web_public = {
|
||||||
|
code: "web-public",
|
||||||
|
name: $t({defaultMessage: "Web public"}),
|
||||||
|
description: $t({
|
||||||
|
defaultMessage:
|
||||||
|
"Anyone can join; anyone on the Internet can view complete message history without creating an account",
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export const stream_post_policy_values = {
|
export const stream_post_policy_values = {
|
||||||
everyone: {
|
everyone: {
|
||||||
code: 1,
|
code: 1,
|
||||||
@@ -544,6 +555,9 @@ export function id_is_subscribed(stream_id) {
|
|||||||
export function get_stream_privacy_policy(stream_id) {
|
export function get_stream_privacy_policy(stream_id) {
|
||||||
const sub = sub_store.get(stream_id);
|
const sub = sub_store.get(stream_id);
|
||||||
|
|
||||||
|
if (sub.is_web_public) {
|
||||||
|
return stream_privacy_policy_values.web_public.code;
|
||||||
|
}
|
||||||
if (!sub.invite_only) {
|
if (!sub.invite_only) {
|
||||||
return stream_privacy_policy_values.public.code;
|
return stream_privacy_policy_values.public.code;
|
||||||
}
|
}
|
||||||
@@ -553,6 +567,11 @@ export function get_stream_privacy_policy(stream_id) {
|
|||||||
return stream_privacy_policy_values.private_with_public_history.code;
|
return stream_privacy_policy_values.private_with_public_history.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function is_web_public(stream_id) {
|
||||||
|
const sub = sub_store.get(stream_id);
|
||||||
|
return sub !== undefined && sub.is_web_public;
|
||||||
|
}
|
||||||
|
|
||||||
export function get_invite_only(stream_name) {
|
export function get_invite_only(stream_name) {
|
||||||
const sub = get_sub(stream_name);
|
const sub = get_sub(stream_name);
|
||||||
if (sub === undefined) {
|
if (sub === undefined) {
|
||||||
|
|||||||
Reference in New Issue
Block a user