streams: Set is_announcement_only when creating streams.

Adds is_announcement_only to create_stream_if_needed and
add_subscriptions_backend.
This commit is contained in:
Shubham Padia
2018-05-30 19:02:51 +05:30
committed by Tim Abbott
parent bab09a6579
commit bb8ad15fa9
3 changed files with 8 additions and 1 deletions

View File

@@ -1620,6 +1620,7 @@ def create_stream_if_needed(realm: Realm,
stream_name: str,
*,
invite_only: bool=False,
is_announcement_only: Optional[bool]=False,
history_public_to_subscribers: Optional[bool]=None,
stream_description: str="") -> Tuple[Stream, bool]:
@@ -1633,6 +1634,7 @@ def create_stream_if_needed(realm: Realm,
name=stream_name,
description=stream_description,
invite_only=invite_only,
is_announcement_only=is_announcement_only,
history_public_to_subscribers=history_public_to_subscribers,
is_in_zephyr_realm=realm.is_zephyr_mirror_realm
)
@@ -1666,6 +1668,7 @@ def create_streams_if_needed(realm: Realm,
realm,
stream_dict["name"],
invite_only=stream_dict.get("invite_only", False),
is_announcement_only=stream_dict.get("is_announcement_only", False),
history_public_to_subscribers=stream_dict.get("history_public_to_subscribers"),
stream_description=stream_dict.get("description", "")
)

View File

@@ -115,7 +115,8 @@ class TestCreateStreams(ZulipTestCase):
realm,
[{"name": stream_name,
"description": stream_description,
"invite_only": True}
"invite_only": True,
"is_announcement_only": True}
for (stream_name, stream_description) in zip(stream_names, stream_descriptions)])
self.assertEqual(len(new_streams), 3)
@@ -127,6 +128,7 @@ class TestCreateStreams(ZulipTestCase):
self.assertEqual(actual_stream_descriptions, set(stream_descriptions))
for stream in new_streams:
self.assertTrue(stream.invite_only)
self.assertTrue(stream.is_announcement_only)
new_streams, existing_streams = create_streams_if_needed(
realm,

View File

@@ -294,6 +294,7 @@ def add_subscriptions_backend(
streams_raw: Iterable[Mapping[str, str]]=REQ(
"subscriptions", validator=check_list(check_dict([('name', check_string)]))),
invite_only: bool=REQ(validator=check_bool, default=False),
is_announcement_only: bool=REQ(validator=check_bool, default=False),
history_public_to_subscribers: Optional[bool]=REQ(validator=check_bool, default=None),
announce: bool=REQ(validator=check_bool, default=False),
principals: List[str]=REQ(validator=check_list(check_string), default=[]),
@@ -307,6 +308,7 @@ def add_subscriptions_backend(
# Strip the stream name here.
stream_dict_copy['name'] = stream_dict_copy['name'].strip()
stream_dict_copy["invite_only"] = invite_only
stream_dict_copy["is_announcement_only"] = is_announcement_only
stream_dict_copy["history_public_to_subscribers"] = history_public_to_subscribers
stream_dicts.append(stream_dict_copy)