Commit Graph

53439 Commits

Author SHA1 Message Date
Lauryn Menard ef1ac399e6 api-docs: Clean up shared schemas for error responses.
Removes the JsonErrorBase and JsonError schemas as all error
responses in the API docs use the CodedErrorBase or CodedError
schemas.

Removes the AddSubscriptionsResponse schema since it's no longer
incorrectly used as a shared schema for error responses, and
instead documents the specific success response properties in the
endpoint.
2023-09-20 10:38:01 -07:00
Lauryn Menard c0a4ecd5aa api-docs: Move ignored params example to IgnoredParametersSuccess. 2023-09-20 10:38:01 -07:00
Lauryn Menard f0fe86d5e3 api-docs: Move simple success example up to JsonSuccess schema. 2023-09-20 10:38:01 -07:00
Lauryn Menard eb99efccd8 api-docs: Make "code" field required for CodedErrorBase schema. 2023-09-20 10:38:01 -07:00
Lauryn Menard 6fac83d54f api-docs: Fix RateLimitedError schema. 2023-09-20 10:38:01 -07:00
Lauryn Menard ee2f58e67a api-docs: Replace incorrect JsonError schema refs with CodedError. 2023-09-20 10:38:01 -07:00
Lauryn Menard d3e66b4f4f api-docs: Add 'code' field to emoji does not exist error. 2023-09-20 10:38:01 -07:00
Lauryn Menard 28a2893a41 api-docs: Update mute/unmute user error documentation for 'code' fields. 2023-09-20 10:38:01 -07:00
Lauryn Menard c4d4dfda4d api-docs: Add shared InvalidStreamError schema.
Adds an InvalidStreamError schema for errors that return a 'msg'
field with the string: "Invalid stream ID". Updates endpoints that
have this error 'str' documented to use the shared schema.
2023-09-20 10:38:01 -07:00
Lauryn Menard 3e369bcf96 api-docs: Add 'code' field to errors for deleting only org owner. 2023-09-20 10:38:01 -07:00
Lauryn Menard cb921300ce api-docs: Add 'code' field to create user email already exists. 2023-09-20 10:38:01 -07:00
Lauryn Menard 1b14745b17 api-docs: Update InvalidMessageError and use for read receipts doc. 2023-09-20 10:38:01 -07:00
Lauryn Menard 767c6a506c api-docs: Update drafts/scheduled message ResourceNotFoundErrors.
Updates documentation of ResourceNotFoundErrors for unknown draft
and scheduled message IDs to include the 'code' field, have an
HTTP status code of 404 in the documentation, and to follow the
general description format of errors in the API documentation.
2023-09-20 10:38:01 -07:00
Lauryn Menard 03ba4df8ee api-docs: Add 'code' field to unauthorized error in delete attachments. 2023-09-20 10:38:01 -07:00
Lauryn Menard 68fcd0a299 api-docs: Add 'code' field to InvalidApiKeyError response example. 2023-09-20 10:38:01 -07:00
Lauryn Menard ad3bed2086 emails: Fix contact_us macros for "mailto" scheme in email links.
Updates the contact_us_zulip_cloud and contact_us_self_hosted email
macros to have the "mailto" scheme in the anchor tag for the support
email address.

Also updates the Zulip Cloud version for the account_registered
support email link, which has a slightly different format/text than
the macro.
2023-09-20 09:58:12 -07:00
Mateusz Mandera 41d76969cb build_message_send_dict: Remove redundant realm arg.
Since the function asserts that the realm arg matches message.realm
anyway, having the argument is redundant here.
2023-09-20 09:55:25 -07:00
Alex Vandiver 5ee4b642ad views: Add a /health healthcheck endpoint.
This endpoint verifies that the services that Zulip needs to function
are running, and Django can talk to them.  It is designed to be used
as a readiness probe[^1] for Zulip, either by Kubernetes, or some other
reverse-proxy load-balancer in front of Zulip.  Because of this, it
limits access to only localhost and the IP addresses of configured
reverse proxies.

Tests are limited because we cannot stop running services (which would
impact other concurrent tests) and there would be extremely limited
utility to mocking the very specific methods we're calling to raising
the exceptions that we're looking for.

