Commit Graph

19720 Commits

Author SHA1 Message Date
Alex Vandiver
67bea1f103 cache: validate_cache_key in cache_delete_many may get other prefixes. 2025-03-05 09:48:19 -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
ImDooMLorD
b6f09b6dab errors: Use shared class for message when email is already in use.
Replaces "Email '{email}' already in use" with "Email is already in use."
2025-03-04 16:10:25 -08:00
Alex Vandiver
66bad1da39 send_email: Skip the ScheduledEmail table for 0-delay emails. 2025-03-04 16:09:25 -08:00
Alex Vandiver
c5200e8b05 deliver_scheduled_emails: Use a queue, instead of infinite retries.
`deliver_scheduled_emails` tries to deliver the email synchronously,
and if it fails, it retries after 10 seconds.  Since it does not track
retries, and always tries the earliest-scheduled-but-due message
first, the worker will not make forward progress if there is a
persistent failure with that message, and will retry indefinitely.
This can result in excessive network or email delivery charges from
the remote SMTP server.

Switch to delivering emails via a new queue worker.  The
`deliver_scheduled_emails` job now serves only to pull deferred jobs
out of the table once they are due, insert them into RabbitMQ, and
then delete them.  This limits the potential for head-of-queue
failures to failures inserting into RabbitMQ, which is more reasonable
than failures speaking to a complex external system we do not control.
Retries and any connections to the SMTP server are left to the
RabbitMQ consumer.

We build a new RabbitMQ queue, rather than use the existing
`email_senders` queue, because that queue is expected to be reasonably
low-latency, for things like missed message notifications.  The
`send_future_email` codepath which inserts into ScheduledEmails is
also (ab)used to digest emails, which are extremely bursty in their
frequency -- and a large burst could significantly delay emails behind
it in the queue.

The new queue is explicitly only for messages which were not initiated
by user actions (e.g., invitation reminders, digests, new account
follow-ups) which are thus not latency-sensitive.

Fixes: #32463.
2025-03-04 16:09:25 -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
opmkumar
1d33214b55 narrow: Allow spectators to use is:resolved.
Fixes #33568.
2025-03-04 11:37:21 -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
Prakhar Pratyush
dd181bd03f migrations: Update rename_general_chat_to_empty_string_topic migration.
Earlier, the migration code was replacing the occurrence of "general
 chat" as topic name in the database with `""`. This resulted in an
error which permanently broke `/near/` URL links to existing topics
named "general chat".

This commit updates the migration approach to instead move messages
from "general chat" to `""`. An edit history entry is added.

It results in the same expected behaviour and fixing that bug.
2025-03-04 11:02:08 -08:00
Apoorva Pendse
a33d7bacb9 compose_paste: Use katex-mathml for inline math filtering.
This is better than using `.katex` as sometimes
the selection range starts from the `.katex-mathml`
node.

Since `.katex-mathml` is always the immediate child
of `.katex`, this filtering/replacement change will
make copy pasting inline expressions better.

Fixes: https://chat.zulip.org/#narrow/channel/9-issues/topic/.F0.9F.93.82.20pasting.20LaTeX/near/2104904
2025-03-03 14:30:38 -08:00
Tim Abbott
d4da66b6af migrations: Fix typo in migration 0669. 2025-03-02 23:59:13 -08:00
Tim Abbott
d02527b1a8 zulip_updates: Tweak channel permissions text. 2025-02-28 17:12:25 -08:00
Tim Abbott
1044af0015 api: Clarify semantics of sender_id for message edit typing. 2025-02-28 13:23:52 -08:00
opmkumar
c97fd1bca5 api: Rename edit typing endpoint to /messages/{message_id}/typing.
This is more consistent with how other URLs work in Zulip.

Replaces `/message_edit_typing` with `/messages/{message_id}/typing`.
The `message_id` parameter, previously passed in the request body,
is now included in the URL path.
2025-02-28 13:20:46 -08:00
Alya Abbott
61db2bc158 integrations: Update GitHub intergation for new configuration UI. 2025-02-28 13:04:42 -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
Shubham Padia
0def74b097 message: Make is_modifying_message a mandatory kwarg.
This is valuable so that one is forced to explicitly make a decision
on what is correct when adding new callers. Past experience tells us that
not having to explicitly show the decision leads to people introducing
security bugs in PRs that the maintainer has to catch in review, and our
goal for access control code should be that security bugs are hard to write.
Fixes #33688.
2025-02-28 10:10:33 -08:00
Shubham Padia
1a84a30759 typing: Add archived stream tests for typing and message_edit_typing.
Fixes part of #33688.
2025-02-28 09:27:28 -08:00
Shubham Padia
da7354ca89 message: Make is_modifying_message a mandatory kwarg.
This is valuable so that one is forced to explicitly make a decision
on what is correct when adding new callers. Past experience tells us that
not having to explicitly show the decision leads to people introducing
security bugs in PRs that the maintainer has to catch in review, and our
goal for access control code should be that security bugs are hard to write.
Fixes part of #33688.
2025-02-28 09:27:28 -08:00
Shubham Padia
0f7982e4c8 test_markdown: Add content and metadata access asserts.
It's good to verify the claims we are making in the comments before the
actual test code block.
2025-02-28 09:03:38 -08:00
Aman Agrawal
7e16a4e778 test_message_summary: Fix failing tests.
Tests were failing due to credit usage being capture in the next
month instead of current if the current time is last day of the
month. To fix this, we mock current time to not be the last day
of any month.
2025-02-28 12:10:16 +05:30
Alya Abbott
986837af01 updates: Add update message (level=13). 2025-02-27 16:55:34 -08:00
Sahil Batra
c2f1b3673e register: Optimize computing realm group setting values.
We do not fetch all the realm group settings using
select_related for register data now since it takes a
lot of time in planning phase. This commit updates
the code to fetch all the members and subgroups data
in user_groups_in_realm_serialized so that we do not
need to access each setting group individually.

