Commit Graph

426 Commits

Author SHA1 Message Date
Anders Kaseorg
f24a0a6b81 ruff: Fix RUF059 Unpacked variable is never used.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-09-30 16:47:54 -07:00
Sahil Batra
d4d7a8fe2a streams: Make sure that unused anonymous groups are not created.
Anonymous groups were being created for stream permission
settings when calling the subscriptions endpoint without
any streams data or when calling it only for subscribing
users to streams and not for creating any new streams.

This commit makes sure that no such unused anonymous groups
are created.
2025-09-23 12:15:51 -07:00
Sahil Batra
1e21f7b224 register: Rename stream_creator_or_nobody to channel_creator.
This commit renames `stream_creator_or_nobody` value for
`default_group_name` field in `server_supported_permission_settings`
object to `channel_creator`.
2025-09-23 12:12:23 -07:00
Anders Kaseorg
40a022dcc3 zephyr: Remove Zephyr mirroring support.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-09-16 11:18:18 -07:00
Kislay Verma
18d9b686b7 add_subscriptions: Only exclude DMs and not new channel notifications.
When the number of new subscriptions crosses a threshold, we wish to
avoid sending DMs to the user as implemented in #31206. But there was
a bug causing announcement channel and new channel notification
messages to also not be sent.

This commit fixes that bug by ensuring that we only exclude direct
message notications.
2025-08-27 17:06:31 -07:00
Lauryn Menard
699c0c6200 create-channel: Remove send_new_subscription_messages parameter.
Removes send_new_subscription_messages parameter from
`POST channel/create` endpoint as Notification Bot DMs
are never sent when users are subscribed as part of
creating a new channel.

Not considered a documentable API change, since the previous parameter
never had any effect, so this is effectively just a documentation and
error-handling bug fix, not an API change relevant to implementors.
2025-08-27 11:12:05 -07:00
Lauryn Menard
dda2c6e285 create-channel: Clarify flow of new channel and subscription notices.
Updates comments in send_user_subscribed_and_new_channel_notifications
so that it is clearer what notification each "if" block of the function
is generating.

Also, moves variables that are only used in the user subscribed DMs to
that "if" block.
2025-08-27 11:12:05 -07:00
Lauryn Menard
8b1e536e6b create-channel: Rename send_messages_for_new_subscribers helper.
Because send_messages_for_new_subscribers also sends channel
notification messages about newly created channels, a clearer
name for is send_user_subscribed_and_new_channel_notifications.
2025-08-27 11:12:05 -07:00
Mateusz Mandera
5ef6852cfe delete_in_topic: Don't unnecessarily fetch .recipient.
This reverts commit f119c33789.
With 51cef01c29 merged, there is no need
to fetch .recipient here, as it won't be accessed by the delete messages
codepath.
2025-08-27 09:08:00 -07:00
apoorvapendse
8f14b717ff zerver: Drop support for Zulip API emails in channel creation.
Also write the description a bit better.

Discussion:
https://chat.zulip.org/#narrow/channel/378-api-design/topic/Channel.20creation.20should.20return.20the.20channel.20ID/near/2240040.

Signed-off-by: apoorvapendse <apoorvavpendse@gmail.com>
2025-08-11 23:40:12 -07:00
Mateusz Mandera
f119c33789 delete_in_topic: Don't fetch .recipient for each message in a loop.
The grouping logic in `do_delete_messages` calls
`message.is_stream_message()` in a loop, which needs to access
message.recipient. This is obviously super inefficient if .recipient
hasn't been prefetched for the message objects.

`delete_in_topic` is the only function that calls `do_delete_messages`
with many messages, so this is the only spot we need to fix, to address
the immediate bug.
Of course a better improvement would be to fix `do_delete_messages` to
do something smarter than naively accessing message.recipient in a loop.
2025-08-11 10:08:40 -07:00
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
apoorvapendse
1190afbe4f streams: Extract pydantic validation for topics_policy.
Signed-off-by: apoorvapendse <apoorvavpendse@gmail.com>
2025-08-08 18:41:47 -07:00
Vector73
0ac24bd437 api: Add support for passing partial to include_subscribers parameter.
Fixes #35318.
2025-08-04 18:43:14 -07:00
Sahil Batra
eb57fe10a2 streams: Handle empty topic only streams being used for announcements.
This commit updates code to send messages to "general chat" topic
if streams used for announcements for "New user signups",
"New created streams", "Moderation requests" and "Zulip updates"
have topics policy set to allow only "general chat" messages.
2025-07-22 16:59:47 -07:00
Mateusz Mandera
8f66e0b640 access_user_group_api_value_for_setting: Change arg to realm.
This is a cleaner interface, allowing this function to be called in
contexts without a user_profile object.
2025-07-22 12:02:06 -07:00
Vector73
a02614204a settings: Add can_set_delete_message_policy_group setting.
Adds new organization setting `can_set_delete_message_policy_group`
for defining who can set per-channel message delete permissions.

