Commit Graph

246 Commits

Author SHA1 Message Date
apoorvapendse
6203861529 zerver: API to create channel.
Fixes #16206.

Co-authored-by: Sahil Batra <sahil@zulip.com>
Co-authored-by: Steve Howell <showell@zulip.com>
Signed-off-by: apoorvapendse <apoorvavpendse@gmail.com>
2025-08-08 19:29:17 -07:00
apoorvapendse
4d49fa6fbb streams: Extract zephyr realm invite check.
This will be reused later in the
`/channels/create` view.

Signed-off-by: apoorvapendse <apoorvavpendse@gmail.com>
2025-08-08 18:41:47 -07:00
Vector73
97a43fa6b6 stream_settings: Add can_delete_own_message_group setting.
Adds per-channel `can_delete_own_message_group` setting for
defining who can delete their own message in the channel.
2025-07-17 15:44:52 -07:00
Vector73
c4e641365b stream_settings: Add can_delete_any_message_group setting.
Adds per-channel can_delete_any_message_group setting for
defining who can delete any message in the channel.
2025-07-17 15:44:42 -07:00
apoorvapendse
947658def4 streams: Extract topics_policy validation.
Fixes: Point 3 of
https://github.com/zulip/zulip/pull/33405#issuecomment-3064452310.
Signed-off-by: apoorvapendse <apoorvavpendse@gmail.com>
2025-07-16 09:38:36 -07:00
apoorvapendse
e2f3b64b35 streams: Extract channel creation permissions check logic.
Prep commit to add the channel creation API
endpoint.
Signed-off-by: apoorvapendse <apoorvavpendse@gmail.com>
2025-07-14 07:44:01 -07:00
Vector73
a77fc6aa79 stream_settings: Add new disable_topics option to topics_policy.
Adds new configuration option `disable_topics` in `topics_policy`
channel setting to support disabling topics in the channel.

Fixes #34553.
2025-07-09 14:25:53 -07:00
Vector73
7afed92c00 streams: Add function to get topic for channel events notifications.
Refactored the code to add a function `channel_events_topic_name`
to get the topic name for sending notification for channel events.
2025-07-09 14:25:53 -07:00
opmkumar
8786b12f0c streams: Add can_resolve_topics_group setting.
Fixes #19955.
2025-07-08 16:53:43 -07:00
Vector73
b612351e48 stream_setting: Add setting for who can move messages out of channel.
Adds `can_move_messages_out_of_channel_group` channel-level
permission for who can move messages out of the channel.

Fixes #34243.
2025-06-24 16:52:53 -07:00
Vector73
703601a5d5 stream_setting: Add setting for who can move messages within channel.
Adds `can_move_messages_within_channel_group` channel-level
permission for who can move messages within the channel.
2025-06-24 16:52:53 -07:00
Evy Kassirer
4313648ca5 streams: Add subscriber_count to page load data. 2025-06-19 14:25:41 -07:00
Vector73
6094bbe8a5 stream_settings: Add new topics_policy setting.
Added `topics_policy` channel setting to configure sending
messages in the empty topic.

Fixes #33549.
2025-06-17 17:05:58 -07:00
Sahil Batra
509a84403b streams: Refactor get_web_public_streams_queryset.
This commit updates code to not prefetch group setting
fields using select_related as we do not need to
prefetch these settings for all the cases and we instead
prefetch these in callers whenever needed.
2025-05-20 13:25:06 -07:00
Sahil Batra
ec96fc9659 streams: Allow adding newly created channels to folders.
Fixes part of #31972.
2025-05-20 13:25:06 -07:00
Sahil Batra
202bebda89 streams: Add folder foreign key to Stream table.
This commit also adds "folder_id" field in stream and subscription
objects.

Fixes part of #31972.
2025-05-20 13:25:06 -07:00
Ritwik
187a008f13 streams: Modify get_stream_permission_policy_name to return dict key.
This is a prep commit for #30212. It will allow us to compare the key
and not translated policy name.

Co-authored-by: Tanmay Kumar <tnmdotkr@gmail.com>
2025-04-15 16:28:38 -07:00
Sahil Batra
7ebea853be user_groups: Refactor user_has_permission_for_group_setting.
This commit refactors user_has_permission_for_group_setting
to accept setting group ID instead of UserGroup object.

