Commit Graph

57453 Commits

Author SHA1 Message Date
Alex Vandiver bd82c6edf9 settings: Support multiple database replicas in REMOTE_POSTGRES_HOST.
The libpq client library, used under the hood by psycopg2, supports
passing a list of hosts; they are tried sequentially until one of them
works[^1].

In cases where this is used, it is often the case that the other
servers are read-only hot spare replicas.  Since Zulip does not expect
to be in a read-only transaction, we require that the server that we
connect to be writable, by passing `target_session_attrs`[^2].

To limit how long we may block connecting to a potentially bad host
before moving on, we set `connection_timeout` from null (meaning
forever) to 2 (the lowest supported value)[^3], so we move on quickly
in the case that the server is running but unable to handle new
connections.

[^1]: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-MULTIPLE-HOSTS
[^2]: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-TARGET-SESSION-ATTRS
[^3]: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-CONNECT-TIMEOUT
2024-04-04 16:48:58 -07:00
Alex Vandiver 92121a0626 postgresql: Decouple wal_g from streaming replication.
Streaming replication may be used even if `wal-g` is not -- as long as
the user can move a copy of the base backup to the replica (e.g. using
`pg_basebackup`).  Remove the warning about this combination, and move
the `primary_conninfo` setting outside of the `s3_backups_bucket`
check.
2024-04-04 16:48:58 -07:00
Alex Vandiver 5121bff3c0 postgresql: Drop lowered max_wal_senders value.
This was originally added in a PostgreSQL 9.5 configuration, where the
default is 0, meaning replication is disabled[^1].  In PostgreSQL 10
and above, the default is 10[^2], and there is no reason to lower it
from that value.

[^1]: https://www.postgresql.org/docs/9.5/runtime-config-replication.html
[^2]: https://www.postgresql.org/docs/10/runtime-config-replication.html#RUNTIME-CONFIG-REPLICATION-SENDER
2024-04-04 16:48:58 -07:00
Alex Vandiver acc94a5f32 create-database: Skip stop-server and flush-memcached on standalone Pg.
If running on a stand-alone PostgreSQL server, then supervisor does
exist -- but `stop-server` is useless, and in fact cannot run because
the Zulip directory may not be readable by the `zulip` user.

Detect if this is an application front-end server by looking for
`/home/zulip/deployments`, and use the stop-server and flush-memcached
from there if it exists.  The `create-db.sql` and
`terminate-psql-sessions` files are still read from the local
directory, but those already have precautions from being from a
non-world-readable directory, and are more obviously important to keep
in sync with the `create-database` script.
2024-04-04 16:48:58 -07:00
Alex Vandiver c56dd5ec4d puppet: Fix indentation. 2024-04-04 16:48:58 -07:00
evykassirer d6f4424102 compose_actions: Convert module to typescript. 2024-04-04 16:34:42 -07:00
evykassirer 55cf08c4e6 compose: Allow stream_id of ComposeTriggeredOptions to be undefined. 2024-04-04 16:34:42 -07:00
evykassirer 5e0343816f page_params: Add narrow_topic. 2024-04-04 16:34:42 -07:00
evykassirer 85c5fe635e compose_actions: Include message type in opts for `fill_in_opts_from_current_narrowed_view`. 2024-04-04 16:34:42 -07:00
evykassirer 9cea1c0ee1 compose_actions: Include message type in opts for `complete_starting_tasks`. 2024-04-04 16:34:42 -07:00
evykassirer 2014c25cb4 compose_actions: Include message type in opts for `start`. 2024-04-04 16:34:42 -07:00
evykassirer 3ea46542ce compose_actions: Include message type in same_recipient_as_before opts. 2024-04-04 16:34:42 -07:00
evykassirer 1f7e419cee compose_actions: Include message type in show_compose_box opts. 2024-04-04 16:34:41 -07:00
evykassirer 5934081801 resize: Let bottom_whitespace_height be optional.
This aligns with the comment below of "Compute bottom_whitespace_height
if not provided by caller." I'd change this to do a check for if it's
undefined, instead of checking the type, but I don't understand
enough about `ResizeObserver` to feel confident that this would be
equivalent.
2024-04-04 16:34:41 -07:00
evykassirer d05c7a64c8 stream_data: Remove unused code branch. 2024-04-04 16:34:41 -07:00
Evy Kassirer 466560faa1
compose_actions: Fix automated scroll when resizing compose.
This code has been inoperative since 86073588be
upgraded the autosize library without migrating this event.
2024-04-04 16:33:05 -07:00
Anders Kaseorg 0bae651e23 upgrade-zulip-stage-2: Add Ubuntu 20.04, Debian 11 to UNSUPPORTED_DISTROS.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-04 16:28:12 -07:00
Anders Kaseorg d8ebb2db95 auth: Avoid deprecated django.contrib.auth.views.logout_then_login.
It’s removed in Django 5.0.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-04 16:27:58 -07:00
N-Shar-ma a3ed41efa0 typeahead: Redesign the function `compare_people_for_relevance`.
We make the following changes:

