Commit Graph

47923 Commits

Author SHA1 Message Date
Zixuan James Li d1acd67897 test_realm: Fix realm confirmation object test case.
We are no longer creating confirmation objects associated with realms
directly. This should test for `RealmReactivationStatus` instead.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-27 17:07:11 -07:00
Zixuan James Li ed77684427 models: Add RealmReactivationStatus to ConfirmObjT.
We added RealmReactivationStatus as a possible confirmation object
in #22584. We also need to add this type to ConfirmationObjT.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-27 17:07:11 -07:00
Mateusz Mandera 43213ea37b realm_reactivation: Migrate old Confirmations to the new data format.
cf74d7d140 changed what .content_object on
these Confirmations is, but old Confirmations still need to be migrated
to that to make sense.
2022-07-27 17:06:19 -07:00
Alya Abbott 7be4146980 corporate: Add Senior Frontend Engineer job opening to /jobs. 2022-07-27 16:36:14 -07:00
Alya Abbott 8f316ce4e8 corporate: Remove technical writer job opening. 2022-07-27 16:36:14 -07:00
rodwan-bakkar bfd9fc8622 integration: Fix integration with newrelic.
Newrelic updated the payload that's sent via the webhook incoming call
causing a bug in the newrelic webhook endpoint.
This fixes the bug by updating the endpoint to respect the new format
of the payload as well as the old format. This should be updated once
the old format is EOLed.

Fixes #22338.
2022-07-27 16:15:29 -07:00
sahil839 594724b834 stream: Do not hide stream email on live update after unsubscribing.
We currently show stream emails for subscribed and unsubscribed
streams in stream settings overlay and don't show them for never
subscribed streams.

There is a bug where we show the empty container without email on
live update after unsubscribing and then we completely hide the
email element after we switch the stream and come back to it
again. But then we again show emails for unsubscribed streams
after reload, to preserve the beahviour of showing the emails of
unsubscribed streams.

This commit fixes this bug by not hiding stream email on live
update after unsubscribing and also showing them after switching
between different streams and makes it consistent with showing
emails for unsubscribed streams.

Fixes #22308.
2022-07-27 16:07:01 -07:00
anurastogiji 32615c81f2 popovers: Add topic auto-complete to "Move topic" menu.
We add topic auto-complete to the left sidebar menu as sometimes user
may want to merge the topic they are moving with an existing topic.

With a tweak by tabbott to remove a now incorrect comment.

Fixes #19876.
2022-07-27 16:01:03 -07:00
Ganesh Pawar e59512764d modal: Use font-weight 600 for modal title. 2022-07-27 14:37:32 -07:00
Zixuan James Li 06d3f3cf64 2fa: Refactor is_2fa_verified to require type narrowing.
This makes it mandatory to narrow the type of the user to `UserProfile`
before calling this helper.

This effectively removes the `request.user` check. We do not call login_page
anywhere else without getting through the authentication middleware.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-27 14:28:31 -07:00
Adam Sah c6931434e9 email_error: Improve tests for inbound email edge case.
Tests to assist with clarifying #22585.
2022-07-27 13:53:16 -07:00
David Rosa 268dbd3172 help-docs: Fix instructions for the "Logging out" mobile app feature.
The instructions for logging out are not accurate.

Fixes the instructions and replaces the iOS and Android tabs with
a single Mobile tab.

Adds a Related articles section with links to "Logging in",
"Switching between organizations", and "Deactivate your account".
2022-07-27 13:51:14 -07:00
David Rosa f060d5c870 help-docs: Standardize on "corner of the app" instead of "...screen".
The phrasing "corner of the screen" wouldn't be accurate when the user
is doing a split screen or if the window or app is not taking up the
whole screen. Also, the use of "lower/upper" and "top/bottom" is not
consistent.

This standardizes on "corner of the app" and "bottom/top" when
referring to the location of app features on Desktop, Web, or Mobile.
2022-07-27 13:51:14 -07:00
David Rosa 0f7742ec4d help-docs: Improve "Logging in" and "Switching between organizations".
Improves step-by-step instructions for Desktop users by directing
users to the relevant items in the left sidebar or top menu bar
without using an obscure keyboard shortcut.