user_groups_in_realm_serialized is updated to send the
required data accordingly.

Fixes #33656.
2025-02-27 10:03:28 -08:00
Sahil Batra
643182ce42 user_groups: Refactor code in user_groups_in_realm_serialized.
Following improvments are done in user_groups_in_realm_serialized-
- Members and subgroups are fetched using a single query using
union.
- Query to fetch groups now does not fetch setting fields since
we already have the members and subgroups of all the setting
groups and we can check if setting group was a named group
or not directly without checking named_user_group field of
UserGroup object as we have IDs of all named groups of the realm.
2025-02-27 10:03:28 -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
Prakhar Pratyush
1ac7c2b942 migration: Handle conflict in UserTopic when topic="" pre-exists.
When a channel has both "general chat" and "" topic and a user
has visibility policy configured for both the topics, then
the migration to rename "general chat" to "" resulted in error
as it violated '(user_profile_id, stream_id, lower(topic_name)'
unique constraint.

This commit fixes the error.

For each row with topic="general chat", we create a new row
with topic="". On conflict we update the visibility policy
of the existing row -- we prefer the visibility policy of
'general chat' topic over "" as we're renaming 'general chat'
to "" so the configured policy of 'general chat' should be
preferred and any "" topic created wouldn't be intentional
or would be for testing purpose as it is not announced yet.

Finally, we delete the rows with "general chat" topic.
2025-02-27 09:44:27 -08:00
Aditya Kumar Kasaudhan
18d83534ff github: Include old issue number in transfer message for new repo.
This commit updates the GitHub webhook integration to include the
old issue number in the transfer message sent for the new repository,
alongside the old repository's full name.
2025-02-27 09:22:15 -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
Prakhar Pratyush
1462c8ac1b migration: Rename 'general chat' topic to empty string topic.
Zulip now supports empty string as a valid topic name.

For clients predating this feature, such messages appear
in "general chat" topic. Messages sent to "general chat" are
stored in the database as having a "" topic.

This commit adds a migration to rename the existing
"general chat" topic in the database to "".

Fixes parts of #32996.
2025-02-26 13:53:39 -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
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
Alya Abbott
4aa83de15b help: Add article on viewing group members. 2025-02-25 13:26:41 -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
Anders Kaseorg
1f085a920a zephyr: Switch from py3dns to dnspython.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-02-25 11:53:08 -08:00
Tim Abbott
0338fd7357 get_realm_with_settings: Fix unnecessary joins with channel.
We were not actually using anything but the IDs here, so it was a
bunch of wasted work to fetch these.

This essentially reverts f48e87cd3c. At
the time, something like that was required, because we needed to check
if the channel was deactivated before exposing it to the API, but more
recent reworking of the system to change the setting if the channel is
deactivated, rather than masking it in fetch_initial_state_data, means
we can do this cleanup.
2025-02-25 11:42:04 -08:00
Anders Kaseorg
498c6c485e zephyr: Fix compute_mit_user_fullname for py3dns returning bytes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-02-25 10:39:45 -08:00
Anders Kaseorg
d7556b4060 requirements: Migrate to uv.
https://docs.astral.sh/uv/

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-02-24 22:29:24 -08:00
Anders Kaseorg
72f5df2e09 install: Remove --cacert and CUSTOM_CA_CERTIFICATES.
This has been broken for many years and nobody’s complained.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-02-24 22:29:24 -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
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
Niloth P
82ddc73df7 integration-docs: Add context properties for PythonAPIIntegrations.
Updated the change-zulip-config-file macro to use a newly added
context parameter, demonstrating its purpose.
2025-02-24 17:04:58 -08:00
Niloth P
f78f4b0e4b python-api-integrations: Map to directory names used in the API repo.
Added a `directory_name` field in PythonAPIIntegration objects to map
each integration to their corresponding directory in
zulip/python-zulip-api.
2025-02-24 17:04:58 -08:00