Commit Graph

18473 Commits

Author SHA1 Message Date
Tim Abbott 47db96d730 migrations: Add migration for RealmAuditLog ordering.
Because this might impact how past RealmAuditLog-reading migrations
are processed, I think it's better to this one as an actual Django
migration, even though it has no actual SQL to run.
2024-06-26 17:18:50 -07:00
Lauryn Menard 673a01ea0c realm-deactivation: Send email to owners as part of deactivation.
Creates a new "realm_deactivated" email that can be sent to realm
owners as part of `do_deactivate_realm`, via a boolean flag,
`email_owners`.

This flag is set to `False` when `do_deactivate_realm` is used for
realm exports or changing a realm's subdomain, so that the active
organization owners are not emailed in those cases.

This flag is optional for the `deactivate_realm` management command,
but as there is no active user passed in that case, then the email
is sent without referencing who deactivated the realm.

It is passed as `True` for the support analytics view, but the email
that is generated does not include information about the support
admin user who completed the request for organization deactivation.

When an active organization owner deactivates the organization, then
the flag is `True` and an email is sent to them as well as any other
active organization owners, with a slight variation in the email text
for those two cases.

Adds specific tests for when `email_owners` is passed as `True`. All
existing tests for other functionality of `do_deactivate_user` pass
the flag as `False`.

Adds `localize` from django.util.formats as a jinja env filter so
that the dates in these emails are internationlized for the owner's
default language setting in the "realm_deactivated" email templates.

Fixes #24685.
2024-06-26 16:48:18 -07:00
Alex Vandiver 2eaf098c5d upload: Content-type is always defined. 2024-06-26 16:43:11 -07:00
Alex Vandiver 17fb23746f upload: Move methods into zerver.lib.upload from .base. 2024-06-26 16:43:11 -07:00
Alex Vandiver c826d80061 upload: Factor out common code into zerver.lib.upload. 2024-06-26 16:43:11 -07:00
Alex Vandiver c0d9a95aa8 email_mirror: Fix a misleading variable name. 2024-06-26 16:43:11 -07:00
Alex Vandiver 5cd10ce51d s3: Allow setting a CloudFront URL prefix for avatar and emoji images. 2024-06-26 16:43:11 -07:00
Alex Vandiver 08b24484d1 upload: Remove redundant acting_user_profile argument.
This argument, effectively added in 9eb47f108c, was never actually
used.
2024-06-26 16:43:11 -07:00
Alex Vandiver 41d1b417e7 avatars: Clean up now-irrelevant assumptions.
This x=x hack was removed in 3bd3173b1f.
2024-06-26 16:43:11 -07:00
Alex Vandiver fb929ca218 thumbnailing: Remove unnecessary third return value from resize_emoji. 2024-06-26 16:43:09 -07:00
Alex Vandiver 0070b5da78 tests: Switch from PIL to pyvips. 2024-06-26 16:42:59 -07:00
Alex Vandiver b14a33c659 thumbnailing: Switch to libvips, from PIL/pillow.
This is done in as much of a drop-in fashion as possible.  Note that
libvips does not support animated PNGs[^1], and as such this
conversion removes support for them as emoji; however, libvips
includes support for webp images, which future commits will take
advantage of.

This removes the MAX_EMOJI_GIF_SIZE limit, since that existed to work
around bugs in Pillow.  MAX_EMOJI_GIF_FILE_SIZE_BYTES is fixed to
actually be 128KiB (not 128MiB, as it actually was), and is counted
_after_ resizing, since the point is to limit the amount of data
transfer to clients.

[^1]: https://github.com/libvips/libvips/discussions/2000
2024-06-26 16:42:57 -07:00
Alex Vandiver 9fb03cb2c7 upload: Factor out common avatar logic. 2024-06-26 16:38:01 -07:00
Alex Vandiver d92993c972 upload: Factor out common emoji logic. 2024-06-26 16:38:01 -07:00
Alex Vandiver 872e2ad2cd models: Enforce an ordering to on audit logs to solve a flaky test.
Multiple events may be created with the same timestamp; we add a
default ordering by "id" such that these have a consistent ordering in
tests (to solve for flaky tests), as well as in the internal API.
2024-06-26 16:38:00 -07:00
Lauryn Menard d356577c29 api-docs: Add example for BigBlueButton meeting_name parameter.
Also adds a link to the BigBlueButton integration documentation in
the endpoint's main description.
2024-06-26 10:04:09 -07:00
Vector73 6aa3a55796 openapi: Reorder group-setting-value oneOf clause. 2024-06-25 15:37:31 -07:00
Vector73 b285e631e9 api_docs: Fix missing content from API documentation. 2024-06-25 15:37:31 -07:00
Kenneth Rodrigues 29cbdd5050 documentation: Convert to typed_endpoint. 2024-06-25 11:07:03 -07:00
Prakhar Pratyush 1b9143b511 onboarding: Update message contents to use triple quotes.
This commit updates the message contents to use triple quotes.