We only need ID in checking the permission and this helps in
further commit to avoid prefetching can_access_all_users_group
setting.
2025-04-11 17:37:06 -07:00
Sanchit Sharma
d5c83e02c3 streams: Return archived web-public channels. 2025-04-11 08:12:53 -07:00
Sahil Batra
7c470f0161 streams: Fix events send when archiving and unarchiving streams. 2025-04-08 12:41:09 -07:00
Shubham Padia
2e48293e4b streams: Use bulk function in can_access_stream_metadata_user_ids.
Performance remains the same whether we're using the bulk function
underneath the function in question or not, this helps us avoid
duplication.
2025-03-25 13:20:06 -07:00
Shubham Padia
b62d51f0ae streams: Add get_metadata_access_streams_via_group_ids. 2025-03-25 13:20:06 -07:00
Shubham Padia
208ee1b8d9 streams: Add bulk_access_stream_metadata_user_ids.
This function will be useful in sending events for users gaining or
losing metadata access when the members of a user group change in any
way.
2025-03-25 13:20:06 -07:00
Shubham Padia
ac9b7b5fa1 user_groups: Rename UserGroupMembersDict to UserGroupMembersData.
UserGroupMembersData is not serializable by orjson. We will be
introducing a TypedDict (which is serializable) in the next commit
called UserGroupMembersDict. This rename will help us distinguish
between the two.
2025-03-17 14:21:37 -07:00
Sahil Batra
5915b85c5a register: Optimize computing stream group setting values.
Fetch all anonymous groups data once which can be used
for computing group setting values for realm, streams
and user groups.

Fixes #32561.
2025-03-14 18:31:18 -07:00
Sahil Batra
bc2afd45b3 streams: Refactor code to handle group setting values.
This commit updates the code which computes the dict for
setting groups mapping named user groups to ID and anonymous
groups to UserGroupMembersDict. After the changes, the dict
contains only anonymous groups values and the setting values
for group IDs not present in dict will be computed based on
the fact that those are named user groups.

This is a preparatory refactor for optimizing computing group
setting values for register response by fetching all anonymous
groups membership data just once.
2025-03-14 18:31:18 -07:00
Sahil Batra
943e754a90 streams: Do not include deactivated users in group setting values.
This commit fixes the code to not include deactivated groups in
stream setting values when the setting is set to an anonymous
group. This is consistent with what we do for realm and user
group settings.

As a result, we also deduplicate some code by using existing
function used for realm and group settings.
2025-03-12 17:14:05 -07:00
Tim Abbott
c58f14b159 streams: Allow editing subscriptions in archived channels.
Since this does impact the ability to access the channel's content, it
makes sense to permit changing subscriptions, just like other
permissions settings on the archived channel.
2025-03-07 18:08:41 -08:00
Tim Abbott
494f28c64e streams: Add require_active_channel access parameter. 2025-03-07 18:08:41 -08:00
Tim Abbott
f68692a893 access_stream: Use mandatory kwargs. 2025-03-07 18:08:41 -08:00
Tim Abbott
e92d68fffe streams: Remove require_active in access_stream code path.
This was confusingly doing an assertion about the subscription being
active, not the channel. We could rename it to
require_active_subscription. But it was only passed with a non-default
value in b2cb443d24, and that call was
removed in 378062cc83.
2025-03-07 18:08:41 -08:00
ImDooMLorD
6dea58623c errors: Standardize "already in use" error messages.
Updates these error messages to have "X is already in use." format,
e.g., "Channel name is already in use." and "Name is already in use."

Fixes #33629.
2025-03-04 16:10:25 -08:00
Sahil Batra
75b5d43a91 groups: Rename AnonymousSettingGroupDict to UserGroupMembersDict.
This change is done because we would use the same data structure
for named user groups as well in future commits.
2025-02-27 10:03:28 -08:00
Sahil Batra
f9107adaa4 streams: Do not archive vacant private streams.
We no longer archive private streams when they become vacant,
since user can still have permissions to subscribe to it.

And streams can anyways be archived manually if needed.