- Remove the dm partnership check before calling the comparator passed
by the caller, and instead have the more thorough `compare_by_pms` be
the final tie breaker. This deprioritization of dms fixes the bug where
dm partners would be prioritized even if they had not participated in
a stream conversation over recent senders who are not dm partners.

- Make the passed comparator optional, since the tie breaker is same as
the comparator that was passed so far for dms, and only pass it in case
of a stream conversation.
2024-04-04 13:13:11 -07:00
N-Shar-ma a8954ad00e tests: Add missing setup to typeahead_helper tests passing as a fluke. 2024-04-04 13:13:11 -07:00
N-Shar-ma 7c2772022b typeahead: Add check for all time dm partners to `compare_by_pms`.
For the rare case where there is no recent recipient count for a pair of
users when sorting, we now check if either has been a dm conversation
partner ever before.
2024-04-04 13:13:11 -07:00
JohnLu2004 11c9e5bb3d api-docs: Document optimization of is:unread filter.
Documents that the is:unread narrow/filter can be an important
optimization for clients to consider using in certain cases.

Fixes #28328.
2024-04-04 12:54:25 -07:00
Aman Agrawal 0a90a13bec popover_menus: Fix event handler trying to hide a hidden popover.
When user is trying to open a modal after clicking on a button
in a popover, we call popovers.hide_all() before opening the modal
which hides the popover but since the event handler call isn't
finished running yet, we call instance.hide() again resulting in
tippy throwing errors that this could be a memory leak.

We introduce a wrapper function for `instance.hide` which if
the popover/tooltip is visible before hiding it to fix it.
2024-04-04 12:51:35 -07:00
Anders Kaseorg ac5161f439 tests: Downgrade deprecated SHA1PasswordHasher to MD5PasswordHasher.
SHA1PasswordHasher will be removed in Django 5.1.  MD5PasswordHasher
will remain for exactly this purpose of speeding up tests.

Use MD5PasswordHasher by default, but leave SHA1PasswordHasher in the
list for compatibility with test databases that have already been
generated.  Once some other change forces test databases to be
rebuilt, we can remove SHA1PasswordHasher.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-04 12:43:54 -07:00
Anders Kaseorg e5fd761562 test_stripe: Replace deprecated stripe.Event.to_dict_recursive.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-04 11:23:11 -07:00
Anders Kaseorg 040e8aa7f1 test_stripe: Remove unused stripe.util import.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-04 11:20:26 -07:00
Lauryn Menard 80d4a704fe mentions: Replace "channel" wildcard when selected via typeahead.
Until "stream" is renamed to "channel" in user facing strings,
when "channel" is selected from the composebox typeahead options,
the "stream" wildcard syntax will be inserted in the message
content instead.

Adds some helper functions to util.ts to initially be used to
check/convert "channel" to "stream" during the rename process,
with the intention of then converting those helpers for the
reverse (check/convert "stream" to "channel") in the final part
of the rename process.

Part of project to rename "stream" to "channel".
2024-04-04 11:16:07 -07:00
Lauryn Menard e700e818e5 mentions: Add "channel" as a wildcard mention.
Adds "channel" to the `stream_wildcards` frozenset for stream
wildcard notifications on the backend/server.

Updates frontend/web-app to handle "channel" as the other stream
wildcards are handled in the typeahead and composebox modules.

Updates the API version and documentation for the addition of
"channel" as a wildcard mention. But does not change any of the
functionailty of (or deprecate) the "stream" wildcard at this
point.

Part of project to rename "stream" to "channel".
2024-04-04 11:16:07 -07:00
Lauryn Menard 88fd9d947b api-docs: Add article about markup message formatting.
Adds a "Message formatting" article to the API documentation. To
start, the article is a changelog of updates to markup features for
messages, with the idea being that it can be expanded to further
describe and document Zulip's markup features in future iterations.
2024-04-04 11:16:07 -07:00
Lauryn Menard 92f236ffea mentions: Update backend tests to not use only "stream" wildcard.
Use "all" or the set of stream wildcard mentions for backend tests.

