933 Commits

Author SHA1 Message Date
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
Prakhar Pratyush
5f3896710f onboarding_steps: Add 'navigation_tour_video' for new users.
This commit adds a one-time modal to display navigation tour
video to new users.

Includes an `NAVIGATION_TOUR_VIDEO_URL` server-setting to specify
the video's URL. When set to None, the modal is not displayed.

Fixes #29304.
2025-03-13 14:38:16 -07:00
Vector73
b31024be47 saved_snippets: Add support for editing saved snippets.
Fixes #33708.
2025-03-13 10:58:36 -07:00
roanster007
2c548d4856 settings: Allow "resolve topic" permissions to be managed independently.
This commit separates the "resolve topic" permissions from the
topic editing permissions, through the introduction of setting -
"can_resolve_topics_group" which user group whose members
can resolve topics.

Fixes #21811
2025-03-12 19:32:35 -07:00
Alex Vandiver
721fd26442 send_email: Set the Date header according to local enqueue time.
Email clients tend to sort emails by the "Date" header, which is not
when the email was received -- emails can be arbitrarily delayed
during relaying.  Messages without a Date header (as all Zulip
messages previously) have one inserted by the first mailserver they
encounter.  As there are now multiple email-sending queues, we would
like the view of the database, as presented by the emails that are
sent out, to be consistent based on the Date header, which may not be
the same as when the client gets the email in their inbox.

Insert a Date header of when the Zulip system inserted the data into
the local queue, as that encodes when the full information was pulled
from the database.  This also opens the door to multiple workers
servicing the email_senders queue, to limit backlogging during large
notifications, without having to worry about inconsistent delivery
order between those two workers.

Messages which are sent synchronously via `send_email()` get a Date
header of when we attempt to send the message; this is, in practice,
no different from Django's default behaviour of doing so, but makes
the behaviour slightly more consistent.
2025-03-10 16:48:08 -07:00
Vector73
c049259d07 user: Remove is_billing_admin user property.
Removed `is_billing_admin` user property as it is no longer used since
billing permissions are now determined by `can_manage_billing_group`
realm setting.
2025-03-10 09:36:30 -07:00
Alex Vandiver
2a0f3c9746 message_send: Do not attempt to place a set into a message event.
This would have triggered exceptions in production, since orjson
cannot serialize sets.
2025-03-10 09:35:02 -07: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
Aman Agrawal
6801c6de7b message_edit: Fix moved msg not updated when user not sub of new stream.
Fixes #33719

If the user is not subscribed to the new stream but is a subsriber
of the old stream, we were not sending any update events to the user.
This results in unexpected behaviour related to the message.
2025-03-04 15:55:54 -08:00
Aman Agrawal
d9eedee017 message_edit: Extract function to remove duplicate users.
This functions helps exclude users for which we don't need to
send `update` event.
2025-03-04 15:55:54 -08:00
Shubham Padia
86579c02f3 stream: Send stream create/delete event on group setting change.
Fixes part of #33420.
If a group setting that can grant metadata access is changed, send a
create or delete event accordingly.
2025-03-04 11:34:59 -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
Shubham Padia
3fb2695a32 message: Add is_modifying_message argument to bulk_access_messages.
Although, currently there are no scenarios where we are using
bulk_access_messages for edit. But we might do so in the future, and
it's better to have an explicit argument called is_modiying_message in
that case, so that the person making that change makes a conscious
decision of setting that property.
2025-02-28 10:10:33 -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
5cca30d971 message: Allow accessing archived channel when not modifying message.
Fixes #33567.

We have used the flag `is_modifying_message` since it's more generic
than an archived channel specific flag and helps us understand better
what is the condition where we do not want to allow archived channels.
We have not added tests for message edit since it  has an existing test
for this.
2025-02-26 16:39:41 -08:00
Mateusz Mandera
9649e0d7c0 presence: Fix for last active time for invisible mode.
Co-authored-by: Tim Abbott <tabbott@zulip.com>
2025-02-26 12:51:57 -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
Saubhagya Patel
d0c5c1cacb settings: Add backend to change allow_edit_history to integer field.
This commit implements the backend of migrating the
`allow_edit_history` setting to
`message_edit_history_visibility_policy`.
This allows organizations, to have an intermediate setting to
view only the "Moves" history of the messages.

We still pass `realm_allow_edit_history` in `/register` response
though for older clients with its value being set depending on the
value of `realm_message_edit_history_visibility_policy`. We set
`realm_allow_edit_history` to `False` if the
`realm_message_edit_history_visibility_policy` is "None", and
`True` for "Moves only" or "All" message edit history.

Fixes part of #21398.

Co-authored-by: Shlok Patel <shlokcpatel2001@gmail.com>
Co-authored-by: Tim Abbott <tabbott@zulip.com>
2025-02-25 18:18:23 -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
Alex Vandiver
ba7ad3de94 send_email: If using AWS, automatically remove from suppression list.
When sending invites and password reminders, ensure that the email
address is not on the AWS SES suppression list.  Addresses often
mistakenly end up on there and are never removed; automatically
removing them, if necessary, before we reach out to attempt a signup
reduces support overhead and perceived buggy behaviour.
2025-02-24 21:48:04 -08:00
sanchi-t
b2bc8db6bc message_flags: Add skipped unsubscribed stream ids in the response.
Added `ignored_because_not_subscribed` field in the response of
`/messages/flags/narrow` endpoint.

Fixes a part of #23470.

