Commit Graph

19825 Commits

Author SHA1 Message Date
Anders Kaseorg
e8faa4a029 worker: Check if Sentry is initialized before calling add_breadcrumb.
Otherwise we get spammed with “Dropped breadcrumb because no client
bound” log messages.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-04-08 10:17:49 -07:00
Ethan Mayer
c12b94aea4 models: Refactor corporate/models.py into models package.
Fixes #34318.

Seperated models file into a package with component files.
2025-04-08 10:16:35 -07:00
Ritwik
9feba0f16f emoji: Remap ':smile' emoji and update the settings UI.
This commit remaps the ':smile' emoji to 😄 and
introduces ':slight_smile' which maps to `🙂`.

Fixes #32712
2025-04-07 17:34:52 -07:00
Sahil Batra
f29166dbba settings: Do not pre-fetch DM permission group settings.
This commit updates code to not pre-fetch DM permission
group settings using select_related and instead just
fetch the required data from DB when checking permission.

This will increase one query but will help in pre-fetching
the settings for all users and for all type of messages.

Fixes part of #33677.
2025-04-07 15:34:30 -07:00
Sahil Batra
179782eaba user_groups: Refactor is_user_in_group and is_any_user_in_group.
This commit updates is_user_in_group and is_any_user_in_group
to accept group ID as parameter instead of UserGroup object.

This is a prep commit for updating code to not prefetch
direct message permissions group.
2025-04-07 15:34:30 -07:00
Varun-Kolanu
59d5d29ed8 integrations: Add support for GitLab design comments.
Fixes #26199.

Co-authored-by: Barış <barisunsalhn@users.noreply.github.com>
Co-authored-by: Satyam Bansal <sbansal1999@gmail.com>
2025-04-07 11:54:37 -07:00
Varun-Kolanu
aaa2db4079 webhooks: Support no_previews argument for markdown messages.
This commit enables skipping inline image previews
by passing the no_previews field to check_send_webhook_message.
2025-04-07 11:53:19 -07:00
Shubham Padia
12afeee277 test_classes: Mention actual and expected count in assert_length. 2025-04-07 10:19:57 -07:00
Shubham Padia
8ee80f29ae test_events: Explicitly subscribe both users to a stream when testing.
When testing `do_deactivate_user`, we were getting a non-deterministic
failure where `peer_remove` event was not being sent. We were unable to
figure out the exact reason why, but this commit subscribes both the
user being deactivated and the user receiving the event to a new channel
in the hopes of this event being always sent regardless of other test
conditions.
2025-04-07 10:18:52 -07:00
Mateusz Mandera
5814ac559f do_change_user_email: Store old and new email in the audit log.
We forgot to store the actual values in the audit log, making these logs
not very helpful in actually auditing a user's email change history.
2025-04-05 07:25:46 -07:00
Aman Agrawal
80c9698943 registration: Fix 500 error pages rendered without context.
We need `corporate_enabled` and some other params to render
500 error page which is not passed when using `server_error`,
as it only contains our custom inserted `DEFAULT_PAGE_PARAMS`.

We render the page with `zulip_default_context` to fix this.
2025-04-04 11:00:06 -07:00
Shubham Padia
53983c9eb9 users: Send peer_remove on deactivating user.
Tweaked by tabbott to clean up the API changelog.

Fixes #34245.
2025-04-03 18:07:31 -07:00
Alex Vandiver
c7da412b3b web: Sync content of Django and nginx error pages.
Also edit the text to more clearly explain the situation.
2025-04-03 17:09:46 -07:00
Tim Abbott
f15d12f257 registration: Document incorrect 500 template use. 2025-04-03 17:09:46 -07:00
Prakhar Pratyush
41df472d41 corporate: Replace /try-zulip with /?show_try_zulip_modal.
This commit removes the `/try-zulip` landing page.

The URLs are replaced with `chat.zulip.org/?show_try_zulip_modal`,
which leads to display a modal for spectators.

