933 Commits

Author SHA1 Message Date
Anders Kaseorg
33b8eabd9f message_flags: Fix type error.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-09-30 16:47:54 -07:00
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
764f4aa2e0 groups: Use realm_for_sharding for limiting NamedUserGroup queries.
For get and filter queries of NamedUserGroup, realm_for_sharding
field is used instead of realm field, as directly using
realm_for_sharding field on NamedUserGroup makes the query faster
than using realm present on the base UserGroup table.
2025-09-23 12:15:53 -07:00
Prakhar Pratyush
421637ce31 push_notifications: Skip enqueuing notif for users without push devices.
Previously, we enqueued events to "missedmessage_mobile_notifications"
even for users who had no registered push devices.
'handle_push_notification' later used to perform the check & skip
if there were no registered devices.

This commit avoids putting such events into the
"missedmessage_mobile_notifications" queue at all. By doing so,
we reduce unnecessary churn.
2025-09-17 12:32:49 -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
Alex Vandiver
9c92fe8f34 streams: Skip pickling the recipient string in cache. 2025-08-27 09:22:56 -07:00
Mateusz Mandera
51cef01c29 message: Use .is_channel_message column instead of is_stream_message().
This avoids a potential unnecessary message.recipient fetch required by
is_stream_message(). is_stream_message() methods precedes the addition
of the denormalized is_channel_message column and is now unnecessary.

In practice, we usually fetch Message objects with `.recipient` already,
so I don't expect any notable performance impact here - but it's still a
useful change to make.
2025-08-19 23:37:07 -07:00
Alex Vandiver
7480510aeb embeds: Propagate group membership before updating UserMessage flags. 2025-08-13 10:38:40 -07:00
Vector73
f1d1d5f1a4 events: Add support for sending presence events in modern format.
If the client has passed `simplified_presence_events` as true
in the `client_capabilities` parameter of the `POST /register`
request, then the server will send `presence` events with the
`presences` field, which has the user presence data in the
modern API format. When that client capability is false, the
`presence` event will be unchanged and sent with the user
presence data in the legacy format.
2025-08-12 12:37:54 -07:00
Sahil Batra
5675860707 channel-folders: Send event when reordering channel folders. 2025-08-12 11:17:17 -07:00
Saubhagya Patel
bb5c87e306 bots: Add a setting to customize the Welcome Bot message.
This commit includes the following changes:
- Add an administrator setting to customize the Welcome Bot
message when sending an invitation.
- Add an API endpoint to test the customized Welcome Bot message
by sending a copy of the message to the administrator.

Fixes #27663.

Co-authored-by: Akarsh Jain <akarsh.jain.790@gmail.com>
2025-08-08 18:59:37 -07:00
Kislay Verma
f0a88d51cc message_reminders: Add support for notes.
This commit adds the ability for users to include notes
with their message reminders.

Fixes #35070.

Co-Authored-By: Aman Agrawal <amanagr@zulip.com>
2025-08-07 17:13:12 -07:00
Shubham Padia
22b231ab6f channel-folders: Add PATCH method to reorder channel folders.
The test cases are copied from ReorderCustomProfileFieldTest since we
are imitating the reordering mechanism from custom profile fields to
channel folders.
2025-08-06 16:34:40 -07:00
Vector73
f689dfc3c3 message_move: Mark notification messages as read for acting user.
When moving messages, the notification messages should be
automatically marked as read for the user who moved the messages.
2025-08-05 15:27:08 -07:00
Rohan Gudimetla
cb01bdf0c4 topics: Follow topics that are merged into even after merge.
Previously, when there were two topics -- A and B, and a user
follows topic A, then when messages of topic B are merged into
topic A then topic A loses its follow status.

This is fixed by updating the algorithm for getting the visibility
policy after merge to be followed in the above case.

Fixes #35226
2025-07-28 12:35:30 -07:00
Rohan Gudimetla
8330e7c283 topics: Refactor method that decides topic visibility after merge.
This commit refactors the method
which determines the visibility of two topics merged.

This is a preparatory commit for #35226.
2025-07-28 12:35:30 -07:00
Pratik Chanda
e7629ef07d message_flags: Fix message flags not updating for wildcard mentions.
Earlier, editing a message with wildcard mention and removing the
wildcard mention didn't properly remove the corresponding flag for
it in the message object. It was only updating flags when mentions
were present in new message but not the other way around.