[^1]: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/
2023-09-20 09:53:59 -07:00
David Rosa e60a4c4d01 help: Document `unarchive_stream` management command.
- Adds "Unarchiving archived streams" section to "Archive a stream".
- Adds `./manage.py unarchive_stream` to contributor docs.
2023-09-19 15:04:07 -07:00
David Rosa eb244fdc07 help: Update "Archive a stream".
- Updates page to follow current help center documentation patterns.
2023-09-19 15:03:33 -07:00
David Rosa cb123d4f15 management: Rename command reactivate_stream -> unarchive_stream. 2023-09-19 15:03:33 -07:00
Aman Agrawal 696287b0eb left_sidebar: Remove dev environment check for inbox. 2023-09-18 21:31:58 -07:00
Steve Howell a8f5836ee6 tests: Make soft-reactivation tests readable.
The `expected` flag was incredibly confusing, as you
couldn't tell from the calling code what you were
actually expecting to happen.

I avoid the context manager idiom in order to force
the callers to create simple helper functions, and
I de-duplicate some code in some places.

I also force the caller to explicitly soft-deactivate
the user with one simple line of code, so that the
person reading the test doesn't have to research
the side effects of the helper. (And I make it
very easy for new authors to follow the practice
going forward.)

This is also somewhat of a prep commit to avoid
the obfuscated use of refresh_from_db.
2023-09-18 16:55:06 -07:00
Steve Howell 31d2660ee2 tests: Simplify policy-related tests.
The helper here was no longer a useful abstraction.
2023-09-18 16:55:06 -07:00
Steve Howell 0e261f6ec4 tests: Wrap get_user method.
The get_user function is poorly named, but I don't want to
sweep the entire codebase yet.

It's also nice to have a test wrapper for little experiments
like profiling tests or hunting down calls to refresh_from_db.

It's possible that we would also just change the new wrapper
to more directly call Django. The `get_user` function isn't
used in a ton of real-world places, so we might want the test
code to just bypass the cache.
2023-09-18 16:55:06 -07:00
Steve Howell df43f86cbc tests: Clean up check_has_permission_policies.
I add a bunch of cute helper methods to make
the test a bit more readable.

And then I make sure to get clean objects,
which precludes the need for our callback
functions to refresh the user objects.

And finally I make sure that our validation
functions don't cause any round trips (assuming
we have fetched objects using a standard
Zulip helper, which example_user ensures.)
2023-09-18 16:55:05 -07:00
m-e-l-u-h-a-n 8a6d649ef9 user groups: Fix right panel display for new user group on small screen.
Opening create user group from `+` button on left panel did not
open the create user group form properly on small viewports.

This was due to show_right_section not being called which is
resposible to handle this.
2023-09-18 16:09:31 -07:00
m-e-l-u-h-a-n e42fa42b0c user groups: Reset active_group_id at initial build of groups overlay.
We maintain active_group_id as a module level variable to keep
track of the group that is being edited in the right panel of
the overlay. This variable could store the value of group id for
which settings were open when the groups overlay was open previously.

While this caused no bugs but it was not inline with the idea of
the variable holding id of group for which settings were open
and undefined in case right panel was empty or group creation
form was open.

To make this variable consistent with this idea we reset the
value of this variable while building up the ui for groups
overlay as initially groups overlay is opened with empty right
panel.
2023-09-18 16:09:31 -07:00
m-e-l-u-h-a-n 350802a510 user groups: Remove redundant DOM operations on user group add event.
Settings DOM for newly created group were unnecessarily appended
in the right panel during live update. This was not needed as
these HTML elements are any way created for the window in which
the group was created and this was extra work for a window that
had groups overlay open but the group was not created in that window.

These changes also solved a minor bug where an extra delete button
appeared after the extra HTML elements were appended in the right
panel.
2023-09-18 16:09:31 -07:00
m-e-l-u-h-a-n 4a8271e854 user groups: Optimize DOM operations while showing groups overlay.
Groups overlay during initial build up created groups rows for
all the groups in the realm and then based on the section/(active tab)
it updated the list data in the group_list_widget that again caused
repeated removing and rebuilding of several group rows.

