Commit Graph

26 Commits

Author SHA1 Message Date
sanchi-t
1aef79078c stream_settings: Display archived channels.
By default, archived channels will be hidden.
2025-03-07 18:08:41 -08:00
sanchi-t
f9babb37a2 delete_sub: Do not remove stream from subscriptions when archived. 2025-03-07 18:08:41 -08:00
Sahil Batra
166d9282b8 streams: Use can_subscribe_group setting for checking permission.
This commit adds code to use can_subscribe_group setting in webapp.

Fixes part of #33417.
2025-02-25 13:17:15 -08:00
Shubham Padia
5d7a78f721 stream_data: Users with content access should be able to preview.
Before this, not all users with content access were able to see the
preview button.
2025-02-21 15:36:07 -08:00
Shubham Padia
89ea21f7f0 stream_data: Use user_has_permission_for_group_setting.
Before this, we were using `is_user_in_setting_group` which does not do
the extra checks around a guest user's permissions (and in future, some
other checks).
We introduced `initialize_and_override_current_user` in stream_data test
to make it easier to set current_user.user_id.
2025-02-18 12:49:05 -08:00
Prakhar Pratyush
1acf309d57 stream_data: Fix 'can_access_stream_email' function.
'can_access_stream_email' function determines who can
generate email to send message in a channel.

Earlier, the function was not considering channel post policy.
So, a user which doesn't have permission to post in
a channel as per channel post policy could generate channel email.

This commit makes sure to not show the "Generate email address"
button in such cases.

We show the button only if the current user or any of the bots
they control has the permission to post in the channel.

Fixes part of #31566.
2025-02-12 15:08:32 -08:00
Shubham Padia
d82f595e51 stream: Disable permissions that require content access.
Disable privacy settings and can_add_subscriber_group when an admin does
not have content access to the channel.
We are going to add `can_subscriber_group` in the future which will also
require content access to change and that's why we have used
`stream_group_permission_settings_requiring_content_access` to keep the
list of such group settings.
We only show the warning banner now if the user cannot edit any of the
channel properties. For more details, see
https://chat.zulip.org/#narrow/channel/101-design/topic/Warning.20for.20settings.20that.20cannot.20be.20changed.2E
2025-02-11 15:09:16 -08:00
Shubham Padia
f94608677f stream_data: Use can administer channel for can_unsubscribe_others.
Previously, we were just checking whether a user was realm admin for
`can_unsubscribe_others`, now we also check whether they are a channel
admin for the said channel.
2025-02-11 15:09:16 -08:00
Shubham Padia
c97495c7ae stream_data: Use has_content_access for can_subscribe_others. 2025-02-11 15:09:16 -08:00
Shubham Padia
f5bcaacfc3 stream_data: Add has_content_access function.
This function will be used to check whether a user has access to a
channel's content in future commits.
2025-02-11 15:09:16 -08:00
Shubham Padia
03bfa7752d stream_data: Use has_metadata_access for can_view_subscribers.
We are using `has_metadata_access` one by one in different functions in
stream_data where possible. This commit does not represent the
exhaustive use of `has_metadata_access`.

We have kept around the `can_view_subscribers` function even though it
is the same as `has_metadata_access` right now. Since we've already done
the work of using `can_view_subscribers` at appropriate places, it would
be good to keep that work around in case that function's underlying
implementation changes in the future.
2025-02-11 15:09:16 -08:00
Shubham Padia
29a1a01325 stream_data: Add has_metadata_access function.
This function will be used in upcoming commits to determine whether a
user has access to a channel metadata or not. This function does not
give access to channel's content.
2025-02-11 15:09:16 -08:00
Tim Abbott
68c3e86ffa stream_data: Fix parsing of slugs for inaccessible channels.
Previously, if we had syntax in a URL slug that looked like a channel
ID, but we couldn't find the channel (say, beacuse it's a link to a
channel we're not subscribed to), parse_narrow would fail to parse it,
resulting in incorrect error handling.

This could break rendering of topic links that we want to process via
rendered_markdown.ts. I've confirmed that the web app's logic for
processing message_view.show does not require its caller to check the
channel ID is accessible.

The updated logic matches what we do in the mobile apps.
2025-02-05 14:01:11 -08:00
Shubham Padia
f40db2de28 stream_data: Use can_add_subscribers_group to check permissions. 2025-01-22 14:27:06 -08:00
Shubham Padia
3bf87228a2 settings: Use can_add_subscribers_group instead of realm policy.
We are using `can_add_subscribers_group` instead of
`invite_to_stream_policy` to check whether a user can subscribe other
users.
We've removed `invite_to_stream_policy` from the frontend wherever
applicable.
2025-01-22 12:33:58 -08:00
Sahil Batra
1175467d45 stream-settings: Remove code related to stream post policy. 2025-01-07 12:17:37 -08:00
Sahil Batra
bbf43a2866 stream-settings: Use new "can_send_message_group" setting. 2025-01-07 12:17:36 -08:00
Sahil Batra
1c933dd231 streams: Include only IDs in default streams data.
Clients do not need complete stream objects in the default
streams data since they already have that via streams and
subscriptions data.
2024-12-17 09:40:10 -08:00
Shubham Padia
7e92c2ad16 streams: Use can_administer_channel_group to administer channel.
Fixes #31959.
2024-12-03 18:38:25 -08:00
Shubham Padia
940b7e38f8 stream: Use existing group declarations for can_unsubscribe_others.
The test was declaring all groups again and creating them, this commit
ensures that it uses the share-able code.
2024-12-01 19:32:22 -08:00
Shubham Padia
dbf9f2d181 stream: Use generic update_stream_permission_group_setting.
We will not have to create a new function for every setting that we add
in the future.
2024-12-01 19:32:22 -08:00
Sahil Batra
7a6159eee2 streams: Do not show archived streams in dropdown.
Dropdown widget in compose box and in message move modal should
not show archived streams in dropdown as we do not allow sending
messages or moving messages to archived streams.

We need a more focused audit of code for fixing other things
where archived streams are shown.
2024-11-22 10:40:59 -08:00
Sahil Batra
d1e76a9281 streams: Allow admins to unsubscribe others irrespective of setting. 2024-11-21 11:28:54 -08:00
Sahil Batra
7c6110e47a stream_data: Fix code to check permission for unsubscribe others.
We no longer allow admins to unsubscribe others from stream if
they are not allowed as per the can_remove_subscribers_group
setting.
2024-11-19 13:26:42 -08:00
Sahil Batra
5d1de4c037 stream-settings: Use new pills UI for can_remove_subscribers_group. 2024-11-16 17:11:08 -08:00
Anders Kaseorg
687f1b1651 tests: Rename the Node tests to *.cjs.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-11-13 09:18:56 -08:00