Fixes #33689.
2025-02-27 09:21:03 -08:00
Shubham Padia
e57c43b705 bots: Do not remove bot from inaccessible streams on owner change.
See
https://chat.zulip.org/#narrow/channel/101-design/topic/manage.20bot.20access.20feature.20removal
2025-02-26 09:30:24 -08:00
Shubham Padia
a80b2e478c get_streams: Return metadata access streams in include_all.
This parameter is no longer restricted to realm administrators. Any
user can get the streams they have metadata access to by setting this
parameter to true.
2025-02-25 14:25:43 -08:00
Sahil Batra
7d0cef6911 streams: Do not fetch can_add_subscribers_group unnecessarily.
In public_stream_user_ids function, which is used to get users
who can access public streams, there is no need to fetch members
of can_add_subscribers_group as we eventually exclude guests
from them and we have already included all non guest users of
the realm.
2025-02-25 13:17:15 -08:00
Sahil Batra
62478f900d streams: Modfiy stream permissions to use can_subscribe_group.
Fixes part of #33417.
2025-02-25 13:17:15 -08:00
Sahil Batra
bafec11c61 streams: Add new can_subscribe_group permission setting.
Fixes part of #33417.
2025-02-25 13:17:15 -08:00
Shubham Padia
ce031c4b52 get_stream: Rename include_all_active to include_all.
We keep around the old `include_all_active` parameter for backwards
compatibility.
Web frontend doesn't use this API and thus there were no changes needed
there.
2025-02-24 22:17:15 -08:00
Shubham Padia
6dde44cf37 get_streams: Add include_can_access_content.
Also add some query count checks.
See https://chat.zulip.org/#narrow/channel/378-api-design/topic/GET.20.2Fstreams.20with.20new.20permissions/with/2096944
for API design discussion.
2025-02-24 22:15:18 -08:00
Shubham Padia
f6bb990b91 user_group: Move UserGroupMembershipDetails from lib/streams.py. 2025-02-21 15:36:07 -08:00
Shubham Padia
63a4aea7a8 streams: Add get_content_access_streams function.
To get content access streams for mention.py, we will now use
get_content_access_streams and we have done a lot more other refactors
in this commit around filter_stream_authorization. Mainly making that
function only to be used for adding subscribers and naming it
accordingly.
2025-02-21 15:36:07 -08:00
Shubham Padia
a7b5960c98 message: Allow to send without subscribing if user has content access.
If the user has content access and is part of the
`can_send_message_group`, they can send a message to streams with shared
history. We do not allow them to send messages to stream with protected
history since they it would go into a void and they cannot see the
message later.
See https://chat.zulip.org/#narrow/channel/101-design/topic/shared.20history.20can.20send.20message/with/2095398
2025-02-21 15:36:07 -08:00
Shubham Padia
dcaf0dd103 stream: Function to check if user is in groups granting content access.
We're going to be adding a new setting called `can_join_group` soon and
it would be good to have this wrapper function ready for it to be used
in.
2025-02-16 17:12:30 -08:00
Sahil Batra
a1ac49582b streams: Optimize computing users with metadata access.
This commit updates code to optimize computing users who have
metadata access via permission groups so that we do not have
to do DB query for each stream to get recursive members for
the groups having permissions.
2025-02-14 12:00:37 -08:00
Aman Agrawal
75be449d45 CVE-2025-25195: Only send "active" change events to channel subscribers.
This fixes a bug where private stream event to update stream's
active status was sent to all active users instead of just
its subscribers.
2025-02-13 11:58:23 -08:00
Aman Agrawal
a2a1a7f8d1 streams: Use a common func to send stream recently active update event.
This helps us to apply fix for sending event update for
private stream to only its subscribers.
2025-02-13 11:58:23 -08:00
roanster007
c562503089 markdown: Fix stream description with topic permalink not rendered.
Previously, when description for a channel -- either during its
creating or when we change its description contained a topic
permalink (through #-mention), then it was not rendered. This
is because of lack of authorization to access the channel.

This is fixed by passing the acting_user through the methods
which update or add the description, so that permissions
of the acting_user could be used to determine whether to
render the #-mention in stream description or not.
2025-02-12 12:50:25 -08:00
Shubham Padia
1db2487f1c stream: Guest users cannot get metadata access to channel via groups. 2025-02-12 09:35:17 -08:00