This commit fixes this behaviour by removing flags if the new message
removed mention from it.
2025-07-24 11:52:20 -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
Mohammad Reza Kianifar
d02cafce52 welcome_bot: Support auto-reply for 1:1 DMs using DM groups.
Welcome Bot should auto-reply to users in 1:1 DMs, including when
the direct message group recipient model is used. This ensures
the bot detects and responds to messages where it is a recipient,
for both PERSONAL and DIRECT_MESSAGE_GROUP recipient types.

Fixes: part of issue #25713.
2025-07-21 22:48:01 -07:00
Mohammad Reza Kianifar
9c036024bd scheduled_messages: Set read_by_sender for self-DMs using DM group.
When using direct message group as the recipient for 1:1 or self DMs,
ensure read_by_sender is set correctly when scheduling a message.
2025-07-21 22:46:38 -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
Anders Kaseorg
3be686fa86 requirements: Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-07-15 07:32:44 -07:00
Aditya Kumar Kasaudhan
0b37ef6a9b email: Bulk clearing of scheduled emails for multiple users.
This commit is a preparatory step for allowing organization owners to
reset user preferences, refactors the `clear_scheduled_emails` function
to support bulk operations.
2025-07-11 14:15:49 -07:00
Rohan Gudimetla
26abfc4d91 markdown: Render inline audio files using the ![title](url) syntax.
Previouly, there was no option to play the inline audio files
within the web app without downloading or leaving the browser.

This commit adds option to render inline audio files that use
the syntax `![title](url)`.

Fixes #27007
2025-07-11 13:11:56 -07:00
Vector73
d0bc9b8f92 message_edit: Cleanup empty topic check. 2025-07-10 08:32:53 -07:00
Mateusz Mandera
a61d849e37 ldap: Implement external auth id auth+sync.
Fixes #24104.
2025-07-09 15:31:17 -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
roanster007
0b2cb835f5 topics: Apply automatic follow/unmute when message moved to new topic.
This commit adds a feature, wherein when someone moves a user's
message to be the first message in a topic, and the user has the
Automatically follow topics initiated enabled, then the new topic will
also be followed by the user.

Similarly, if the user has Automatically unmute topics initiated
enabled, the moved topic would also be unmuted.

Fixes #28408.
2025-07-08 11:18:15 -07:00
Lauryn Menard
ca48ffccb8 realm-create: Update default user email visibility for org_type.
When creating a new organization, the new user default for email
address visibility is now limited to admins for most organization
types. The exceptions are education organizations, which have the
default set to moderators, and business organizations, which have
the default set to all users.

Fixes #34859.
2025-07-08 09:30:39 -07:00
Mateusz Mandera
fe993032a6 validate_email_not_already_in_realm: Add kwarg for mirror dummies.
In user signup context, we are okay with there being an existing mirror
dummy user with the matching email - at the end of the signup, that
mirror dummy account will be activated and control of it given to the
user doing this signup.

However, in email change contexts (SCIM API and regular email change
flow), we can't change an account's email address to the address that
already belongs to an existing mirror dummy user.

To avoid subtle bugs like this, we make callers have to explicitly
specify whether existance of mirror dummies with the matching email
address is okay or not.
2025-07-07 17:15:08 -07:00
Mateusz Mandera
9abdb17d1f do_start_email_change_process: Don't revoke USED EmailChangeStatus objs.
We obviously shouldn't set such objects to REVOKED as that introduces
misleading information into our data. USED objects cannot be re-used, so
they can stay as they are.
2025-07-07 17:15:08 -07:00
Aman Agrawal
25731859b6 zerver: Add endpoints and events for reminders.
There are similar to what exists for scheduled messages expect
the PATCH requests which will be added later when the
functionality is implemented.
2025-07-02 12:47:00 -07:00
PieterCK
38d2a95aa1 users: Add acting_user to do_update_outgoing_webhook_service.
The `acting_user` parameter is added in preparation to make
`do_update_outgoing_webhook_service` log `RealmAuditLog` when updating
bots service. It doesn't have any use as of right now.
2025-07-01 13:24:58 -07:00
PieterCK
fb229a013e actions: Refactor do_update_outgoing_webhook_service.
This updates `do_update_outgoing_webhook_service` to use
`BotServicesOutgoing` as the schema for the updated service data we send
back to client because it's the schema `bot_data.update` expects.