It helps to maintain a consistent pattern for multi-line strings
in 'zerver/lib/onboarding.py' file and it'll be a lot more
convenient to edit in that form in the future.
2024-06-24 10:44:30 -07:00
Lauryn Menard 3f8d5ea0ab api-docs: Update message_ids description in update_message event.
Clarifies that the ID of the edited message will always be included
in the `message_ids` list, even if there are no topic or channel
updates to be made.
2024-06-24 10:36:49 -07:00
Sahil Batra b44d30add7 events: Optimize computing can_create_streams and related fields.
Currently, for computing fields like can_create_public_streams
and can_create_private_steams fields, is_user_in_group is called
to check whether the user is part of the group which has the
permission. This means that there will be one DB query for each
field.

To optimize this, we now first fetch all the groups that the
user is member of, including the anonymous groups which are
used for settings, such that we can then just check whether
the user is part of the group which has the permission meaning
we would need only one query to compute all the fields.

This would be helpful when settings for other similar fields
will also be migrated to groups framework.
2024-06-24 10:00:08 -07:00
Mateusz Mandera 9f24b30e78 test_push_notifs: Adjust .filter() in test_analytics_api.
The test asserts entries about the zephyr realm anyway. The reason the
filter hasn't been limiting the query to zephyr is that we might
simultaneously want to ensure no other realms received changes - but
that doesn't seem quite right, given that the test doesn't dilligently
set up the initial conditions for all realms to have control over what
exactly happens with them. That makes this logic pretty fragile since if
some new (potentially unrelated) changes to Realm/RemoteRealm initial
state make it so some updates to other realms occur during the early
analytics upload calls in the test, the remote_audit_logs asserts here
will break in a very annoying to debug way.

If we want this query to be general, without limiting to the zephyr
realm, we could alter the test a bit to set up initial conditions
precisely.
2024-06-23 07:44:11 -07:00
Mateusz Mandera f8616fa013 analytics: Send ZULIP_MERGE_BASE to the bouncer. 2024-06-23 07:44:11 -07:00
Anders Kaseorg f7eecb0e03 sentry: Untangle from page_params.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-06-22 18:53:56 -07:00
tnmkr 9af71c690f custom_profile_fields: Fix "required" field in OpenAPI documentation.
This is not an optional field and should be present in all API responses
of custom profile field object.
2024-06-21 16:32:15 -07:00
tnmkr b6231f5568 zulip.yaml: Fix typo in IncludeCustomProfileFields description. 2024-06-21 16:32:15 -07:00
Vector73 5230aada2b python_examples: Validate error responses.
Adds assert statements to validate error response for "400" error code. The
current validation using `validate_against_openapi_schema` doesn't work for
"400" responses.

Adds separate functions to validate "200" and "400" responses and removes `validate_response_result`.
2024-06-21 09:49:07 -07:00
Alex Vandiver be9369541a create_user: Copy the avatar before announcing it. 2024-06-20 23:06:08 -04:00
Alex Vandiver 35f8c3c455 avatar: Clean up one callsite of deprecated avatar_url_from_dict. 2024-06-20 23:06:08 -04:00
Alex Vandiver 3ce06361c8 models: Document UserProfile.avatar_hash as LDAP-only. 2024-06-20 23:06:08 -04:00
Alex Vandiver 0153d6dbcd thumbnailing: Move resizing functions into zerver.lib.thumbnail. 2024-06-20 23:06:08 -04:00
Alex Vandiver 2c5dff7f59 thumbnailing: Remove unnecessary os.path adjustment.
This is a library file, not a binary; os.path is already set up.
2024-06-20 23:06:08 -04:00
Alex Vandiver 846cffe2fa name_restrictions: Reserve "avatar". 2024-06-20 23:06:08 -04:00
Sahil Batra 6164a41864 realm: Remove create_private_stream_policy setting.
This commit removes create_private_stream_policy setting as
we now use new group based setting.