Part of project to rename "stream" to "channel".
2024-04-04 11:16:07 -07:00
Ajay Singh dc80f29b8a
docs: Fix typo. 2024-04-04 10:51:37 -07:00
Anders Kaseorg ad5abbe54f apt-repos: Remove Ubuntu 24.04 gnupg workaround.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-04 10:48:22 -07:00
afeefuddin b32c837c6b settings_playgrounds: Convert module to TypeScript. 2024-04-04 10:45:53 -07:00
afeefuddin 50f35a22b3 state_data: Update realm properties. 2024-04-04 10:45:53 -07:00
afeefuddin af0a31f0e4 bootstrap_typeahead: Make updater property optional in TypeaheadOptions. 2024-04-04 10:45:53 -07:00
Prathamesh Kurve f9bc21f4bf
keyboard ui: Fix vim keyboard navigation from inbox view filter.
Fixes #29509.
2024-04-04 10:17:09 -07:00
Anders Kaseorg b9e55f2c4d eslint: Enable no-jquery/no-append-html.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-04 10:11:57 -07:00
Anders Kaseorg 8fb1117cef eslint: Fix no-jquery/no-append-html errors that need test changes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-04 10:11:57 -07:00
Anders Kaseorg 382af5f79f eslint: Fix no-jquery/no-append-html errors that need no test changes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-04 10:11:57 -07:00
Alex Vandiver 01860422af util: Do not use look-behind in wildcard mention checks.
92fa9ee78c switched this regex to match the server-side regex, but
Safari < 16.4 does not support look-behind in regexes.

Switch to matching on start-of-string or a positive character class.
2024-04-03 17:39:26 -07:00
Karl Stolley 6d5243148a timestamps: Calculate the maximum timestamp width in use.
Fixes: #26970
2024-04-03 17:38:43 -07:00
Karl Stolley 82d0eec0bc timestamps: Consolidate and simplify message-time properties.
This is better form, and also sets things up to render sample
timestamps for calculating their max width.
2024-04-03 17:38:43 -07:00
Karl Stolley 09d7105747 timestamps: Consolidate variable-based timestamp width. 2024-04-03 17:38:43 -07:00
Karl Stolley 1425d2f71f message_body: Hyphenate message-time class. 2024-04-03 17:38:43 -07:00
Karl Stolley c25975642a message_body: Remove status-time references.
The `.status-time` class was used only for setting a `top` value,
but that's made moot by the use of grid in the message area.
2024-04-03 17:38:43 -07:00
Alex Vandiver 48b925931e django: Skip running config and database checks on process start.
The process of running Django's built-in database and config checks
can be very heavy-weight, potentially taking multiple seconds:

```
$ hyperfine './manage.py print_initial_password iago@zulip.com'  './manage.py print_initial_password iago@zulip.com --skip-checks'
Benchmark 1: ./manage.py print_initial_password iago@zulip.com
  Time (mean ± σ):      4.943 s ±  0.722 s    [User: 4.434 s, System: 0.311 s]
  Range (min … max):    4.415 s …  6.835 s    10 runs

Benchmark 2: ./manage.py print_initial_password iago@zulip.com --skip-checks
  Time (mean ± σ):      1.786 s ±  0.113 s    [User: 1.598 s, System: 0.162 s]
  Range (min … max):    1.576 s …  1.999 s    10 runs

Summary
  './manage.py print_initial_password iago@zulip.com --skip-checks' ran
    2.77 ± 0.44 times faster than './manage.py print_initial_password iago@zulip.com'
```

This extends the window during which nginx is forced to serve 502's to
clients.  f5f6a3789b added an explicit `manage.py check` during
server restarts, and fa77be6e6c added one during upgrades; as such,
we expect that any check failures will already have been caught when
performing a restart or upgrade, and there is no point in running them
on process startup.
2024-04-03 17:18:41 -07:00
Anders Kaseorg 92bc2df4bb lint: Quiet the Ruff formatter.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-03 15:34:02 -07:00
Anders Kaseorg 1e4427caf5 tests: Fix incorrect uses of .indexOf(…) > 0.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-03 15:13:33 -07:00
Anders Kaseorg 1188a0f26d stream_settings_ui: Add missing $ prefix to jQuery object variable.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-03 14:10:21 -07:00
Tanmay Kumar fbb42dd297
tools: Fix broken link in check-frontend-i18n.
The section referenced was moved to another page.
2024-04-03 13:13:16 -07:00