Co-authored-by: Hemant Umre <hemantumre12@gmail.com>.
2025-02-23 13:59:46 -08:00
Anders Kaseorg
949e5004cb codespell: Fix typos caught by codespell.
“Brunch” wasn’t a typo, but, whatever.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-02-18 22:04:43 -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
Alex Vandiver
a7d513e5ec users: Remove unnecessary get_api_key helper.
Using the column name is clearer.
2025-02-13 12:40:53 -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
opmkumar
2a15da47d9 message_edit: Show typing indicator for message editing.
This commit adds typing indicators for message editing in stream
as well as in dm, if the send typing notification
for corresponding is enabled.

Based on earlier work in #28585.

Co-authored-by: Rohan Gudimetla <rohan.gudimetla07@gmail.com>

Fixes #25719.
2025-02-12 15:08:56 -08:00
opmkumar
c2821ef0f4 typing: Remove an unnecessary comment in zerver/actions/typing.py.
The comment was incorrectly placed and misleadingly suggested that
`long_term_idle` subscribers were excluded from `subscription_query`,
whereas they were not.
2025-02-12 15:08:56 -08:00
Aman Agrawal
3d5307c0a9 message_summary: Add markdown support for generated summary. 2025-02-12 13:23:42 -08:00
Tim Abbott
ca0babc7e9 message_summary: Don't meter analytics query as AI work. 2025-02-12 13:23:42 -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
roanster007
4789de2e96 markdown: Fix #-mention of private channel's topic made by system bots.
Previously when system bots used to `#-mention` a private
channel's topics in cases like moving messages of a private
channel, then the #-mentions were not rendered by the
markdown. This was because the system bots did not have
authorization to mention these channels.

This is fixed by passing down an `acting_user` parameter
in code paths involving sending these move message
notifications so that permission of acting_user to mention
the topic is verified for rendering the markdown, rather
than that of the system bot.
2025-02-12 12:50:25 -08:00
Shubham Padia
552b464de7 stream: Notify all users with metadata access when unarchiving. 2025-02-12 09:35:17 -08:00
Shubham Padia
3893dcfcb8 stream: Do not send redundant events to users with metadata access.
When a user gets access to a private channel, they get a stream creation
event. Channel admins and users in `can_add_subscribers_group` already
have metadata access to a private channel and therefore do not need to
be notified.
2025-02-11 15:09:16 -08:00
Shubham Padia
35f9305acb stream: Modify flag to allow access for users with metadata access. 2025-02-11 15:09:16 -08:00
Shubham Padia
9725de99e9 stream: Move bulk_get_subscriber_peer_info to subscription_info.
We were not able to use
get_user_ids_with_metadata_access_via_permission_groups in the function
in question due to a cyclic dependency to `lib/streams.py`.
2025-02-11 15:09:16 -08:00
Shubham Padia
48eec43f48 stream: Notify users with metadata access on unarchiving stream. 2025-02-11 15:09:16 -08:00
Shubham Padia
f6301c24fe stream: Notify users with metadata access for lib/streams.py.
Users in `can_administer_channel_group` and `can_add_subscribers_group`
have access to private channel metadata. They should be notified of
relevant events.
We've only made relevant changes to lib/streams.py in this commit to
make the changes small and reviewable.
2025-02-11 15:09:16 -08:00
Shubham Padia
9e09a240d7 stream: Pass is_subscribed to check_basic_stream_access.
Earlier, we were passing the whole subscription object to the function
in order to check if the user was subscribed or not. In the future
commits, we want to check that without fetching and passing the complete
subscription object and this commit will help us do that.
2025-02-11 15:09:16 -08:00
Aman Agrawal
2f5aea6604 message_summary: Add setting to put a monthly rate limit per user. 2025-02-06 12:03:24 -08:00
Aman Agrawal
7fb767c080 message_summary: Move cost per token configuration to settings. 2025-02-06 12:03:24 -08:00
Aman Agrawal
0bad785f03 message_summary: Log time to generate summary.
Mostly copy pasted things from markdown time logging.
2025-02-06 12:03:24 -08:00
Prakhar Pratyush
77baa05aa9 streams: Set realm stream fields to NULL when streams are deactivated.
When a stream configured for any of these settings is deactivated,
the corresponding realm settings should be set to NULL:
* new_stream_announcements_stream
* signup_announcements_stream
* zulip_update_announcements_stream
* moderation_request_channel

Earlier, we were not updating those realm settings to NULL.
We had helper functions like 'get_new_stream_announcements_stream'
to return None if the configured stream was deactivated.
But it makes more sense to just set them to NULL in DB.

This commit also includes a migration to clear those fields
if the configured channels are deactivated.
2025-02-05 12:21:55 -08:00
whilstsomebody
8a64940868 message_edit: Fix "(deleted)" not showing for empty edited DMs.
This commit fixes a bug introduced in commit `37f2c5bc788`,
where a message in DM is not updated to "(deleted)" when
left empty after editing.

Fixes: #33305
2025-02-04 11:02:30 -08:00
Aditya Kumar Kasaudhan
21412b9f79 channels: Auto-mark channel archival event messages as read.
Previously, channel archival event messages were unread in
archived channels, which makes the archived channel accessible
from the inbox view.
This commit fixes this issue by auto-marking the channel archival
event message as read.

Fixes: zulip#33258.
2025-02-04 11:01:20 -08:00
Alex Vandiver
4dfb285b5b message_summary: Reorganize settings and secrets.
This allows arbitrary litellm-supported backends.
2025-01-29 14:55:35 -08:00
Alex Vandiver
69524b48b5 message_summary: Switch to orjson. 2025-01-29 14:55:35 -08:00
Alex Vandiver
816dde5b9a message_summary: Factor out into the actions package. 2025-01-29 14:55:35 -08:00