Adds tip macro with instructions for toggling the app's left sidebar
via the top menu bar.

Moves the proxy settings and custom certificate info into a warning
block instead of the main instructions flow given they are rarely
needed for Logging in.

Adds a Related Articles section to "Switching between organizations"
so that users can access the information for setting an organization
profile picture from there instead of an oddly placed warning block.

Also adds links to "Logging in", "Logging out", and "Deactivate your
account", and lists them in each other's Related articles sections.
2022-07-27 13:51:14 -07:00
David Rosa 26b51d9393 help-docs: Replace mobile profile menu instructions with macro.
Adds a macro with instructions for accessing the profile menu for
reusability in "Logging out" and "Switching between organizations".

Reorders tabs Web > Desktop > Mobile for consistency.
2022-07-27 13:51:14 -07:00
Zixuan James Li 01d3df0551 storage: Fix type annotation of content.
Currently django-stubs expects `File` to be generic, this is not yet
supported. We quote it for now before django-stubs gets integrated.

TODO: unquote this in the future.

See also: https://github.com/typeddjango/django-stubs/issues/1061#issuecomment-1185995937.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-27 13:46:13 -07:00
David Rosa a5eea68cf5 help-docs: Fix cross-links to help center pages about linking to Zulip.
Renames the main heading of "Linking to your organization" to match up
with the sidebar index title and adds a "Related articles" section.

Fixes cross-link title in "Link to a message or conversation".

Fixes: #22590.
2022-07-27 13:44:59 -07:00
Zixuan James Li 07eccbde97 test_docs: Add assertion check.
In the test case `test_check_if_every_integration_has_logo_that_exists`,
`urlsplit(integration.logo_url).path` gets inferred as possibly bytes
because `integration.logo_url` might be `None`.

5598b49851/stdlib/urllib/parse.pyi (L166-L169)

TODO:
We might want to ensure that every integration has a `logo_url` with an
explicit assertion in `Integrations` (as noted in the comment).

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 4e240b880e migrations: Define emoji_to_lowercase outside.
The `self` argument should otherwise present.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 90a31d9e66 templates: Narrow the type of jinjia to Jinja2.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 223a1ad0eb test_auth_backends: Add None checks.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 51df4031ac test_auth_backends: Extract external_auth_backends.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li d3f976a0a3 message_flags: Add an assertion check for stream.recipient_id.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 7233ad454f auth: Add an assertion check for context_data.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li d238a448e6 test_draft: Avoid inference with type annotation.
`expected_draft_contents` would be inferred as a list of mutable
mappings that only allow `int` as the value, and thus incompatible with
the `draft_dicts[i]` to be expanded. This is fixed by adding explicit
type annotation.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 56e22e1a92 forms: Fix to_python method signature.
According to the documentation, `to_python` should account for `None`
being a possible value to be processed.

See also: https://docs.djangoproject.com/en/4.0/howto/custom-model-fields/#converting-values-to-python-objects.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 7bf58dbede test_auth_backends: Remove unused self.user_profile.backend.
This was added in d43b031a32 and was
unused when it was added. This is an error that we want to remove.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 4493f74507 models: Move the assertion checking bot_owner_id.
Both code blocks need to have an assertion ensuring that `bot_owner_id`
is not `None`.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 11a23aa5ef test_audit_log: Fix an assertion for a function that never returns.
We likely just wanted to check that `validate_password` succeeds without
any exception being raised. A simple call is sufficient to verify that,
since `validate_password` does not return anything and raises an
exception on failure.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 4675cbfefd test_message_flags: Remove unused comma.
This was accidentally added in 20a97bdb05,
likely due to some typos.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li b0c5db1c22 test_realm_emoji: Remove redundant assertion.
This check was added in 495a8476be.
Now that django-stubs finds that the left operand of the `and` will
always evaluates to `True`, so it makes sense to remove it.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 3ba51ef1e2 queue_processor: Fix type annotation for connection.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li aa733f0bbd webhook: Fix f-string str-bytes-safe error.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li da326aedff report: Correct type annotation allowing unauth access.
`report/error` is a path where we allow anonymous user access. This has
to be correctly denoted in the type annotation of the user argument of
the view function.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 97fd662d48 test_import_export: Enhance typing of getters.
This fixes the type annotations of `Set` derived from `QuerySet` objects,
and add necessary assertions.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 2925615ee7 test_decorators: Use the default value of user.
`HostRequestMock` has `user` default to `None`, which later gets
initialized as `AnonymousUser`. The separate initialization here is
unnecessary.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li a3efc777fa urls: Remove a legacy assertion.
This check was added for a legacy implementation of the GitHub integration in
bb6d189fa8,
which later got removed in
a73e8109b7.