The function is also refactored to allow updating specific fields of the
Service row instead of requiring all value for the Service fields to be
passed.

This is a prep commit for #34524, it adds another field to the Service
field.
2025-07-01 13:24:35 -07:00
Kislay Verma
6bd6f23549 url_encoding: Add support for with message links.
We abstract away "near" vs "with" from the function names and
allow callers to specify whether they want a conversation_link,
ie, use the "with" operator. The default choice is "near".
2025-06-30 11:19:00 -07:00
Aman Agrawal
766bef89b7 scheduled_messages: Extract method to notify new scheduled messages. 2025-06-30 11:12:45 -07:00
Mateusz Mandera
9e3a9b4349 process_new_human_user: Update comments.
These comments miss to mention adding to user groups on the list of
things done with the new user account.
2025-06-25 17:38:12 -07:00
Anders Kaseorg
9ebf461998 user_settings: Add event_value type annotation.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-06-25 11:49:02 -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
Tim Abbott
8179a31dc7 docs: Delete legacy presence subsystem page.
Everything on this page is now better explained in the API
documentation for presence.
2025-06-19 15:20:15 -07:00
whilstsomebody
01935c5be2 message_delete: Fix flaky 'do_delete_messages' function.
This commit fixes a flake in `do_delete_messages`, because of
which `test_do_delete_messages_grouping_logic` test occasionally
failed due to nondeterministic ordering of "delete_message" events.

The root cause was that the dictionaries used to group private
and stream messages for deletion (`private_messages_by_recipient`
and `stream_messages_by_topic`) were not sorted before generating
the events. While the `message_ids` within each event were already
sorted, the order of the events themselves could vary based on
the insertion order of the dictionaries, especially when running
tests in different sequences.

We now sort both `private_messages_by_recipient` and
`stream_messages_by_topic` before emitting events, ensuring
consistent ordering.
2025-06-19 15:03:59 -07:00
Evy Kassirer
4313648ca5 streams: Add subscriber_count to page load data. 2025-06-19 14:25:41 -07:00
Prakhar Pratyush
7970e1fa45 streams: Fix error while sending notice in deactivated stream.
Sending messages to a deactivated stream is not allowed with
the exception of notices sent in "channel events" topic.

Earlier, notice sent to a deactivated stream when it is
deactivated was working correctly but it was resulting in
an error in the following cases:
* Renaming stream
* Changing stream description
* Changing message retention period
* Changing posting permission
* Changing access permission

This commit makes sure to send notice successfully in those cases.
2025-06-19 12:47:54 -07:00
Sahil Batra
b655bd14ea messages: Use "\x07" as topic for DMs and group DMs.
This commit updates code to use "\x07" as value for
"subject" field of Message objects for DMs and group
DMs, so that we have a unique value for DMs and group
DMs which cannot be used for channel messages.

This helps in avoiding having an empty string value as
topic for DMs, which is also used for "general chat"
channel messages, as large number of DMs in the realm
resulted in PostgreSQL query planner thinking that there
are too many "general chat" messages and thus generated
bad query plans for operations like fetching
"general chat" messages in a stream or moving messages
to and from "general chat" topic.

This change as done for ArchivedMessage and
ScheduledMessage objects as well.

Note that the clients still get "subject" value as
an empty string "".

This commit also adds tests for checking that "\x07"
cannot be used as topic for channel messages.

Fixes #34360.
2025-06-19 10:44:37 -07:00
Shubham Padia
00fe2236da message_delete: Sort message_ids when sending delete_message event.
Fixes #34324.
https://chat.zulip.org/#narrow/channel/412-api-documentation/topic/Make.20message_ids.20from.20message.20update.20event.20sorted
2025-06-18 16:48:21 -07:00
Shubham Padia
37bfb7c963 message_edit: Sort message_ids when sending update_message event.
https://chat.zulip.org/#narrow/channel/412-api-documentation/topic/Make.20message_ids.20from.20message.20update.20event.20sorted
2025-06-18 16:48:21 -07:00