We optimize here by initially building the overlay with empty group
list and later on update the group list based on section/(active tab).

Changes in this commit only affect (reduce) the number of DOM
operations we do while showing groups overlay and have no visual
changes.
2023-09-18 16:09:31 -07:00
m-e-l-u-h-a-n 4f6f619d20 user groups: Correctly decide the display of group list on left panel.
All groups were listed on the left panel by default, irrespective
of which tab was active.
This caused a mismatched ui where list of groups displayed was not
according to the active tab.
We fix this by redrawing left panel based on active tab.
2023-09-18 16:09:31 -07:00
m-e-l-u-h-a-n 1a7eb17450 user groups: Fix buggy display of edit button on group membership event.
The display of edit button was not correctly toggled on membership
update events during first render of user group user group settings.

This was due to toggling of display for incorrect html element.

We fix that by toggling display for correct node.
2023-09-18 16:09:31 -07:00
m-e-l-u-h-a-n 74318c9b7e user groups: Update left panel correctly on membership update event.
Live update code for user group membership update events did not cover
following updates that are covered in this commit.
* Updating list of groups to be displayed on left panel based on
  updated membership and selected tab.
* Updating the presence of checkmark on the group row for which
  membership was updated.
2023-09-18 16:09:31 -07:00
m-e-l-u-h-a-n 74bcfa5a9f user groups: Update handling of user group add event.
Group list data in group_list_widget was not updated correctly,
on user group event as a result the group items shown on the
left panel were some times not according to the filters and selected
tab.
We make changes to appropriately update group list data of
group_list_widget on group add event and show group settings for
newly created group even in cases when the newely created group row
is not present in the left panel due to search filter or tab toggles.
2023-09-18 16:09:31 -07:00
m-e-l-u-h-a-n 5cb99ad8a4 user groups: Update handling of user group remove event.
Groups list in group_list_widget data was not propoerly updated
on group remove event as a result the group list on left panel
gave errors during search/(tab switches) redraws.
2023-09-18 16:09:31 -07:00
m-e-l-u-h-a-n 0261be5993 user groups: Fix how we decide if a group is being edited.
We earlier used URL for checking if a group was being
edited in the right pane of #groups overlay. This is
hacky in cases where the URL might be changed by the
user by toggling between all-groups and your-groups.

As the information about the group being edited is
reliably maintianed by user_group_settings_ui module
we use that while checking if the group is being edited.
2023-09-18 16:09:31 -07:00
m-e-l-u-h-a-n 5b7e04773a user groups: Hide correct right panels on #groups overlay change.
`show_user_group_settings_pane` for user groups ui used made hide()
calls to incorrect panels. This however had no effect on the UI
but affected the readability of code for those functions.
2023-09-18 16:09:31 -07:00
m-e-l-u-h-a-n c147aafbe3 user groups: Preserve active group state during left panel updates.
The active group information that was provided by
`user_groups_settings_ui.get_active_data` became
inconsistent as the group list ui on left panel
updated due to tab toggle between Your/All groups
or due to search inputs.
To address this we maintain a module level variable
`active_group_id` that is updated during switches
in the right pane so that information about the
active_group_id is maintained and updated correctly.
2023-09-18 16:09:31 -07:00
m-e-l-u-h-a-n e92aa2293d user groups: Add tabs for your/all groups in #groups overlay.
We add tabs to make distinction between the groups the user
is a member of and all groups in the realm. This is a preliminary
commit and there would be following immediate follow-ups to this:
* Persisting the active state of selected group in the left panel
  as the list updates with search and thorugh tab toggles.
* Updating the display of group in the left panel list on membership
  update events.
2023-09-18 16:09:31 -07:00
m-e-l-u-h-a-n 4b8856b5d6 user groups: Fix tooltip for new user group button on #groups overlay.
The tooltip for new user group button (+) icon button on #groups
overlay was not mounted correctly on the target element as a
result its content was not able to render properly.

This mounting problem was due to its sibling element (search bar)
being inserted dynamically after handlebar got rendered.