Fixes #34214.
2025-07-17 15:44:53 -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
ebbb208a47 streams: Extract channel description validation logic.
Fixes: Point 1 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
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
Tim Abbott
07bb806b28 streams: Extract access_requested_group_permissions.
This code will need to be called from both API endpoints for creating
channels soon.
2025-07-14 07:44:01 -07:00
apoorvapendse
cb487da45a streams: Set system_groups_name_dict in add_subscriptions_backend.
We need system_groups_name_dict in all cases.

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
opmkumar
4aab379e2a views: Sort parameters alphabetically. 2025-06-30 09:13:25 -07:00
Kislay Verma
ee8913e14b streams: Fix typos in comments.
This commit fixes some old typos in comments in views/streams.py file.
2025-06-26 10:08:11 -07:00
Kislay Verma
5f80f0a970 channel: Add option to notify users newly added to a channel.
When a user is added to a channel, we send
the user that was added a Notification Bot
DMs to let them know about it.

In this commit, we add an option for whether or not
this message is sent.

If more than 100 users are added at once, we
do not send notification bot DMs since it would
be a performance-costly operation.

We also send this threshold value of 100 in the
initial state data to the clients.

Fixes part of #31189
2025-06-26 10:08:11 -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
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
ad9abb8e2d streams: Use "isinstance" instead of "is" for "Missing" check. 2025-05-29 15:39:03 -07:00
Sahil Batra
2f34e6d24c streams: Add API support to update folder of a stream.
Fixes part of #31972.
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
whilstsomebody
2780360b00 unarchive: Add support for unarchiving archived channels.
This commit adds support for unarchiving archived channels
by introducing the `is_archived` parameter to the
`PATCH /streams/{stream_id}` API endpoint. Sending a PATCH
request with `is_archived: false` will unarchive the specified
channel.
2025-05-16 11:39:40 -07:00
Sahil Batra
d2ff4bda4c streams: Check creation permission when updating channel privacy.
User who did not have permission to create public channels
could create them by first creating a private or web-public
channel, if they had the permission to create them, and then
changing privacy of that stream to be a public stream.

Similarly user without permission to create private channels
could also create them.

This commit fixes both these bugs.
2025-05-15 15:37:41 -07:00
Kislay Verma
316d1cf285 topic_link_util: Use module to generate correct links.
In this commit, we use the said module instead of using
the `#**..**` syntax for channel and topic links.

Fixes #34608
2025-05-13 15:56:57 -07:00
Ritwik
2429157498 streams: Don't glue translated strings in new channel notification.
We now translate the whole notification message instead of substituting
an already translated policy_name. This avoids scenarios where only part
of the notification message is translated.

Fixes #30212.

Co-authored-by: Tanmay Kumar <tnmdotkr@gmail.com>
2025-04-15 16:28:38 -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
Kislay Verma
54be18d430 streams: Change text in notification bot DM.
This commit addresses the second bullet in
zulip#31206 (comment).
2025-04-15 10:35:59 -07:00
Alex Vandiver
d978363a75 topic: Enforce is_channel_message=True on topic queries. 2025-03-18 09:34:11 -07:00
Shubham Padia
9af5def4aa message: Add acting_user to internal_prep_private_message.
When a user was getting subscribed to a private stream, the stream name
was not linkified since acting_user was not passed. We also pass the
acting user in user_groups.py, even though it doesn't introduce any
behavioural change.
This commit does not attempt to pass acting user in similar message
functions and just focuses on fixing the problem of a private stream not
being linkified.
2025-03-18 09:08:00 -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
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
Tim Abbott
5b2bd07612 streams: Require content access to change channel privacy.
This code path had not been properly updated for the new ways of
having content access to a channel.

Also adjust the error messages for missing content access.
2025-03-07 18:08:41 -08:00
Shubham Padia
8481dcedc4 stream: Do not pass user group object when changing group setting.
Passing the user group object in case of named user group is fine for
`do_change_stream_group_based_setting`. But for anonymous groups, if the
code path calling that function is not creating a new anonymous user
group, it has to modify the user group by itself before calling that
function. In that case, if `old_setting_api_value` is not provided,
`old_user_group` is calculated false, since the group id has not changed
for the stream, but the group membership has changed.
old_setting_api_value will be the same as new_setting_api_value in such
a case.
It is better to accept the new setting value as either an int or
UserGroupMembersDict, so that `do_change_stream_group_based_setting` can
decide what to do with that argument.
2025-03-04 11:34:59 -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
bafec11c61 streams: Add new can_subscribe_group permission setting.
Fixes part of #33417.
2025-02-25 13:17:15 -08:00