The "/register" response includes realm_create_private_stream_policy
field to return a value representing superset of users who have the
permission to create private channels, as older clients still expect
this field.
2024-06-20 15:48:14 -07:00
Sahil Batra 0bae59fa4b streams: Check permission to create channels based on group setting.
This commit updates code to use new group based setting when
checking permission to create private channels.
2024-06-20 15:48:14 -07:00
Sahil Batra 27171d103e realm: Add new group setting for who can create private channels.
This commit adds new group based setting to control who can create
private channels.
2024-06-20 15:48:14 -07:00
Sahil Batra 428d4284f9 users: Update has_permission to accept realm as argument.
This commit helps in using the realm object which has the
prefetched group settings so that we can avoid extra queries
when calculating fields like can_create_public_streams.
2024-06-20 15:48:14 -07:00
Sahil Batra 048221212e realms: Do not prefetch settings in get_realm.
There is no need to prefetch group settings using select_related
in get_realm as we only need to save queries when computing the
setting values in fetch_initial_state_data and we already refetch
the realm using get_realm_with_settings for that.
2024-06-20 15:48:14 -07:00
Sahil Batra 19373d61e8 events: Do not call "can_create_..." functions twice.
There is no need to call settings_user.can_create_public_streams
and similar functions for private and web-public streams twice,
once to compute the field for a single stream type and one to
compute can_create_streams.

The value for each stream type can be used to compute value of
can_create_streams field.
2024-06-20 15:48:14 -07:00
Alya Abbott 2b9a0cbe52 updates: Add update about Reactions view, hiding sidebars, is:followed. 2024-06-20 15:30:47 -07:00
Anders Kaseorg 5f053c4aa7 upload: Serve more cross-browser audio and image formats as inline.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-06-20 15:29:20 -07:00
Anders Kaseorg fb4ad1422e mime_types: Add audio and image types missing from Python library.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-06-20 15:29:20 -07:00
Kenneth Rodrigues 15accfc983 narrow: Use NarrowParameter instead of dictionary.
Earlier we were using the type `OptionalNarrowListT` for all functions
that required "narrow" as a parameter.
This commit changes all the functions accepting a "narrow"
to use a list of the new `NarrowParameter`
instead of `OptionalNarrowListT` which is a list of dicts.
2024-06-20 12:22:37 -07:00
Kenneth Rodrigues 4e05381897 message_fetch: Migrate to typed_endpoint.
Removed the old `narrow_parameter` as we have shifted to
the new `NarrowParameter` Pydantic Object.
This new object provides better error messages for data validation,
hence changed the error messages in `test_message_fetch`.
2024-06-20 12:22:37 -07:00
Kenneth Rodrigues f791d1e1c0 test_message_fetch: Add support for list of error messages. 2024-06-20 12:22:37 -07:00
Kenneth Rodrigues a865977bd5 get_messages_backend: Pass required parameters.
Earlier `num_before` and `num_after` wasn't being passed while
testing.
Moving to typed_endpoint requires all the "required" parameters
to be passed to the function explicitly in tests.
2024-06-20 12:22:37 -07:00
Kenneth Rodrigues 387fba7156 custom_profile: Convert to typed_endpoint.
Convert `custom_profile_fields.py` to use `typed_endpoint`.

Use `TypedDict` from `typing_extensions` instead of `typing`,
to support Pydantic's type checking.
2024-06-19 18:29:28 -07:00
Lauryn Menard a9141f2277 api-docs: Update API feature level 36 rate limit error changes notes. 2024-06-19 17:49:02 -07:00
Lauryn Menard d0c25a9291 api-docs: Clarify error response keys and handling documentation.
Updates the main description of the API error handling article so
that the `code` key in the error reponse is more accurate.

Adds a bullet point to the API changelog for feature level 76 about
the `code` key being consistently in all error responses. This is
based on commit 8b9011dff8, which completed the migration to
JsonableError, at which point the API feature level was already
set to 75 and not yet set to 76.

Also, revises the other error related feature level 76 entries in
the API changelog.

Adds a header for  the common, shared error responses that are
documented on the error handling page, and updates those error
descriptions to include information about any extra fields and to
end with any changes notes.
2024-06-19 17:49:02 -07:00