To address this we append the tooltip element to the body itself
with target as the + button.
2023-09-18 16:09:31 -07:00
m-e-l-u-h-a-n f494daba95 user groups: Miscellaneous fixes to new user groups settings overlay.
We address few of the minor required change mentioned in
https://github.com/zulip/zulip/issues/24443.

* Sort user group list alphabetically by name on left panel.
* Fix actions column items on member list on right panel.
* Add tooltip to trash icon on right panel.
2023-09-18 16:09:31 -07:00
Vector73 40a8ca2ced message_edit_form: Remove question mark icon after edit-timer-text.
Fixes: #26759
2023-09-18 15:31:55 -07:00
Lauryn Menard 31daef7f79 response: Remove "result: partially_completed" for success responses.
In feature levels 153 and 154, a new value of "partially_completed"
for `result` in a success (HTTP status code 200) was added for two
endpoints that process messages in batches: /api/delete-topic and
/api/mark-all-as-read.

Prior to these changes, `result` was either "success" or "error" for
all responses, which was a useful API invariant to have for clients.

So, here we remove "partially_completed" as a potential value for
"result" in a response. And instead, for the two endpoints noted
above, we return a boolean field "complete" to indicate if the
response successfully deleted/marked as read all the targeted
messages (complete: true) or if only some of the targeted messages
were processed (complete: false).

The "code" field for an error string that was also returned as part
of a partially completed response is removed in these changes as
well.

The web app does not currently use the /api/mark-all-as-read
endpoint, but it does use the /api/delete-topic endpoint, so these
changes update that to check the `complete` boolean instead of the
string value for `result`.
2023-09-18 13:18:24 -07:00
Prakhar Pratyush 8d29ad7325 toggle_resolve_topic: Display spinner while request is in progress.
We replace the check icon for "Mark as resolved/unresolved" with
a spinner while the request is still ongoing.

This helps to prevent double-clicking and reduce possible
race conditions.

Fixes #26190.
2023-09-18 13:17:10 -07:00
Prakhar Pratyush 72b3a53864 inline_topic_edit: Fix spinner not visible in the dark mode.
A spinner is shown when the request is in progress
for inline topic edit.

Earlier, the spinner was not visible in the dark theme.

This commit makes it visible by setting a different fill color
in the dark theme.
2023-09-18 13:17:10 -07:00
Alex Vandiver f778316b5a uwsgi: Ensure that the master process cannot load the application.
The rolling restart configuration of uwsgi attempted to re-chdir the
CWD to the new `/home/zulip/deployments/current` before `lazy-apps`
loaded the application in the forked child.  It successfully did so --
however, the "main" process was still running in the original
`/home/zulip/deployments/current`, which somehow (?) tainted the
search path of the children processes.

Set the parent uwsgi process to start in `/`, so that the old deploy
directory cannot taint the load order of later children processes.
2023-09-18 13:13:34 -07:00
Alex Vandiver a6d5d7740e uwsgi: Always enable lazy-apps.
Enabling `lazy-apps` defers loading of the uwsgi application until
after the fork, instead of happening prior to forking workers[^1].  The
nominal reason to not enable this is that it increases the memory
footprint of the server (since no memory is shared across processes),
and may slow down worker initialization, since each worker has to load
the files from disk.

However, Django defers loading the majority of the code until the
first request[^2].  As such, our current non-`lazy-apps` gains nothing
over `lazy-apps`.  For consistency, switch to using `lazy-apps` for
all deployments, rolling restart or no.

[^1]: https://uwsgi-docs.readthedocs.io/en/latest/articles/TheArtOfGracefulReloading.html#preforking-vs-lazy-apps-vs-lazy
[^2]: https://uwsgi-docs.readthedocs.io/en/latest/articles/TheArtOfGracefulReloading.html#preforking-vs-lazy-apps-vs-lazy
2023-09-18 13:13:34 -07:00
Aman Agrawal 8ebb64c622 inbox: Reduce width of rows. 2023-09-18 12:17:51 -07:00
Aman Agrawal 01959d49fc inbox: Use a non transparent background color.
Since the search box header is sticky, we need the background to
be non transparent.
2023-09-18 12:17:51 -07:00
Aman Agrawal 7e11f95716 inbox: Add inbox as default view.
Fixes #26736
2023-09-18 12:17:49 -07:00