Fixes #34181.
2025-04-03 13:01:48 -07:00
Prakhar Pratyush
f64d7b6e28 home: Add a modal to replace /try-zulip landing page.
This commit adds a modal which will be displayed when
a spectator visits `/?show_try_zulip_modal`.

When a user visits `/?show_try_zulip_modal` and is a spectator,
we set a new `show_try_zulip_modal` field in `page_params` to
`true` (in all other cases, it's `false`).

Based on the `show_try_zulip_modal` page param, the web client
shows the modal.

Fixes part of #34181.
2025-04-03 13:01:48 -07:00
Sahil Batra
8528453db6 user_groups: Add do_reactivate_user_group function.
This commit adds do_reactivate_user_group which will be used
to reactivate user groups.

Fixes part of #23568.
2025-04-03 13:00:17 -07:00
Evy Kassirer
ea2fd69f67 subscription_info: Send partial subscriber info to client separately.
We're doing this so that the client can keep track of which channels
it might need to request full subscriber data from, and which already
have full subscriber data.
2025-04-02 16:19:05 -07:00
Alex Vandiver
bee3c6eb59 runtusd: Respect application_server.nginx_listen_port.
In deploys `nginx_listen_port` set, tusd would fail to send its hook
requests, as it assumed that nginx would always be listening on
127.0.0.1:80.

Set the `nginx_listen_port` on the hook URL, if necessary.
2025-04-01 09:28:18 -07:00
Evy Kassirer
1405dd630f subscription_info: Add option to get partial subscribers.
It returns just bots for now.
2025-03-31 22:13:50 -07:00
Mateusz Mandera
716ead8f4e export: Also add guardrail to the management command. 2025-03-28 17:44:58 -07:00
Mateusz Mandera
8ab400b95d export: Add guardrails against generating a dysfunctional export via UI.
As explained in the comments, if in an export with consent there are no
consenting owners or in a public export there are no owners with email
visibility set to at least ADMINS, the exported data will, upon import,
create an organization without usable owner accounts.
2025-03-28 17:44:58 -07:00
Mateusz Mandera
9864eee029 export: Add detailed tests for export of public vs private data.
Adds detailed tests for the work in the prior commits fixing the
treatment of private data in various tables in exports with consent and
public exports.
2025-03-28 17:44:58 -07:00
Mateusz Mandera
d098b9c349 export: Don't export DirectMessageGroup info of non-consented users.
This is private information, as by inspecting the DirectMessageGroup
objects and their associated Subscription objects, you could determine
which users conversed with each other in a DM group.

This did *not* leak any actual message - only the fact that at least one
of the users in the group sent a group DM.
2025-03-28 17:44:28 -07:00
Mateusz Mandera
0fd79e379e export: Fix public exports.
The prior significantly restricted what data gets exported from
non-consented users. The last thing we're missing is to fix the logic
to work correctly for public exports.

Prior commits focused on addressing exports with consent. This commit
adapts it to work with public exports.:
- Do not turn user accounts into mirror dummies in the public export - or
  after export->import you'll end up with a realm with no functional
  accounts; as every user is non-consented and the original logic added in
  the prior commits will turn them into mirror dummies.
- Some of the custom fetch/process functions were changed without
  considering public exports - now they work correctly, by setting
  consenting_user_ids to an empty set.
2025-03-28 17:44:28 -07:00
Mateusz Mandera
6695e8f9eb export: Scrub Subscriptions to defaults for non-consented users.
The Subscription Config is constructed in a bit of a strange way, that's
not compatible with defining a custom_fetch function.
Instead we have to extend the system to support passing a custom
function for processing just the final list of rows right before it's
returned for writing to export files.
2025-03-28 17:44:28 -07:00
Mateusz Mandera
03887bf871 export: Don't turn non-consented deactivated users into mirror dummies.
As explained in the comment, if we turn a non-consented deactivated user
into a mirror dummy, this will violate the rule that a deactivated user
cannot restore their account by themselves after an export->import
cycle.
2025-03-28 17:44:28 -07:00
Mateusz Mandera
85a98009cd export: Treat is_mirror_dummy=True users as consenting.
As explained in the comment added to the function, in terms of privacy
concerns, it is fine to export all data for these accounts. And it is
important to do - so that exporting an organization which was originally
imported e.g. from Slack doesn't result in excessively limited data for
accounts that were mirror dummies and never "activated" themselves.
2025-03-28 17:44:28 -07:00
Mateusz Mandera
a956c31645 export: Treat deactivated user with consent enabled as consenting.
Prior to this, deactivated user were presumed to be non-consenting to
private data export, regardless of their setting.
2025-03-28 17:44:28 -07:00
Mateusz Mandera
0b5d0a348e export: Fix get_consented_user_ids to also account for bots.
Now that we severely limited the way that non-consenting users get
exported, we need to start to consider bots as consenting when
appropriate - otherwise the exported bot accounts will be unusable after
importing.
2025-03-28 17:44:28 -07:00
Mateusz Mandera
82f17b14d3 export: Scrub RealmAuditLog rows where modified_user is non-consenting. 2025-03-28 17:44:28 -07:00
Mateusz Mandera
479b1dea84 export: Don't export real email of users unless accessible to admins.
An administrator shouldn't be able to bypass a user's setting to hide
their email address from everyone, including admins.
Therefore, we should overwrite the delivery_email for such users during
export - unless the user consented to have their private data exported.

The notable consequence of this is that such user accounts will become
completely inaccessible after importing this data to a new server, due
to not having a functional email address on record.

These accounts will only be possible to reclaim via a manual
intervention to change the email address on the `UserProfile` by server
administrators.
2025-03-28 17:44:28 -07:00
Mateusz Mandera
9a49b6a62c export: Plumb consented_user_ids to export_usermessage_batch in a file.
This allows us to get rid of the call to `get_consented_user_ids` in
`fetch_usermessages`. Now it's only called at the beginning of the
export, eliminating the redundant db query and also resolving the
potential for data consistency issues, if some users change their
consent setting after the export starts.

Now the full export process operates with a single snapshot of these
consenting user ids.

These ids need to be plumbed through via a file rather than normal arg
passing, because this is a separate management command, run in
subprocesses during the export.
2025-03-28 17:44:28 -07:00
Mateusz Mandera
b56b9d570d export: Reset settings to default for users not in exportable_user_ids.
These users didn't consent to having their private data exported.
Therefore, correct handling of these users should involve scrubbing
their settings to just match the realm defaults.
2025-03-28 17:44:27 -07:00
Mateusz Mandera
69da235ed1 export: Use exportable_user_ids arg to plumb through consenting users.
Instead of making repeated calls to get_consented_user_ids, we can just
fetch it (mostly) once and put it in
`context["exportable_user_ids"]`. This is essentially what the
(unused until now) exportable_user_ids logic was added for after all.

The added, intended, effect of this is that non-consenting users will
now get exported as mirror dummy accounts, due to the handling of
non-exportable users in `custom_fetch_user_profile`.

The remaining additional call to `get_consented_user_ids` is in
`fetch_usermessages`. This one is tricky as this function gets called
in subprocesses via
`zerver/management/commands/export_usermessage_batch.py` management
command invoked by the export process.
It requires passing the `exportable_user_ids` in some other way. This
can be dealt with in upcoming commits.
2025-03-28 17:44:27 -07:00
Mateusz Mandera
f2024ad625 export: Only export Client objects needed by the data being exported.
We shouldn't export the entire Client table - it includes Clients for
all the realms on the server, completely unrelated to the realm we're
exporting. Since these contain parts of the UserAgents used by the
users, we should treat these as private data and only export the Clients
that the specific data we're exporting "knows" about.
2025-03-28 17:44:27 -07:00
Mateusz Mandera
7e599cf959 export: Don't export miscellaneous private data of non-consenting users. 2025-03-28 17:44:27 -07:00
Anders Kaseorg
87e4b99706 custom_profile_fields: Restrict access to users in the same realm.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-03-28 17:41:32 -07:00
Anders Kaseorg
85abd9d58b realm_export: Restrict deletion to users in the same realm.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-03-28 17:40:22 -07:00
Aman Agrawal
83d917853e apps: Provide arm64 app build by default for macOS.
This reduces confusion amount users when they download the
intel version and it works super slow. Downloading the arm64
version on an intel mac would just not work.

Users who use intel macs have a habit now (atleast me) to look
for `Intel` version of software when downloading an app. So, made
`Intel` bold to help that process.
2025-03-28 16:45:07 -07:00
Alex Vandiver
9c043c6c14 tusd: Attempt to derive S3 region.
We already do this in computed_settings.py, but only if the
S3 (secret) key is set.  Those aren't required to be set, and tusd
_requires_ a region, so we try again to suss it out here.
2025-03-28 09:41:43 -07:00
Alex Vandiver
794588629d tusd: Support running without explicit AWS keys.
Fixes: #34102.
2025-03-28 09:41:43 -07:00
Prakhar Pratyush
7e20100ebd test_message_topics: Optimize test by limiting fetch_event_types.
Earlier, in 'EmptyTopicNameTest.test_initial_state_data',
we were not passing a short 'fetch_event_types' to 'do_events_register'
resulting in unnecessary work to fetch extra initial data which
isn't important for the test.

This commits updates the test to pass a 'fetch_event_types'
parameter with the event types required for the test.
2025-03-28 09:24:47 -07:00
Prakhar Pratyush
d011fb0621 typing: Rename "(no topic)" to empty string topic.
This commit renames "(no topic)" to "" when used as
topic name in `POST /typing`.

Message sent in "(no topic)" is translated as being
sent in "" by the server, so it makes sense to show
the typing notification in "" when message is being composed.
2025-03-27 09:29:49 -07:00
Anders Kaseorg
721f804736 middleware: Parse Accept header properly.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-03-26 22:29:09 -07:00
Lauryn Menard
e101f03b11 scheduled-message-tests: Use f-strings for setting message content. 2025-03-26 15:51:00 -07:00
Shubham Padia
559629345e test_subs: Test rendered content instead of just the content.
Without this test, a bug with the rendering logic that was fixed
by #34056 went unnoticed.
Fixes part of #34069.
2025-03-26 11:33:04 -07:00
Niloth P
b2910aa05c integration-docs: Migrate PythonAPIIntegration docs.
To zulip/python-zulip-api, to keep them closer to their source code.

- Renamed the generate_zulip_bots_static_files to
generate_bots_integrations_static_files to accomodate the new function.
- Added a new function to
tools/setup/generate_bots_integrations_static_files to copy the
integration docs into static/generated/integrations.
- Updated integrations.py and computed_settings.py to use the new doc
paths.
- Deleted the affected integration docs.
- Updated the dependency URL.
2025-03-26 11:19:31 -07:00
Niloth P
e76ace28d2 integration-docs: Rename Jira doc to avoid collision with Jira plugin.
The Jira plugin integration doc will be moved in the next commit, to
"static/generated/integrations/jira/doc.md", as the directory name of
the integration is "jira" in zulip/python-zulip-api.

- Jira integration doc (previously) - "zerver/webhooks/jira/doc.md"
- Jira plugin integration doc (next commit) -
"static/generated/integrations/jira/doc.md"

Both of these will use the same path "jira/doc.md" as their
integration.doc value, and the actual file is loaded based on the order
of template directories listed in computed_settings.py.

Hence, use a custom path for the Jira integration doc to avoid this
collision.
2025-03-26 11:19:31 -07:00
Niloth P
4b9317cee4 integrations: Add missing directory_name for Jira plugin integration. 2025-03-26 11:19:31 -07:00