No other webhook integration can now have a Falsy `url_object` attribute.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li b5f03b9637 settings: Type JITSI_SERVER_URL as being Optional.
We fixed the case when handling `JITSI_SERVER_URL` being `None`, but the
type annotation didn't get updated along with the fix
2f9d4f5a96

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 583116db14 email_notifications: Fix type annotation for tuples.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li f314171a7b streams: Add isinstance check for merge_streams.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 6f42b1c75c uploads: Avoid redefinition of a variable.
Mypy disallows redefinition of the same variable with a different type.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li 036a90f375 settings: Add isinstance check before filtering.
This is a follow-up to https://github.com/typeddjango/django-stubs/pull/1038.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Anders Kaseorg 35778fa100 overlays: Remove unused support for Bootstrap modals.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-07-26 17:48:31 -07:00
Sahil Batra e83ea8b6a7 import: Call create_system_user_groups_for_realm outside the function.
Previously, we had a function named create_add_users_to_system_user_groups
for creating system user groups and adding users to them in case when
exports do not contain these groups when importing from other services.

This commit just separates out the call to create_system_user_groups_for_realm
outside the function and the function is thus renamed to
add_users_to_system_user_group. This change is done because in further
commits we would need to update the import order and user groups will
be created before creating user profile objects.
2022-07-26 17:36:53 -07:00
Sahil Batra 58fdcdb00c streams: Extract stream access checks in a function.
This commit extracts whether a stream is accessible or not
in a new function such that "Subscription" object is passed
by the caller and thus we can use these functions to check
access of multiple streams in a loop without querying the
database in a loop for subscription objects.
2022-07-26 17:25:52 -07:00
Sahil Batra 52c8f687cc streams: Rename admin_access_required to unsubscribing_others.
This commit renames admin_access_required parameter of
list_to_streams function to unsubscribing_others since that
parameter is used and passed as True only when calling
the function while unsubscribing others and in further
commits we would allow non-admins too to unsubscribe others
based on can_remove_subscribers_group setting.
2022-07-26 17:25:52 -07:00
Sahil Batra bcef35490d test_markdown: Use make_stream function for creating streams.
This commit removes the instances of using "Stream.objects.create"
in tests with make_stream function. This change will help us to
avoid adding code for things to be done after creating streams in
multiple places. We can instead just add it in make_stream function
only.
2022-07-26 17:25:52 -07:00
Mateusz Mandera cf74d7d140 realm_reactivation: Prevent realm reactivation link reuse.
This uses the approach analogical to EmailChangeStatus for email change
confirmation links.
2022-07-26 17:14:26 -07:00
Mateusz Mandera 46c6f33b10 reactivate_realm: Change error status code on invalid links to 404. 2022-07-26 17:14:26 -07:00
Mateusz Mandera 0e2691815e confirmation: Prevent re-use of email change links.
The .status value of EmailChangeStatus was not being looked
at anywhere to prevent re-use of email change confirmation links. This
is not a security issue, since the EmailChangeStatus object has a fixed
value for the new_email, while the confirmation link has expiry time of
1 day, which prevents any reasonable malicious scenarios.

We fix this by making get_object_from_key look at
confirmation.content_object.status - which applies
generally to all confirmations where the attached object has the .status
attribute. This is desired, because we never want to
successfully get_object_from_key an object that has already been used or
reused.
This makes the prereg_user.status check in check_prereg_key redundant so
it can be deleted.
2022-07-26 17:14:26 -07:00