Compare commits

...

365 Commits
6.0-rc1 ... 6.2

Author SHA1 Message Date
Alex Vandiver
5082182e37 Release Zulip Server 6.2. 2023-05-19 18:23:04 +00:00
Sahil Batra
7c2693a2c6 CVE-2023-32677: Check permission to subscribe other users in invites.
This commit updates the API to check the permission to subscribe other
users while inviting.  The API will error if the user passes the
"stream_ids" parameter (even when it contains only default streams)
and the calling user does not having permission to subscribe others to
streams.

For users who do not have permission to subscribe others, the
invitee will be subscribed to default streams at the time of
accepting the invite.

There is no change for multiuse invites, since only admins are allowed
to send them, and admins always have the permission to subscribe
others to streams.
2023-05-18 21:49:20 +00:00
Mateusz Mandera
3df1b4dd7c CVE-2023-28623: Prevent unauthorized signup with ldap + external auth.
Since 74dd21c8fa in Zulip Server 2.1.0, if:
- ZulipLDAPAuthBackend and an external authentication backend (any aside
  of ZulipLDAPAuthBackend and EmailAuthBackend) are the only ones
  enabled in AUTHENTICATION_BACKENDS in /etc/zulip/settings.py
- The organization permissions don't require invitations to join

...then an attacker can create a new account in the organization with
an arbitrary email address in their control that's not in the
organization's LDAP directory.

The impact is limited to installations which have the specific
combination of authentication backends described above, in addition to
having the "Invitations are required for joining this organization
organization" permission disabled.
2023-05-18 19:49:36 +00:00
Mateusz Mandera
baf9382f24 maybe_send_to_registration: Remove password_required arg.
This argument was added with the default incorrectly set to `True` in
bb0eb76bf3 - despite
`maybe_send_to_registration` only ever being called in production code
in a single place, with `password_required=False` explicitly. And then
it just got carried forward through refactors.

`maybe_send_to_registration` was/is also called twice in tests, falling
back to the default, but the `password_required` value is irrelevant to
the tests - and if anything letting it use the `True` has been wrong,
due to not matching how this function is actually used.
2023-05-18 19:49:36 +00:00
Anders Kaseorg
520808f55a requirements: Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit d0481be3e5)
2023-05-15 16:11:36 -07:00
Anders Kaseorg
fb61843a00 requirements: Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 03b3c8522d)
2023-05-15 16:11:36 -07:00
Anders Kaseorg
6cfe0655f2 provision: Disable compilemessages searching for locale directories.
We explicitly configure LOCALE_PATHS, so we can safely disable this
search of the entire tree for other locale directories.

https://github.com/django/django/blob/4.1/django/core/management/commands/compilemessages.py#L92-L100

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 8f27a6fb73)
2023-05-15 12:05:08 -07:00
Mateusz Mandera
2a6d4ea036 zilencer: Delete duplicate remote push registrations.
This fixes existing instances of the bug fixed in the previous commit.

Fixes #24969.
2023-05-14 11:17:46 -07:00
Mateusz Mandera
7b08419145 zilencer: Avoid creating duplicate remote push registrations.
Servers that had upgraded from a Zulip server version that did not yet
support the user_uuid field to one that did could end up with some
mobile devices having two push notifications registrations, one with a
user_id and the other with a user_uuid.

Fix this issue by sending both user_id and user_uuid, and clearing
2023-05-14 11:17:46 -07:00
Alex Vandiver
546ecc38d6 zulip-puppet-apply: Any resources failing to apply should exit 2.
The existing `except subprocess.CalledProcessError` only catches if
there are syntax errors which prevent the `lastrun` file from being
written; it does not handle if there are properly-defined resources
which fail to evaluate (e.g. due to a missing dependency or file).

Check the `failed` resource count, and exit 2 if there are any such
resources.  This will cause `zulip-puppet-apply --force --noop` (which
is used as a pre-flight check during upgrades) to properly detect and
signal on more types of invalid puppet configurations.  In turn, this
will cause `upgrade-zulip` to not attempt to power through upgrades it
knows are destined to fail.
2023-05-12 17:59:14 -07:00
Alex Vandiver
d2ef4e85f8 webpack: Silence out-of-date warnings from caniuse browserslist. 2023-05-12 17:58:23 -07:00
Sahil Batra
ad27f38d93 invite: Add checkbox to select all default streams.
We now add a checkbox in "Steams they should join" to directly
select all default streams in the realm for the invite.
We hide the stream list if that option is selected.
2023-05-12 17:52:57 -07:00
Sahil Batra
f6f5697ccb invites: Allow users to invite without specifying any stream to join.
We now allow users to invite without specifying any stream to join.
In such cases, the user would join the default streams, if any, during
the process of account creation after accepting the invite.

It is also fine if there are no default streams and user isn't
subscribed to any stream initially.
2023-05-12 17:52:57 -07:00
Sahil Batra
f0d1f7370d invites: Do not add user to default streams if streams list is empty.
We do not add user to the default streams if the streams list passed
while sending the invite (both email and multi-use) was empty since
invite explicitly selected to not subscribe the user to default
streams.
2023-05-12 17:52:57 -07:00
Sahil Batra
a15bc8e1be test_signup: Add test to verify stream subscriptions.
This commit adds test to verify whether the user was
subscribed to the streams selected when inviting them.
2023-05-12 17:52:57 -07:00
Alex Vandiver
ea27719e07 workers: Rewrite missedmessage_emails with a worker thread.
The previous implementation leaked database connections, as a new
thread (and thus a new thread-local database connection) was made for
each timer execution.  While these connections were relatively
lightweight in Python, they also incur memory overhead in the
PostgreSQL server itself.  The logic for managing the timer was also
unclear, and the unavoidable deadlock in the stopping logic was rather
unfortunate.

Rewrite with one explicit worker thread which handles the delayed
message sending.  The RabbitMQ consumer creates the database rows, and
notifies the worker to start its 5s timeout.  Because it is controlled
by a condition variable, it does not hold the lock while waiting, and
can be notified to exit.

(cherry picked from commit 3efc0c9af3)
2023-04-18 15:47:51 -07:00
Alex Vandiver
99047e5a0c requirements: Add time-machine for time mocking.
This was in main as 50a2a54393.
2023-04-18 15:47:51 -07:00
Anders Kaseorg
e99240e4e7 requirements: Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit a881918a05)
2023-04-06 09:30:23 -07:00
Anders Kaseorg
f290c4cb8f codespell: Fix newly found typos.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 2ce8357009)
2023-04-06 09:30:23 -07:00
Zixuan James Li
aa791f6381 cache: Use QuerySetAny for isinstance check.
Previously, `QuerySet` does not support isinstance check since it is
defined to be generic in django-stubs. In a recent update, such check is
possible by using `QuerySetAny`, a non-generic alias of `QuerySet`.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
(cherry picked from commit 24f24d236d)
2023-04-06 09:30:23 -07:00
Anders Kaseorg
042cd05b6c Fix typos caught by typos.
https://github.com/crate-ci/typos

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit bd884c88ed)
2023-04-06 09:30:23 -07:00
Anders Kaseorg
da1296e7e7 setup-apt-repo: Fix GPG check of groonga-apt-source-*.deb.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 54b08ee30b)
2023-04-05 16:08:11 -07:00
Anders Kaseorg
315f62610a requirements: Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 087660a87e)
2023-04-05 16:07:58 -07:00
Anders Kaseorg
d85022ca17 html_diff: Fix lxml import.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 11e94c4bb7)
2023-04-05 16:07:58 -07:00
Anders Kaseorg
cdd222b8f6 python: Import F, Q, QuerySet from their canonical module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit d3efd4c095)
2023-04-05 16:07:58 -07:00
Anders Kaseorg
51d2dc68c8 populate_db: Import timedelta from its canonical module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit aa577a554b)
2023-04-05 16:07:58 -07:00
Anders Kaseorg
94a3f2cf1c migrations: Import BaseDatabaseSchemaEditor from its canonical module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 0628c3cac8)
2023-04-05 16:07:58 -07:00
Anders Kaseorg
fe27f8eb40 upload: Replace deprecated PIL.PngImagePlugin.APNG_DISPOSE_OP_NONE.
https://pillow.readthedocs.io/en/stable/deprecations.html#constants

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit f90a41bab0)
2023-04-05 16:07:58 -07:00
Anders Kaseorg
961be78940 requirements: Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 81a7c7502f)
2023-04-05 16:07:58 -07:00
Anders Kaseorg
1709d707d2 exceptions: Accept lazy translation as JsonableError argument.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit b85cb1e700)
2023-04-05 16:07:58 -07:00
Anders Kaseorg
08b30e95b4 readthedocs: Add a configuration file.
This overrides the settings in the web interface, and enables much
more flexible configuration of the build environment (which previously
defaulted to Python 3.7).

https://docs.readthedocs.io/en/stable/config-file/v2.html

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit b4ee94e758)
2023-04-05 16:07:58 -07:00
Anders Kaseorg
7a34e9a3fd black: Reformat with Black 23.
Black 23 enforces some slightly more specific rules about empty line
counts and redundant parenthesis removal, but the result is still
compatible with Black 22.

(This does not actually upgrade our Python environment to Black 23
yet.)

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit df001db1a9)
2023-04-05 16:07:58 -07:00
Aman Agrawal
25609fb675 people: Add function get participants from user_ids_string.
This implements the TODO in recent_senders.
2023-04-05 15:47:32 -07:00
Aman Agrawal
66b593e505 recent_senders: Fix twice sent user ids in PM to self case.
This caused double user avatar to appear in recent conversations
for when showing user PM to self.
2023-04-05 15:47:32 -07:00
Josh Klar
f62b55a5cf ci: Only report failures to CZO on branch pushes.
Targeted fix for regression introduced in #23719 wherein failure reports
were attempted for all CI failures, including those from forked pull
requests, which don't have access to Actions Secrets. Since undefined
Secrets are empty strings at interpolation time [^1], the underlying
`send-message` Action was being called with no API Key, causing a
failure in the failure handler.

This fix is, per discussion in both a comment on #23719 and later on CZO
[^2], prefered to restoring the prior guard against ZULIP_BOT_KEY being
an empty string that had been in the shell script as it is more explicit
in its intent.

[^1]: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-secrets

[^2]: https://chat.zulip.org/#narrow/stream/43-automated-testing/topic/all.20branches.20failing/near/1475246

(cherry picked from commit a67ecc0f36)
2023-04-05 14:52:34 -07:00
Anders Kaseorg
00829867d7 Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit d1bb100a2d)
2023-04-05 12:48:58 -07:00
Anders Kaseorg
2e39466575 migrations: Switch message_model type to Any.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit fd617b24f2)
2023-04-05 12:48:58 -07:00
Anders Kaseorg
e7e1756886 remote_server: Check for missing ZULIP_ORG_ID, ZULIP_ORG_KEY.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit a98ecee278)
2023-04-05 12:48:58 -07:00
Aman Agrawal
1563c85573 streams_list: Don't zoom out user when stream list rearranges.
Fixes #23588

When a new message arrives in an inactive stream, it will lead
to stream being marked as active from inactive which leads to
stream list being rearranged which zooms out the user since the
active stream is reset momentarily. To avoid this, we delay the
stream list redraw until user zooms out and only update the topics
list.
2023-04-02 23:18:45 -07:00
Aman Agrawal
03b55a3d03 left_sidebar: Highlight inactive streams when narrowed to.
Having active streams greyed out can be confusing to the user. This
is especially useful when the app is still fetching messages on
a reload and the active stream has no messages and is thus marked
as `inactive`.
2023-04-02 23:18:45 -07:00
Chris Bobbe
c429fe19b7 docs: Update mobile/desktop apps' compatability threshold to 4.0, from 3.0
Zulip Server 4.0 is now 22 months old, which is more than 18 months.
Per the general policy in the "Client apps" section below, that
means it's time to drop support for older versions.

We released 5.0 near the end of 2022-03, so near the end of 2023-09
we can update this further to say 5.0.
2023-04-02 23:15:47 -07:00
Alex Vandiver
0172200baa management: Add a command to send initial welcome bot messages. 2023-04-02 23:05:01 -07:00
Alex Vandiver
628464ad98 queue: Allow enabling TLS for the RabbitMQ connection.
This allows using cloud-based RabbitMQ services like AmazonMQ.

Fixes: #24699.
(cherry picked from commit bf532de8bb)
2023-03-24 20:06:52 +00:00
Alex Vandiver
73fef4152f puppet: Allow choice of timesync tool. 2023-03-02 13:43:19 -08:00
Anders Kaseorg
fbb58903c6 mypy: Link issue for missing py.typed in aioapns.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-02 13:43:19 -08:00
Anders Kaseorg
b47f014ab5 ruff: Enable some new errors.
PGH001 forbids eval().

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-02 13:43:19 -08:00
Anders Kaseorg
17b14f5233 ruff: Fix PLR0402 Consider using from … import.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-02 13:43:19 -08:00
Anders Kaseorg
2296629c17 ruff: Fix PLR1701 Consider merging these isinstance calls.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-02 13:43:19 -08:00
Anders Kaseorg
0255fc9ead ruff: Fix B006 Do not use mutable data structures for argument defaults.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-02 13:43:19 -08:00
Anders Kaseorg
a24aee2679 requirements: Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-02 13:43:19 -08:00
Anders Kaseorg
6ebeba289a ruff: Fix PLC0414 Import alias does not rename original package.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-02 13:43:19 -08:00
Anders Kaseorg
2b5ee4adb2 ruff: Fix UP015 Unnecessary open mode parameters.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-02 13:43:19 -08:00
Anders Kaseorg
ace159dad2 ruff: Fix RUF004 exit() is only available in the interpreter.
‘exit’ is pulled in for the interactive interpreter as a side effect
of the site module; this can be disabled with python -S and shouldn’t
be relied on.

Also, use the NoReturn type where appropriate.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-02 13:43:19 -08:00
Anders Kaseorg
931afb97b8 emoji: Import modules relative to ZULIP_PATH.
Newer mypy is less confused this way.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-02 13:43:19 -08:00
Anders Kaseorg
773f9af6a6 emoji: Remove old broken CSV import/export scripts.
These have been broken at least since commit
e331a758c3 (#12787), so clearly nobody
cares.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-02 13:43:19 -08:00
Alex Vandiver
dbc1d71a0d upgrade-zulip-stage-2: Abort upgrade if puppet will not run cleanly. 2023-03-02 13:43:19 -08:00
Alex Vandiver
e4a766965d zulip-puppet-apply: Exit status code 2 on puppet failure.
This allows us, when run with `--noop -f`, to differentiate between
"there are unapplied changes" and "there were puppet errors."
2023-03-02 13:43:19 -08:00
Alex Vandiver
9299fe65d2 upgrade-postgresql: Also upgrade postgresql-client.
The `pg_upgrade` tool uses `pg_dump` as an internal step, and verifies
that the version of `pg_upgrade` is the same exactly the same as the
version of the PostgreSQL server it is upgrading to.  A mismatch (even
in packaging versions) leads to it aborting:

```
/usr/lib/postgresql/14/bin/pg_upgrade -b /usr/lib/postgresql/13/bin -B /usr/lib/postgresql/14/bin -p 5432 -P 5435 -d /etc/postgresql/13/main -D /etc/postgresql/14/main --link
Finding the real data directory for the source cluster      ok
Finding the real data directory for the target cluster      ok

check for "/usr/lib/postgresql/14/bin/pg_dump" failed: incorrect version: found "pg_dump (PostgreSQL) 14.6 (Ubuntu 14.6-0ubuntu0.22.04.1)", expected "pg_dump (PostgreSQL) 14.6 (Ubuntu 14.6-1.pgdg22.04+1)"
Failure, exiting
```

Explicitly upgrade `postgresql-client` at the same time we upgrade
`postgresql` itself, so their versions match.

Fixes: #24192
2023-03-02 13:43:19 -08:00
Mateusz Mandera
6bf24a0643 docs: Document how LDAP email address changes work (manually).
We will hopefully be able to just this in #16208 to document what
users need to configure in order to do this manually, but the content
here will be useful for anyone who hasn't set that up regardless.
2023-03-02 13:43:19 -08:00
Tim Abbott
d14870b564 recent topics: Fix exception displaying PMs with 5+ senders.
The previous logic incorrectly tried to map elements of the list of
user IDs beyond 4 senders to their `.id` fields, which were undefined;
the correct thing to do is just use the list of user IDs that we
already have.
2023-03-02 13:43:19 -08:00
Tim Abbott
5a7ce8bdc7 install-node: Upgrade Node.js from 18.10.0 to 18.14.1.
Manual backport of the pure Node upgrade part of upgrade commits from main.
2023-03-02 13:43:19 -08:00
Alex Vandiver
d97c450798 docs: Document how to use SMTP without authentication.
This is the behaviour inherited from Django[^1].  While setting the
password to empty (`email_password = `) in
`/etc/zulip/zulip-secrets.conf` also would suffice, it's unclear what
the user would have been putting into `EMAIL_HOST_USER` in that
context.

Because we previously did not warn when `email_password` was not
present in `zulip-secrets.conf`, having the error message clarify the
correct configuration for disabling SMTP auth is important.

Fixes: #23938.

[^1]: https://docs.djangoproject.com/en/4.1/ref/settings/#std-setting-EMAIL_HOST_USER

(cherry picked from commit 015a10637b)
2023-02-27 20:02:06 +00:00
Alex Vandiver
dc4f140e85 rabbitmq: Add a RABBITMQ_PORT setting.
(cherry picked from commit 1492191b6d)
2023-02-27 17:07:05 +00:00
David Rosa
b5427709f8 contributor docs: Improve the first sentence in "Upgrade Zulip".
(cherry picked from commit a6abf959bb)
2023-01-27 21:56:51 -08:00
David Rosa
aa121267ac contributor docs: Rename "Customize Zulip" -> "Server configuration".
- Renames "Customize Zulip" to "Server configuration".
- Cross-links "Server configuration" with "System and deployment
configuration".

Fixes part of #23984.

(cherry picked from commit 538801c651)
2023-01-27 21:56:51 -08:00
David Rosa
cc8dead870 contributor docs: Rename "Upgrade or modify Zulip" -> "Upgrade Zulip".
Fixes part of #23984.

(cherry picked from commit 08e9686cd2)
2023-01-27 21:56:51 -08:00
David Rosa
932af1ed2d contributor docs: Migrate "Modify Zulip" to its own page.
Splits /production/upgrade-or-modify.md to improve the organization
of production documentation.

Fixes #23984.

(cherry picked from commit af39a1a554)
2023-01-27 21:56:51 -08:00
Alex Vandiver
aea01b51d4 release: Add tests for spelling and links in changelog.
(cherry picked from commit ad8041253c)
2023-01-24 16:46:17 -05:00
Mateusz Mandera
b67785c289 do: Install pynacl in the oneclick job.
This is now a required dependency.

(cherry picked from commit 9aacf76f0d)
2023-01-24 16:45:40 -05:00
Alex Vandiver
8bc6ad7a46 email_mirror: Create attachments as the message sender.
When the email mirror gateway is sending messages "as" a user (as
triggered by having access to the missed-message email address),
attachments were still created as the Email Gateway bot.  Since the
sender (the end-user) was not the owner of those attachments (the
gateway bot), nor were they referenced yet anywhere, this resulted in
the attachments being "orphaned" and not allowed to be accessed by
anyone -- despite the attachment links being embedded in the message.
This was accompanied by the error:

```
WARN [] User 12345 tried to share upload 123/3LkSA4OcoG6OpAknS2I0SFAQ/example.jpf in message 123456, but lacks permission
INFO [zerver.lib.email_mirror] Successfully processed email from user 12345 to example-stream
```

We solve this by creating attachment objects as the users the message
will be sent from.

(cherry picked from commit 608c787c52)
2023-01-24 16:44:29 -05:00
Alex Vandiver
d97952bc7d changelog: Tweak wording to clarify impact to Safari.
(cherry picked from commit 25c9fcdb4e)
2023-01-23 15:07:35 -05:00
Alex Vandiver
312e81809f changelog: Fix the link from .html# to .md#. 2023-01-23 18:57:28 +00:00
Alex Vandiver
87ab3e73ca version: Update version after 6.1 release. 2023-01-23 18:51:11 +00:00
Alex Vandiver
8be460631b Release Zulip Server 6.1. 2023-01-23 18:32:20 +00:00
Alex Vandiver
cfae101805 docs: Mention probably needing to allow port 22 for SSH access.
(cherry picked from commit e19d4e5e0a)
2023-01-20 15:59:21 -05:00
Josh Klar
15aea7f6f2 tools: Reimplement CI failure script without using CircleCI endpoint.
Using curl to POST to the CircleCI workflow endpoint on CZO:

- Doesn't work on zulip/zulip@main (CZO runs a revert)
- Sets a bad example for other orgs
- Robs us of an opportunity to dogfood our own zulip/github-actions-zulip

Refactor the Actions workflows in this repo to report failure states
using the Zulip Action, and reimplement the related helper scripts in
Python, since they'd previously mostly shelled out to Python anyway.

(cherry picked from commit 3a0620a40c)
2023-01-19 10:51:58 -08:00
Josh Klar
041ee5ed42 invites: Validation error instead of DB exception on overflowed SMALLINT.
If `invite_as` is passed as a number outside the range of a PostgreSQL
`SMALLINT` field, the database throws an exception. Move this exception
to the glass as a validation error to allow better client-side error
handling and reduce database round-trips.

(cherry picked from commit ebc6ab4744)
2023-01-19 10:41:23 -08:00
Josh Klar
46966957ac invites: Use check_int_in to validate invite_as.
(cherry picked from commit ea9b05d88a)
2023-01-19 10:41:11 -08:00
Josh Klar
82aac9e113 message_list_view: Use translated form of "at" in timestamp tooltip.
The English word "at" was manually appended to the string output of
datetime-related functions to generate the string shown in the tooltip
when hovering over the timestamp of a message. Use the translated form
"{date} at {time}" instead, as found elsewhere in the codebase.

(cherry picked from commit 465d0b2710)
2023-01-19 10:39:54 -08:00
Zixuan James Li
83bd34c93c decorator: Do not send HEAD response with non-empty body.
An HTTP HEAD response with a non-empty message body is not compliant
with the standard.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
(cherry picked from commit 33716f6156)
2023-01-19 11:05:04 -05:00
Zixuan James Li
0484d38e5f intercom: Return success on HEAD requests.
Intercom sends a HEAD request to validate the webhook URL on their side,
which was not expected in the previous implementation.
This fixes the problem that we send out a confusing error message for it.

Fixes #23912.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
(cherry picked from commit 1e36d79b83)
2023-01-19 11:05:02 -05:00
Alya Abbott
edfdcdc6e2 docs: Clarify --email installation option.
(cherry picked from commit 358a0dda5b)
2023-01-19 11:03:20 -05:00
Alex Vandiver
16f119b076 create-database: Hide harmless "non-existant database" warnings.
During installation on a new host, `create-database` attempts to
verify that there isn't a bunch of data already in the database which
is it about to drop and recreate.  In the most common case, this
statement emits a scary-looking warning, since the database does not
exist yet:

```
+ /home/zulip/deployments/current/scripts/setup/create-database
+ POSTGRES_USER=postgres
++ crudini --get /etc/zulip/zulip.conf postgresql database_name
++ echo zulip
+ DATABASE_NAME=zulip
++ crudini --get /etc/zulip/zulip.conf postgresql database_user
++ echo zulip
+ DATABASE_USER=zulip
++ cd /
++ su postgres -c 'psql -v ON_ERROR_STOP=1 -Atc '\''SELECT COUNT(*) FROM zulip.zerver_message;'\'' zulip'
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  database "zulip" does not exist
```

Because we are attempting to gracefully handle the case where the
database does not exist yet, we also continue (and drop the database)
in other, less expected cases -- for instance, if database contains a
schema we do not expect.

Explicitly check for the database existence first, and once we verify
that, allow any further failures in the `SELECT COUNT(*)` to abort
`create-database`.  This serves the dual purpose of hiding the "FATAL"
error for the common case when the database does not exist, as well as
preventing dropping the database if anything else goes awry.

(cherry picked from commit a1151aef8b)
2023-01-19 11:02:25 -05:00
Anders Kaseorg
047be276e9 styles: Delete useless rules for stream and topic names.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit b0c1b2c37f)
2023-01-19 11:01:05 -05:00
Anders Kaseorg
0a225401ed styles: Don’t clip tall characters in stream and topic names.
Fixes #23867.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 34306ba1f3)
2023-01-19 11:01:05 -05:00
Josh Klar
efd1978294 tests/i18n: Reflect Serbian translation update from Transifex. 2023-01-18 13:09:27 -08:00
Josh Klar
7a9b09eea7 i18n: Sync latest 6.x branch translations from Transifex. 2023-01-18 13:09:27 -08:00
Josh Klar
23ed3251ee i18n: Unescape Unicode sequences in JSON.
This greatly improves the readability of the diffs and in-codebase
translation strings over using ASCII sequences for unicode in the JSON.

We've previously noticed [^1] some JSON translation files ending up with
escaped Unicode sequences on disk, which Transifex indicates is expected
behavior [^2], though it is sometimes fixed by `manage.py
compilemessages` [^3]. Further, as noted in #23932 [^4], some JSON
translation files include HTML-escaped entities like quotation marks.

This script will ingest valid JSON files and output them as proper UTF-8
files with appropriately unescaped (unless otherwise necessary, like
double quotes being backslash-escaped) sequences, except when the key
itself contains HTML escape sequences (as it's presumed the value of
such entries must be pre-escaped before being passed to consumers).

[^1]: https://chat.zulip.org/#narrow/stream/58-translation/topic/Transifex.20client/near/1479205

[^2]: https://chat.zulip.org/#narrow/stream/58-translation/topic/an.20email.20for.20Transifex.20support/near/1481287

[^3]: https://chat.zulip.org/#narrow/stream/58-translation/topic/an.20email.20for.20Transifex.20support/near/1481908

[^4]: Which is not end-to-end fixed yet by this commit: that will
require a new release of Zulip Server.

gitlint-ignore: B1, title-trailing-punctuation, body-min-length, body-is-missing
2023-01-18 13:09:27 -08:00
Alex Vandiver
c57d885680 puppet: Go's website is officially go.dev, not golang.org.
(cherry picked from commit 8ba51f90e6)
2023-01-04 17:34:35 -05:00
evykassirer
ed930f2e7f emoji: Remove variation selector when generating emoji.
Fixes #23625.

The U+FE0F character was appearing in the data supplied by
emoji-datasource-google, but isn't in the CLDR data. By
removing that variation selector character, all remaining
emoji (that were previously marked as "not found in custom
emoji name maps, but also not found in CLDR data. Skipping.")
are now supported.
2023-01-03 11:33:37 -08:00
Mateusz Mandera
d9c1c25ef8 docs: Mention the reset_authentication_attempt_count command.
The authenticate_by_username limit of 5 attempts per 30 minutes can get
annoying in some cases where the user really forgot their password and
should be allowed to keep trying with admin approvial - so we should
document the command that allows unblocking them.
2023-01-03 11:30:53 -08:00
Mateusz Mandera
c3e58ef5f8 rate_limit: Add comments documenting how each rate limit rule works.
This avoid the need for spelunking the code to figure out the details of
how/when the rule is applied.
2023-01-03 11:30:53 -08:00
Anders Kaseorg
ce6f0e806a rocketchat: Import timezone-aware datetimes.
The bson library creates naive datetime objects by default.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-03 11:29:50 -08:00
Anders Kaseorg
53238f0e8f realm_logo: Add fallback for MediaQueryList.addEventListener.
MediaQueryList.addEventListener is missing in Safari < 14:
https://caniuse.com/mdn-api_mediaquerylist_eventtarget_inheritance

Fixes #23915.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-03 11:28:40 -08:00
Anders Kaseorg
52d9c96ae9 dark_theme: Move color scheme classes from body to root element.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-03 11:28:31 -08:00
Josh Klar
7a918eab48 docs: Use API Tokens instead of raw creds for Transifex. 2023-01-03 11:26:26 -08:00
Josh Klar
1698bd8615 provision: Respect proxy settings when installing shellcheck+shfmt. 2023-01-03 11:26:26 -08:00
Josh Klar
dc569809ee provision: Replace transifex-client with new transifex-cli.
transifex-client went EOL on November 30, 2022, replaced by
transifex/cli [^1].

Swap this in-place, since per the upstream README [^2]:

> The current version of the client maintains backwards compatibility
> for the tx push and tx pull commands. So, if you have a CI setup that
> uses them, you should not have to change anything.

As the mobile team found out, this is a partial truth if one previously
used some of the more advanced CLI flags, but all workflows referenced
in tools/ and docs/ use forwards-compatible flags to the new version.

[^1]: https://github.com/transifex/transifex-client/

[^2]: a0f28a1cf3/README.md
2023-01-03 11:26:26 -08:00
Alex Vandiver
f28eced391 upgrade-postgresql: Ensure the new PostgreSQL is running.
If a previous attempt at an upgrade failed for some reason, the new
PostgreSQL may be installed, and the conversion will succeed, but the
new PostgreSQL daemon will not be running (Puppet does not force it to
start).  This causes the upgrade to fail when analyzing statistics,
since the daemon isn't running.

Explicitly start the new PostgreSQL; this does nothing in most cases,
but will provider better resiliency when recovering from previous
partial upgrades.
2023-01-03 11:17:41 -08:00
Sahil Batra
d2be34d5aa settings: Fix bug when changing stream specific notification setting.
The class for "tr" element was changed in c22de76af7, so
get_stream_id function was not able to get the correct stream-id
from the target element. This commit fixes get_stream_edit
function to also check for closest ".stream-notifications-row"
ancestor element and thus it returns the correct stream id.
2023-01-03 11:17:32 -08:00
SameepAher
d64b536e11 compose: Fix overflow in expanded compose box preview mode.
Fixed a bug in expanded compose box preview mode,
which lead to buttons at the bottom of the compose box
being pushed off the screen and text overflowing.

Manually tested for different screen sizes.

Fixes: #23493.
2022-12-30 17:57:43 -08:00
Alex Vandiver
4bd092b98f apps: Fix redirect from /apps -> https://zulip.com/apps/.
When this code was moved from being in zerver in 21a2fd482e, it kept
the `if ZILENCER_ENABLED` blocks.  Since ZILENCER and CORPORATE are
generally either both on or both off, the if statement became
mostly-unnecessary.

However, because tests cannot easily remove elements from
INSTALLED_APPS and re-determine URL resolution, we switch to checking
`if CORPORATE_ENABLED` as a guard, and leave these in-place.

The other side effect of this is that with e54ded49c4, most Zulip
deployments started to 404 requests for `/apps` instead of redirecting
them to `https://zulip.com/apps/` since they no longer had any path
configured for `/apps`.  Unfortunately, this URL is in widespread use
in the app (e.g. in links from the Welcome Bot), so we should ensure
that it does successfully redirect.

Add the `/apps` path to `zerver`, but only if not CORPORATE_ENABLED,
so the URLs do not overlap.
2022-12-30 17:48:22 -08:00
Alex Vandiver
011aa62dc9 corporate: CORPORATE_ENABLED is always true in corporate.views.portico.
This is a holdover from when the portico was moved from zerver in
21a2fd482e.
2022-12-30 17:48:21 -08:00
Alex Vandiver
e873e9bea7 help: Don't unnecessarily link to zulip.com/help instead of local /help. 2022-12-30 17:48:21 -08:00
Josh Klar
971771d2e6 css: Apply negative spread radius to message box-shadows.
This fixes a visual regression in newer Electron builds (without
regressing Firefox) for which I still don't entirely know the root
cause, where extra "borders" were being applied to messages in both
streams and PMs. Applying a negative "spread radius" to the box-shadow
properties of these elements, and moving that pixel to the "horizontal
shadow" aspect of the property (which is used to create the left-side
"ruler" effect), restores the expected look and feel.

Tested in qutebrowser (Chromium 87-based), Electron v18+v19, and Firefox
107.

Refs (and should unblock) zulip/zulip-desktop#1251
2022-12-14 17:30:22 -08:00
Aman Agrawal
8a0344f60c recent: Sort PM recipients by their last sent message id.
Fixes #23563
2022-12-06 12:20:07 -08:00
Aman Agrawal
28c73c6bde recent_senders: Return senders in most recent sender first order.
Since the library is named `recent_senders`, most recent sender
first order is expected from this library.
2022-12-06 12:20:07 -08:00
Aman Agrawal
2c0c881837 recent_senders: Rename process_message_for_senders.
Since it only processes stream messages, change its name to
`process_stream_message`.
2022-12-06 12:20:07 -08:00
Aman Agrawal
d1085c0e11 Revert "recent: Remove participant avatars from PM rows."
This reverts commit 7e1fe7e569.
2022-12-06 12:20:07 -08:00
Lauryn Menard
1890b6e490 recent-conversations: Check for data change when processing message.
Add in a check to `recent_topics_data.process_message` so that we
know if any conversation data was updated and can rerender the
based on that information.
2022-12-06 12:18:48 -08:00
Mateusz Mandera
4dd2c68dec oneclick: Wait in a loop until the image build droplet gets an IP.
The script will fail if we process with a droplet object with no
.ip_address, which can sometimes happen if we just droplet.load().
Sometimes that gives droplet.ip_address set to None. If we wait in a
loop, we eventuall get the .ip_address set.
2022-12-06 12:17:36 -08:00
Aman Agrawal
e11b0171fa recent: Don't modify row_focus if table is not focused.
This fixes an error in the `inplace_rerender` code when we
are trying to remove a rendered row and correcting the `row_focus`
if it is on the row being removed. If the table is not in focus,
we don't need to do anything.
2022-12-06 12:17:30 -08:00
Alex Vandiver
ac8de664e8 docs: Renumber unique IDs on policies for easier uniqueness. 2022-12-06 12:16:31 -08:00
Alex Vandiver
8d2e1ad145 docs: Include full policy for avatars and uploads buckets.
The documentation included the full policy for the file uploads
bucket, but only one additional statement for the avatars bucket; the
reader needed to assemble the full policy themselves.

Switch to explicitly providing the full policy for both.

Fixes #23110.
2022-12-06 12:16:31 -08:00
Alex Vandiver
d276fe4a01 docs: Remove a now-unused link reference.
031260573f removed the use of this.
2022-12-06 12:16:31 -08:00
Aman Agrawal
787792ca3e left_sidebar: Add border radius to the selected stream. 2022-12-06 12:15:30 -08:00
Hemant Umre
ab7e3d9b3f left_sidebar: Fix section divider not shown when all streams are muted.
This fixes a bug where when all the streams in a section
in the left sidebar are muted, the section divider disappears.

The bug is caused by not considering muted streams when writing
the logic for when to show/not show section divider this commit
fixes it.

fixes #23241.
2022-12-06 12:14:53 -08:00
Anders Kaseorg
a45023a0c8 migrations: Fix Python-looped SQL in 0376; don’t crash if no user found.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-12-06 12:13:15 -08:00
David Rosa
7ad64efc20 docs: Fix link to "Custom profile fields".
Follow-up to PR #23264.
2022-12-06 12:12:09 -08:00
Anders Kaseorg
fda73976bd people: Fix misleading comments and tests for utcToZonedTime.
The reason utcToZonedTime would return an invalid Date (i.e. ‘new
Date(NaN)’) is because we passed in an invalid timezone.  Fix the
comments and tests to reflect this; remove unnecessary mocking and the
misleading ‘instanceof Date’ check.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-12-06 12:10:21 -08:00
Aman Agrawal
40d61be293 people: Verify utcToZonedTime returns a Date before formatting it.
`current_date` being invalid here could result in `user card`
not being displayed to users. So, it is important to verify that
the date is valid so that we don't run into any errors.

This fixes (unverified) an issue where user card was not being
displayed to some users on Zulip Desktop app because `current_date`
was not valid.
2022-12-06 12:10:06 -08:00
Lauryn Menard
247958d55c message-fetch: Update empty narrow check to include opts message list.
In 16c45aa, the check for an empty narrow was updated to no longer
confirm if no messages were returned by the message fetch request.

Updates the empty narrow check to confirm that the messages fetched,
and being processed are for the current / narrow message list before
showing an empty narrow.
2022-12-06 12:09:25 -08:00
Lauryn Menard
ea14e14862 narrow-banner: Fix empty narrow banner titles with user's full name.
Fixes an issue introduced in 6b4ab21 when we started using the
user's full name for empty narrow titles in a single operator
narrow of either "pm-with", "group-pm-with" or "sender".

For these empty narrow titles, any ', & or < characters in the
user's full name are not escaped.
2022-12-06 12:08:45 -08:00
Anders Kaseorg
6c592ce974 ruff: Fix N818 exception name should be named with an Error suffix.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-12-06 12:07:06 -08:00
evykassirer
5ae5fe45ff emoji: Remove commas from emoji names.
Fixes part of #23626.

This was preventing emoji like `:family_man,_woman,_girl,_boy:`
from displaying.
2022-12-06 12:05:43 -08:00
Alex Vandiver
ff621c8bc1 ci: Test upgrades from Zulip Server 6.0. 2022-12-06 12:04:37 -08:00
Alex Vandiver
f0ebe09e88 upgrade-postgresql: Force a known locale.
Some terminals (e.g. ssh from OS X) set an invalid locale, which
causes the `pg_upgradecluster` call late in the upgrade to fail.

Force a known locale, for consistency.  This mirrors the settings in
upgrade-zulip-stage-2, set in 11ab545f3b, and its subsequent
cleanups in 64c608a51a, ee0f4ca330, and eda9ce2364.
2022-12-06 12:02:52 -08:00
Sahil Batra
93134c291b settings: Fix custom input for user email-notification-batching setting.
The custom input was not being shown when changing user email
notification batching period setting dropdown to "Custom" option.
This was because parse_time_limit was undefined in case organization
settings was not loaded till then, and the code raised an error.

This commit changes the code to define parse_limit_function at
module-level instead of defining it in
register_save_discard_widget_handlers which is called only when
build_page is called which happens only when organization settings
is opened before changing the notification batching setting.

Fixes #23674.
2022-12-01 09:13:42 -08:00
Tim Abbott
13e2f5d267 version: Update version after 6.0 release. 2022-11-17 15:10:57 -08:00
Tim Abbott
f0e5f69c01 Release Zulip Server 6.0. 2022-11-17 11:44:45 -08:00
Alex Vandiver
bf00e44bde docs: Document the export_search compliance export tool. 2022-11-17 11:19:59 -08:00
Alex Vandiver
e41ee10966 export_search: Add a sender limit. 2022-11-17 11:19:59 -08:00
Alex Vandiver
809246e1dc docs: Fix a typo in a link anchor. 2022-11-17 11:19:59 -08:00
Alex Vandiver
ab71e97f1c docs: Remove an unused link anchor. 2022-11-17 11:19:59 -08:00
Tim Abbott
5565c85624 i18n: Update translations from Transifex. 2022-11-17 11:05:47 -08:00
Aman Agrawal
f0d87fcf6e unread_ops: Provide more responsive feedback flagging msgs read/unread.
Processing 1k messages takes roughly 1s on a live server like
chat.zulip.org, which is a good enough duration after which
user will be looking to get some feedback on the request. Once
we show the in-progress banner, it makes sense to do bigger
batches to speed up the process.
2022-11-17 10:55:34 -08:00
Tim Abbott
59633e36cb unread: Simplify include_anchor for mark all as read. 2022-11-17 10:26:57 -08:00
Tim Abbott
911cf46c72 unread: Fix mark all as read when oldest unread message is muted.
As detailed in the comment, the new "mark all as read" bankrupcty code
path would fail to mark as read muted stream messages that are older
than the oldest unread non-muted message.

This was because of the semantics of the `first_unread` anchor value
being actually "fire unmuted unread".

We can just change this to "oldest", because we're already using an
`is:unread` for the narrow query; doing so likely is a small
optimization, since we save the query to compute the first unread.
2022-11-17 10:26:57 -08:00
Lauryn Menard
16c45aaf42 narrow: Show empty narrow banner if all topics muted in stream.
Adjusts the check in `message_filter.process_results` to happen
after the messages have been processed so that the empty narrow
banner is shown if there are no messages in the current message
list, which covers the case of there being no messages returned
from the server (e.g. a keyword search, no private messages with
a user) and the case of all existing stream topics being muted
by the current user.
2022-11-17 10:24:49 -08:00
Aman Agrawal
7e1fe7e569 recent: Remove participant avatars from PM rows.
Fixes: #23561.
2022-11-17 09:37:46 -08:00
Tim Abbott
14e14c4d35 unread: Do full rerender of recent view on mark unread.
This matches the current bulk-operation behavior of the message lists,
and avoids spending an enormous amount of time adjusting unread counts
once per message in a loop over thousands of messages.

Also add some comments on adjacent code paths.
2022-11-17 09:06:33 -08:00
Lauryn Menard
79c0d7fbab recent-conversations: Update logic for processing messages.
As of 550a32b, when private messages were added to recent
conversations, `recent_topics_data.process_message` will
always return true.

Updates `recent_topics_data.process_message` for no return
value. Also, removes the `topic_data_changed` logic from
`recent_topics_ui.process_messages` and instead checks for
messages to process before updating the data and calling the
rerender.

`recent_topics_ui.complete_rerender` first checks for whether
the recent conversations view is visible before rerendering.
2022-11-17 09:05:24 -08:00
Sahil Batra
5c833f0423 compose_ui: Revert changes for replace_syntax done in 1ca4566eb2.
This commit reverts the changes for replace_syntax in 1ca4566eb2
and we again use JS replace instead of replace from text-field-edit.

We do this change because replace from text-field-edit leaves the
replaced text selected, which we don't want. This change is
temporary and we can probably use replace method from
text-field-edit once this issue is fixed in upstream.
2022-11-17 08:29:11 -08:00
Aman Agrawal
c3589ad763 unread_ops: Fix plural and singular forms of text. 2022-11-17 00:46:26 -08:00
Tim Abbott
3aec5564eb popovers: Offer mark as unread regardless of fetch_status.
Now that we're using the new /messages/flags/narrow API endpoint, we
don't need this conditional.
2022-11-17 00:46:26 -08:00
Aman Agrawal
0bc0a701f8 unread_ops: Use the improved /messages/flags API to mark all as read.
Fixes #23406.
Fixes #14053.

This also uses the new alert banner system.

It is not clear if we want to scroll user to the end of the narrow
after this update is complete. There is a "scroll to bottom" button
for users who want to be placed at the end of the narrow but there
is no reverse option for users who don't. So, maybe not changing
the scroll position is preferred especially since we now use
banners for the update where a user could have been reading something
while we were updating the message flags in the background.

We do not handle the case of `mark as read` and `mark as unread`
both running in batches at the same (This is a somewhat rare case
given the high cap on `NUM_OF_MESSAGES_UPDATED_PER_BATCH` but
possible.).

`unread.declare_bankruptcy` is no longer used in the code but
we keep it since it is used extensively in tests.
2022-11-17 00:46:26 -08:00
Aman Agrawal
c876e12b86 unread_ops: Let server do the mark as unread for us.
Previous algorithm was not correct if we didn't have full data for
the current narrow loaded from the server. #23512 adds the support
to mark messages in a narrow unread after a give message_id.

Added a new alert banner to indicate loading and success states of
an ongoing request. This is useful when requests can take a long
time to complete.
2022-11-17 00:46:26 -08:00
Tim Abbott
0ba63826dd tornado: Disable event compression for mark-as-unread events.
Doing rapid pace mark-as-unread in the Zulip web application, one
observed assertion failures showing that the server would send an
event containing multiple message IDs but only one of the messages
present in the message_details side data structure.

The cause of this was the "virtual events" compression system; two
flags/remove/read events were being combined by simply concatenating
the lists of events, without any attempt to merge the
`message_details` field on those objects.

The immediate fix is to disable virtual events compression for this
event class, but it's not unlikely we'll need to just eliminate the
virtual_events system entirely, because it seems difficult to make it
soundly handle a message whose state for a given flag changes back and
forth while the client is offline.

But we'll leave that for later, since removing that optimization
deserves more discussion than fixing this event corruption bug.
2022-11-17 00:46:26 -08:00
rht
af00d20402 mailmap: Add entry for rht. 2022-11-17 00:05:17 -08:00
Tim Abbott
564aad2f33 i18n: Update translations from Transifex. 2022-11-16 22:53:02 -08:00
Tim Abbott
d488ca42e6 docs: Update changelog with commits staged for 6.0. 2022-11-16 22:21:18 -08:00
Anders Kaseorg
842a5bb54b message_flags: Allow updating flags by narrows and anchors.
Fixes #22893.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 21:13:44 -08:00
Anders Kaseorg
5d0711df6d message_flags: Don’t send events for no-op flag updates.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 21:13:44 -08:00
Anders Kaseorg
54878a1826 message_flags: Convert operation string to boolean.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 21:13:44 -08:00
Anders Kaseorg
5b5be1fd82 message_flags: Use bulk_access_messages in do_update_message_flags.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 21:13:44 -08:00
Anders Kaseorg
342cba7b4d message: Fetch streams in bulk in bulk_access_messages.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 21:13:44 -08:00
Anders Kaseorg
fef365248b create_user: Create historical UserMessage rows with bulk_create.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 21:13:44 -08:00
Anders Kaseorg
ee2cb855f0 message_fetch: Add include_anchor parameter.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 21:13:44 -08:00
Anders Kaseorg
dae4633745 message_fetch: Extract fetch_messages helper to zerver.lib.narrow.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 21:13:44 -08:00
Anders Kaseorg
bd5d200722 narrow: Return a dataclass from post_process_limited_query.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 21:13:44 -08:00
Anders Kaseorg
0a0a70b33d message_fetch: Move limit_query_to_range to zerver.lib.narrow.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 21:13:44 -08:00
Anders Kaseorg
1095efeb52 message_fetch: Move parse_anchor_value to zerver.lib.narrow.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 21:13:44 -08:00
Anders Kaseorg
4eea5e102e message_fetch: Move ok_to_include_history to zerver.lib.narrow.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 21:13:44 -08:00
Tim Abbott
e797715f1d mailmap: Add a few more canonical names. 2022-11-16 15:49:09 -08:00
Tim Abbott
2a613bbed9 mailmap: Merge duplicates for contributors to the 6.0 release. 2022-11-16 15:26:28 -08:00
Alex Vandiver
2c2afddf1e release-checklist: Clarify main changes are one commit, not two. 2022-11-16 14:37:07 -08:00
Alex Vandiver
dd8ff7e22b release-checklist: Remove duplicated words.
A classic "I love paris in the the springtime" bug.
2022-11-16 14:37:07 -08:00
Alex Vandiver
6be6bcc5e3 release-checklist: Update and clarify the Docker / Helm steps. 2022-11-16 14:37:07 -08:00
Alex Vandiver
fac4c38404 release-checklist: Note that we can test on 22.04 as well. 2022-11-16 14:37:07 -08:00
Aman Agrawal
ec1a114c7e left_sidebar: Fix extra space between stream header and PM header. 2022-11-16 12:00:11 -08:00
M@
280523ad48 slack import: Merge and dedupe same-base emoji reactions and userlists.
The naive solution #23465 creates situations where the same user can have
multiple reactions as the base emojis are not unique, e.g. +1::skin2
and +1::skin4 would both reduce to +1 but the userlists are separate.
This solution handles the reduction, merges the same-base reactions,
and deduplicates the userlist.

Co-authored-by: Alex Vandiver <alexmv@zulip.com>
Co-authored-by: rht <rhtbot@protonmail.com>
2022-11-16 11:11:43 -08:00
Tim Abbott
6f1a341d2d compose: Increase z-index for compose box.
Following b563fdc537, the z-index of the
compose box (2) tied with that of unread date dividers within a topic;
this could lead to the dividers incorrectly appearing on top of the
compose box.

We don't have other elements that can overlap with compose with a
z-index between 2 and 4, so just increase it to 4.
2022-11-16 11:01:09 -08:00
Sahil Batra
e67fc9a713 compose_validate: Remove comments for stream-admin related code.
This commit removes comments related to stream-admin option from
wildcard_mention_allowed.

We have already removed stream-admin option from wildcard mention
policy setting in 83383090f9 since we are no longer planning to
implement stream admin feature and instead are working on new
permissions model based on user groups.
2022-11-16 09:36:56 -08:00
Anders Kaseorg
e4f1c10b87 requirements: Remove isort.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
9a8a2bd345 ruff: Enable import sorting, replacing isort.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
06e64e5713 ruff: Enable sys.version errors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
1b016bef73 ruff: Enable naming errors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
924d530292 ruff: Fix N813 camelcase imported as lowercase.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
8f17093be2 ruff: Fix N812 lowercase imported as non-lowercase.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
0258fba345 ruff: Fix N811 constant imported as non-constant.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
2876ae8e48 ruff: Fix N803 argument name should be lowercase.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
cc01c68aa9 ruff: Enable annotations errors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
46955da3a0 ruff: Fix ANN204 missing return type annotation for __init__.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
3442bf2843 requirements: Upgrade Ruff.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Anders Kaseorg
1735b8863e ruff: Fix B012 return inside finally blocks.
return inside finally blocks causes exceptions to be silenced.
Although these blocks follow blanket ‘except Exception’ handlers, they
do not seem to have a goal of silencing BaseException and exceptions
thrown by the exception handler, so rewrite them to avoid it.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 09:29:11 -08:00
Alex Vandiver
c4e5ddd67f version: Update version and changelog after 5.7 release. 2022-11-16 16:03:05 +00:00
Anders Kaseorg
2cc3fa4fba scim: Check SCIM tokens using constant-time comparison.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-16 10:52:48 -05:00
Rohitt Vashishtha
103b8f6de3 typeahead: Patch third/typeahead.js for IME event handling.
We do not want to import any of our modules into this file, so
it has an independent implementation of the fix for #22062. Also,
using -13 as a keyCode helps avoid having to make changes to all
the comparisons with e.keyCode that the module relies on.
2022-11-15 17:41:15 -08:00
Anders Kaseorg
e5c26eeb86 tornado: Support sharding by user ID.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-15 17:27:01 -08:00
Tim Abbott
8010d06f9e compatiblity: Delete obsolete compatibility code.
Both of these compatibility blocks can be deleted, since you can't
upgrade directly to any supported release from the versions where the
old event formats would be used.
2022-11-15 15:39:38 -08:00
Hari Prashant Bhimaraju
f374498f38 papertrail: Strengthen types using WildValue. 2022-11-15 15:05:02 -08:00
Hari Prashant Bhimaraju
4210ab6c41 ifttt: Strengthen types using WildValue. 2022-11-15 15:05:02 -08:00
Zixuan James Li
71abbbdd7a message_edit: Handle truncated topic resolution.
This solves the problem that resolving a topic with a long name (>60
characters) will cause the topic name to be truncated, and thus the edit
message code path thinks that the topic is being moved in addition to
being resolved.

We store the pre-truncation topic and use it to check against the
original topic when determining whether a topic is being moved while
getting (un)resovled or not.

Fixes #23482

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-11-15 14:33:39 -08:00
Zixuan James Li
c821127131 message_edit: Fix resolution notification not being sent twice.
We intended to send both the "topic was resolved" and the "topic was
moved here" notification when resolving and moving a topic at the same
time in #22312.

The previous implementation did not work as expected and it was only
sending the "topic was moved here" notification.

This removes the check for old_topic and new_topic that have
RESOLVED_TOPIC_PREFIX stripped in maybe_send_resolve_notifications, so
that the notification will be sent regardless if the topic name without
the prefix stays the same or not.

Note that weird topic handling ("✔ ✔✔ some topic") in the comments
was added in e231a03eff is unaffected. In case of confusion, the lstrip
check is not essential to detecting topic being unresolved/resolved.
As we mainly have that handled in the latter part of the helper.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-11-15 14:33:39 -08:00
Alex Vandiver
f3fd0b6975 release: Support -rc1 style suffixes for releases.
These suffixes suppress some checks in the process, but still generate
and upload a tarball, push a tag, and make a Github prerelease.
`upload-release` already understands that anything with a suffix never
becomes the "latest" release.
2022-11-15 12:50:41 -08:00
Alex Vandiver
1f1e1e4ec2 build-release-tarball: Override merge-base for full official releases. 2022-11-15 12:50:41 -08:00
Alex Vandiver
e95e8b985f release: Be explicit about which branch was expected. 2022-11-15 12:50:41 -08:00
Alex Vandiver
abb7a63b62 release: Be consistent about TZ-setting. 2022-11-15 12:50:41 -08:00
Alya Abbott
e215015e80 portico: Add links to /values to footer and /history. 2022-11-15 11:21:14 -08:00
Alya Abbott
87b99af1d0 portico: Minor improvements to /history and /values. 2022-11-15 11:21:14 -08:00
Hari Prashant Bhimaraju
5346de9164 circleci: Rewrite integration to support the new webhook format.
CircleCI has updated its webhook format[1] for CircleCI Cloud,
Server version 3.x and 4.x. This commit rewrites the CircleCI
integration to parse the new webhook structure. The tests have also
been rewritten for the new format.

With this commit, we support webhooks from projects that use GitHub,
BitBucket and GitLab as VCS providers. The CircleCI integration doc
has been updated to mention the same. The doc has also been updated
with the latest instructions for configuring a webhook on the CircleCI
interface, and the new output screenshots.

References:
[1]: https://circleci.com/docs/webhooks
2022-11-15 10:45:05 -08:00
rht
5ce2103b87 Slack import: Cache emoji.json in static/generated/emoji.
Previously, emoji.json was read from
"$ZULIP_PATH/node_modules/emoji-datasource-google/emoji.json".
This path doesn't exist in production when installing from scratch from
a release tarball. And so, we ensure emoji.json exists by copying it to
`static/generated/emoji`.

With tweaks to comments by tabbott.

Fixes: #23469
2022-11-15 10:43:11 -08:00
Rohitt Vashishtha
7e883add5b dark_theme: Re-render realm-logo on prefers-color-scheme changes.
We already re-rendered the realm-logo when the user selects either
the light or dark color scheme, but on `color-scheme-automatic`,
we didn't have any event handlers to trigger a render. This commit
adds a handler to listen for changes to `prefers-color-scheme` property.

Fixes #23548.
2022-11-15 10:35:31 -08:00
David Rosa
a3c5c97488 help center: Document "Mark messages as unread" on mobile.
Fixes #23560.
2022-11-15 10:27:22 -08:00
Sahil Batra
f772eeddd6 util: Add call_function_periodically helper function.
This commit adds call_function_periodically helper function
which will be used to call functions periodically using
setTimeout. Currently, this new function is used to send
presence requests and trying reload.
2022-11-15 10:23:32 -08:00
Sahil Batra
5ce7015cc8 reload: Replace setInterval with setTimeout.
We retry reloading repeatedly at an interval of 30 seconds,
to handle the case where window.location.reload has no
immediate affect.

Previously, setInterval was used for this, but this commit
replaces it with nested setTimeout calls.

This change will help us in avoiding a large number of
requests to `/` in case when browser tries to "catch up"
pending calls after unsuspend.
2022-11-15 10:23:32 -08:00
Mateusz Mandera
f80a999828 invites: Add defensive assert in do_get_invites_controlled_by_user.
This is a follow-up to d201229df8.
do_get_invites_controlled_by_user queries for Confirmations when finding
multiuse invites controlled by a user. This means that a revoked
multiuse invite cannot really be fetched here, because
do_revoke_multi_use_invite deletes the Confirmation object when revoking
the invitations. However, having a defensive assert here should be
useful to make this doesn't secretly break in the future if the query
used changes or if there are unexpected revoked multiuse invites with an
existing Confirmations for any (buggy) reason.
2022-11-15 09:27:38 -08:00
Alya Abbott
c0255d4fe4 corporate: Remove Senior Full Stack Engineer opening from /jobs page. 2022-11-14 17:34:08 -08:00
Mateusz Mandera
d201229df8 signup: Implement use of MultiUseInvite.status attribute.
This allows us to revoke MultiUseInvites by changing their .status
instead of deleting them (which has been deleting the helpful tracking
information on PreregistrationUsers about which MultiUseInvite they came
from).
2022-11-14 17:13:16 -08:00
Hari Prashant Bhimaraju
977a043d03 grafana: Support notifications from Grafana Alerting.
This commit adds support for Grafana's new alerting system, Grafana
Alerting. The existing Grafana integration has been modified to
detect the version of the notification through the structure of the
payload body, since the the structure varies by version. Support for
legacy alerting is been continued. Example fixtures have been added
for Grafana Alerting's webhooks.

Tests updated.
2022-11-14 16:28:59 -08:00
Hari Prashant Bhimaraju
804eb15aa5 grafana: Strengthen types using WildValue. 2022-11-14 16:28:59 -08:00
Alya Abbott
86d8a9c626 help center: Document user cards. 2022-11-14 16:03:37 -08:00
Anders Kaseorg
1e84edf4f2 message_flags: Avoid relying on redundant messages list in response.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-14 16:00:54 -08:00
Anders Kaseorg
c7fefab05d stream_create: Fix “susbscribing” typo.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-14 15:28:30 -08:00
Hari Prashant Bhimaraju
8ab47bbcc4 opbeat: Strengthen types using WildValue. 2022-11-14 13:49:38 -08:00
Hari Prashant Bhimaraju
645e464f98 jira: Strengthen types using WildValue. 2022-11-14 13:49:38 -08:00
Hari Prashant Bhimaraju
d8732e6769 intercom: Strengthen types using WildValue. 2022-11-14 13:49:38 -08:00
Hari Prashant Bhimaraju
ac1a38db75 gocd: Strengthen types using WildValue. 2022-11-14 13:49:38 -08:00
Hari Prashant Bhimaraju
2bd1093c38 gosquared: Strengthen types using WildValue. 2022-11-14 13:49:38 -08:00
Hari Prashant Bhimaraju
08eb34d0d6 greenhouse: Strengthen types using WildValue. 2022-11-14 13:49:38 -08:00
Hari Prashant Bhimaraju
a38b1390ac groove: Strengthen types using WildValue. 2022-11-14 13:49:38 -08:00
Hari Prashant Bhimaraju
8f4133b63e harbor: Strengthen types using WildValue. 2022-11-14 13:49:38 -08:00
Hari Prashant Bhimaraju
c692fc400d hellosign: Strengthen types using WildValue. 2022-11-14 13:49:38 -08:00
Hari Prashant Bhimaraju
f0fd083e88 homeassistant: Strengthen types using WildVale. 2022-11-14 13:49:38 -08:00
Hari Prashant Bhimaraju
6f374b666e insping: Strengthen types using WildValue. 2022-11-14 13:49:38 -08:00
Hari Prashant Bhimaraju
1ac9573a67 jotform: Strengthen types using WildValue. 2022-11-14 13:49:38 -08:00
Hari Prashant Bhimaraju
537632d58c wekan: Strengthen types using WildValue. 2022-11-14 13:49:38 -08:00
Matt Keller
958b58f174 slack: Skip reactions for deleted users.
Fixes #23552.
2022-11-14 13:08:15 -08:00
Alya Abbott
3e6d7c11b0 help center: Add use cases to /help/marking-messages-as-unread. 2022-11-14 13:07:35 -08:00
Lauryn Menard
32d35bcec8 help-docs: Update mobile instructions for invisible mode. 2022-11-14 13:06:54 -08:00
Tim Abbott
23856433e4 popovers: Fix styling of user card/profile status dots.
The tweaks I made as part of merging
f204a4c592 apparently were wrong; the
CSS class .popover_user_presence had been shared between both the user
card and the profile.

Fix this by referencing the right CSS classes. Additionally, fix the
margins to have a square hover region around the presence dot.

Fixes #23588.
2022-11-14 13:03:53 -08:00
Aman Agrawal
1365cc2263 hotkey: Handle enter keypress on body for recent topics.
This fixes a bug where pressing `enter` on a topic in recent
topics opens the compose box instead of narrowing to the topic.
2022-11-14 12:53:15 -08:00
Sahil Batra
a0965d7335 activity: Use setTimeout instead of setInterval.
Instead of using setInterval to call send_presence_to_server
repeatedly, we now simluate setInterval using setTimeout.

This change helps us to avoid the condition likely related to resume
from suspend, when the browser tries to catch up by running a large
number of "missed" copies of the setInterval hook, causing the server
to rate-limit the client.

Fixes #23438.
2022-11-14 12:37:14 -08:00
Aman Agrawal
fbe9a9e539 left_side_userlist: Remove feature from frontend.
Fixes #23517.

While this feature was added to Zulip very early, it has been troubled
for most of that time; it never looked great visually, had a lot of
implementation complexity around resize.js, and has a weird model (a
setting that changes the UI only in certain window sizes).

This option is not commonly used; while a significant portion of users
have it enabled, many of them just don't use window sizes where it
actually has an effect. So it's not clear that it will be missed if
removed; we got very few bug reports when it was completely broken for
a few days after we first integrated the new left sidebar private
messages design.

Even with it no longer being broken, it does not work very well with
the addition of the new PMs section in the left sidebar. (Having two
scrollbars in the sidebar looks quite awkward.) The new private
messages section in the left sidebar also addresses some of the use
cases for always keeping the Users list always visible, even in narrow
windows.

This option is only removed from frontend for now. To make this
decision easily reversible, the backend code of this feature
is still kept.
2022-11-14 12:23:55 -08:00
Aman Agrawal
2b0a4aad50 resize: Remove unused h parameter. 2022-11-14 12:18:24 -08:00
Aman Agrawal
91b2ecac45 ui_init: Remove dead code.
`right-userlist` isn't used anywhere in the code.
2022-11-14 12:18:24 -08:00
Lauryn Menard
de12500f68 popovers: Rename "full profile" to "profile".
Now that we now longer have another thing called a "user profile", we
can simplify the name for this part of the UI.

Fixes #23530.
2022-11-14 12:16:22 -08:00
Lauryn Menard
9aacb15530 tabbed-sections: Update "via-user-profile" to be "via-user-card". 2022-11-14 12:16:22 -08:00
Lauryn Menard
48e2482bbd popovers: Rename "profile summary" to "user card".
This is a briefer and more intuitive name for this frequently accessed
part of the Zulip UI.
2022-11-14 12:15:54 -08:00
Taiki
a09014f1de modals: Fix modal buttons in Safari for some users.
Some Safari users users observed an issue where these modal buttons
appeared with an ugly white-on-grey format. Removing the CSS line with
`appearance: button` appears to fix this for affected users.

That line seems unlikely to have been constructive; as documented in
https://developer.mozilla.org/en-US/docs/Web/CSS/appearance, this is a
deprecated value equivalent to `auto`, and a bit of a misfeature.

Additionally, the "Log in" button was incorrectly underlined on hover;
override that style.
2022-11-14 11:08:55 -08:00
Aman Agrawal
b563fdc537 css: Fix hidden unread marker when a user mentioned message is focused.
Increase z-index of unread-marker to always appear above the message and
focused outline. Also, z-index of date_row is increased to hide
unread marker for it in special conditions.
2022-11-14 09:46:44 -08:00
Sahil Batra
d35e482ddc modals: Don't close the modals on selecting something inside the modal.
Modals are closed when selecting something inside the modal if mouse
is dragged outside the modal. This happens as leaving the mouse after
dragging it outside the modal induces a click even outside the modal
and the current behavior is to close the modal on clicking outside it.

We remove the "data-micromodal-close" attribute from "modal__overlay"
element which is responsible for closing the modal. And we add
click handler which closes the modal on clicking outside the modal but
does not closes it when the mouse is dragged outside while selecting
something.

Fixes #23350.
2022-11-14 09:08:39 -08:00
Mateusz Mandera
3bb2096a7f do_reactivate_realm: Noop if realm is already active.
If the realm doesn't actually need re-activation, this should be a noop
rather than creating a confusing RealmAuditLog entry.
2022-11-13 14:28:33 -08:00
Mateusz Mandera
5c20e2af78 test_do_send_realm_reactivation_email: Deactivate the realm first.
This doesn't make sense if the realm is active and will fail as soon as
do_reactivate_realm is fixed in the next commit to be a noop and not
create confused RealmAuditLog entries when the realm is active.
2022-11-13 14:28:33 -08:00
Mateusz Mandera
23a776c144 maybe_send_to_registration: Don't reuse pre-existing PreregistraionUser.
There was the following bug here:
1. Send an email invite to a user.
2. Have the user sign up via social auth without going through that
   invite, meaning either going via a multiuse invite link or just
   straight-up Sign up if the org permissions allow.

That resulted in the PreregistrationUser that got generated in step (1)
having 2 Confirmations tied to it - because maybe_send_to_registration
grabbed the object and created a new confirmation link for it. That is a
corrupted state, Confirmation is supposed to be unique.

One could try to do fancy things with checking whether a
PreregistrationUser already have a Confirmation link, but to avoid races
between ConfirmationEmailWorker and maybe_send_to_registration, this
would require taking locks and so on - which gets needlessly
complicated. It's simpler to not have them compete for the same object.

The point of the PreregistrationUser re-use in
maybe_send_to_registration is that if an admin invites a user, setting
their initial streams and role, it'd be an annoying experience if the
user ends up signing up not via the invite and those initial streams
streams etc. don't get set up. But to handle this, we can just copy the
relevant values from the pre-existing prereg_user, rather than re-using
the object itself.
2022-11-10 17:46:53 -08:00
Mateusz Mandera
b5b8cc06dc auth: Clean up redundant request.session.modified change.
This line was added in 94e099eaab,
presumably because of the
del request.session["multiuse_object_key"]
line that was just above it.
Looks like it should have been removed in
868a763cec, which eliminated that `del`
operation.
2022-11-10 17:46:53 -08:00
Alex Vandiver
f3135eb414 export_search: Add ability to limit by date sent. 2022-11-10 16:49:19 -08:00
Alex Vandiver
2d5366f455 export_search: Add a compliance tool to export a subset of messages.
This is primarily for administrators needing to provide message
history for compliance or auditing purposes.  Search terms can be
pulled from a file, one per line, or from arguments provided on the
command line.
2022-11-10 16:49:19 -08:00
Alex Vandiver
1f18fa6580 register: Not all clients send a User-Agent header.
In 1fce1c3c73, we added logic to parse
the User-Agent in /register requests; this logic crashed if an HTTP request
was missing that header.

Includes a test for `/register` with no user agent passed; this should catch
similar regressions in the future.

Co-authored-by: Mateusz Mandera <mateusz.mandera@zulip.com>
2022-11-10 16:21:04 -08:00
Imran
0e0a910304 settings_user: Change audio to audible in settings. (#23518)
The notifications headings were not consistent between the personal stream settings panel
and /help/desktop-notifications.

This changes notifications headings from "Audio" to "Audible", since that seems like the
better choice of word.

Fixes #23515.
2022-11-10 16:18:56 -08:00
Tim Abbott
1ca4566eb2 compose: Use text-area-edit for syntax replacements.
Fixes #23284
The basic approach used by `text-area-edit` is same as we were
using, so there is no real change. There are some nice checks
in `text-area-edit` which we don't do that helps us avoid
common bugs.
2022-11-10 16:15:33 -08:00
Sahil Batra
6ad8e276de settings: Refactor code for realm message retention setting.
This commit refactors the code for realm message retention
setting to make it more similar to code for other time-limit
realm settings. There are still separate functions for the
message retention setting but they are similar to that of
other time-limit settings and can probably help us to
deduplicate the code in future. This refactor also helps
us in reusing some code for stream message retention
setting for changes in #23013.

This commit also fixes a bug where save-discard widget
not being hidden when resetting the setting to original
value. This can only be reproduced when the original
setting value is "retain_forever".

Following changes have been done in this commit -

- Added data-setting-widget-type attribute which is set to
"message-retention-setting" similar to "time-limit" value for
message edit and delete limit settings.

- Added get_message_retention_setting_value function similar
to get_time_limit_setting_value function which is used by
get_input_element_value.

- Removed "message-retention" block from
get_complete_data_for_subsection and the message retention
setting is now added to request data in populate_data_for_request
itself using data-setting-widget-type attribute.

- Updated id and class of elements to support the above changes.
2022-11-10 16:13:49 -08:00
Sahil Batra
73e247f08c settings_org: Fix save-discard not hidden for "Other settings" section.
When resetting a setting in "Other settings" section to its original
value, the save-discard widget for the section is not hidden. This can
be reproduced when no language is set for code-block default language
setting. This was because check_property_changed incorrectly returned
true as the original value for code-block language setting was null
but the widget element returned empty string.
2022-11-10 16:13:49 -08:00
Riken Shah
51870f86da recent_topics: Show user status emoji in PMs messages.
To implement this, we are rendering users in PMs with
the status icon (via `user_with_status_icon.hbs`) and
then passing rendered HTML to the recent topics row.

Fixes #23262
2022-11-10 12:32:08 -08:00
Riken Shah
9d12a9c21e recent_topics: Show user presence status in PMs messages.
We have bound the `mouseenter` event with a circle
status parent element to render the tooltip. Instead of passing
the tooltip content directly in `data-tippy-content`, we
are rendering it via JS because when showing the bot
tooltip we want a multiline tooltip.

We have also made some minor changes to `do_render_buddy_list_tooltip`,
so we can append the tooltip to the target element and avoid adding
a observer to it.

This commit also sets the font weight for tippy content to
400 to avoid bold content.
2022-11-10 12:32:08 -08:00
Aman Agrawal
6e3d8c7733 recent_topics_row: Let pm status icons have its own class.
Some additional changes to make align them correctly after
the assigning the new class.
2022-11-10 12:32:08 -08:00
Lauryn Menard
f0c71a0293 unread-ops: Add check to make mark_as_read_turned_off_banner visible.
When processing an "update_message_flags" event to mark messages
as unread, check the current message list once messages are updated
to see if the `mark_as_read_turned_off_banner` should be visible.

This means that other clients in a view that also does not mark
messages as read (for example a sender or keyword search narrow)
will also load the banner when the view is updated.

Fixes #23502.
2022-11-10 12:07:02 -08:00
Sayam Samal
f204a4c592 user_profile_modal: Move presence activity status to modal header.
Moving the last active status icon to the modal header, we obtain a
cleaner visual design for the user profile modal which is more
consistent with other parts of UI.
2022-11-10 12:03:59 -08:00
Alya Abbott
52a04b53ad help center: Clean up "Deactivate or reactivate a user" help page.
Also, removes now unused image in `/static/images/help`:
`deactivate-user-email.png`.

Fixes #23503.
2022-11-10 12:00:25 -08:00
Alya Abbott
343bd395ca help center: Make minor tweaks to Change a user's {role}/{name} pages.
- Factor out instructions for navigating to the "Manage this user" tab.
- Add links to related articles.
2022-11-10 12:00:25 -08:00
David Rosa
59df44f5ce help center: Migrate reusable content in "Import from Slack".
Moves reusable content to multiple Markdown macros.
2022-11-10 11:56:55 -08:00
David Rosa
ba44f308dc help center: Tweak "Import from Slack" page for reusability.
We can reuse the content from multiple sections of the Slack article
to update "Import from Mattermost/Gitter/Rocket.Chat" by making small
wording tweaks.
2022-11-10 11:55:41 -08:00
David Rosa
8e21b6bf95 help center: Improve "analytics" article.
- Renames the page to "Usage statistics" (title & left sidebar).
- Adds an intro section that outlines the types of information
that can be found on the stats page.

Fixes #23449.
2022-11-10 11:27:42 -08:00
Rixant Rokaha
dd39a9747d left_sidebar: Hide stream section separator when there is only one.
Showing section separators in the left sidebar ("Pinned streams",
"Active streams", etc.) is unnecessary when there is only one section,
and can feel confusing. We should show the separators only when there
is more than one section present.

Fixes #22843.
2022-11-09 17:34:58 -08:00
Tim Abbott
72b5af2260 docs: Clarify the http_only parameter.
Previously, the http_only parameter could have been misread as
allowing clients to connect to a Zulip server over HTTP directly.

Fixes #23506.
2022-11-09 17:05:15 -08:00
Tim Abbott
9074a164e6 resize: Adjust left_side_userlist sizes when showing sidebar.
This fixes a race in certain intermediate sizes, with the
left_side_userlist setting, the sidebar sizes would have been computed
with invalid information about the size of the two regions to divide
space between (because the sidebar was closed when the calculation was
done).
2022-11-09 16:55:19 -08:00
Tim Abbott
56005da39d popovers: Simplify sidebar hiding logic for user menus.
Structurally, the goal of this logic is to just hide all popovers
(including potential user popovers) and not the sidebars; use the
function designed for that purpose rather than hackily
hand-implementing it.
2022-11-09 16:55:19 -08:00
Tim Abbott
87bc18c2be popovers: Don't close user list sidebar opening left sidebar menus.
In window width ranges where the left sidebar is fully open and the
right sidebar is toggleable, the existing logic to hide all popovers
and then reopen the left sidebar stream list.

We have a function designed to close all popovers that aren't
sidebars; we should just use it.

See 2d414fa897 for a previous incomplete
fix for this issue.
2022-11-09 16:55:19 -08:00
Aman Agrawal
7dbd2f74d9 resize: Simplify code to calculate max height of left sidebar blocks.
The `size_blocks` code was cool looking but wasn't working well.
Since we only have to place streams list and users list, we can
fix their `max-height` more easily without trying to solve the
`multi-block` case which `size_blocks` was trying to do.

This also fixes users list max-height being incorrectly set,
resulting in user unable to scroll to some user list items.
2022-11-09 16:55:19 -08:00
Alya Abbott
37a7adfd96 portico: Add new features to /features page. 2022-11-09 16:47:40 -08:00
David Rosa
47a8eb0b66 help center: Document viewing @-mentions.
Adds "View your mentions" page to document how to access @-mentions
and the @ indicator for unread @-mentions on desktop/web and mobile.

Fixes #23422.

Co-authored-by: Alya Abbott <alya@zulip.com>
2022-11-09 15:51:44 -08:00
Tim Abbott
c22de76af7 settings: Fix reuse of .stream-row class name.
The stream-specific notifications table incorrectly used the
.stream-row CSS class. As a result, live-update code for the "stream
settings" UI when changing a stream's permissions model would
incorrectly replace rows of this table with a "Manage streams" style
row.
2022-11-09 15:30:03 -08:00
Anders Kaseorg
70dbeb197f middleware: Set the correct options on the django_language cookie.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-09 14:24:22 -08:00
Lauryn Menard
53df35e698 tools: Remove obsolete _set_error_state method in linter spider.
In 2f547ea, the custom `has_error` logic in BaseDocumentationSpider
was removed in favor of checking whether any errors were logged.

One reference to that method was missed in UnusedImagesLinterSpider
and went unremarked as no images were added to the documentation
that were not used.

Replaces that reference with an error log.
2022-11-09 11:54:19 -08:00
David Rosa
233e690fb4 tools: Upgrade scrapy's settings.py to the latest version.
Fixes a warning caused by using the deprecated `2.6` value
of the `REQUEST_FINGERPRINTER_IMPLEMENTATION` setting.

Upgrades `settings.py` to what would have been generated
by starting the documentation_crawler project using the
`startproject` command of scrapy v2.7.
2022-11-09 11:40:07 -08:00
Alex Vandiver
0fa7b8e1ae api: Link to new rate-limiting configuration documentation. 2022-11-09 09:56:16 -08:00
David Rosa
a9f2ec27d6 help center: Document notification triggers.
Documents the top checkboxes section for controlling mobile, desktop,
and email notifications.

Fixes #23371.
2022-11-08 17:45:04 -08:00
Alya Abbott
9937b8112d help center: Update documentation on reading private messages.
- Describe the new PMs section in the left sidebar.
- Mention Recent conversations.

Fixes #23420.
2022-11-08 17:44:46 -08:00
Eric Smith
c7ce20283b docs: Update to match current admin.js
Made some small changes to documentation to match the code in the
current admin.js

Fixes: There was no related issue for this fix.
2022-11-08 17:41:14 -08:00
Aman Agrawal
d15b29f056 list_widget: Add functions to add and remove a rendered item in the list.
This a refactoring commit as a followup from #23385.
2022-11-08 13:27:48 -08:00
Aman Agrawal
8e9ae426c0 recent_topics_ui: Add a comment regarding finding if the topic is rendered. 2022-11-08 13:27:48 -08:00
Alex Vandiver
03f0cb07ff puppet: Upgrade puppetlabs libraries. 2022-11-08 13:26:32 -08:00
Alex Vandiver
6f46faa980 bootstrap-awscli: Upgrade awscli version. 2022-11-08 13:26:32 -08:00
Alex Vandiver
6517e4b239 puppet: Update third-party package versions. 2022-11-08 13:26:32 -08:00
Aman Agrawal
542aea4b1c left_sidebar: Remove chevron-left from back to streams.
This will help us make `Back to streams` look better with PMs header.
2022-11-08 13:25:42 -08:00
Aman Agrawal
46967002dd left_sidebar: Show PM section in topics zoomed view.
This is important to preserve the invariant that the unread count for
private messages is always visible.

Fixes #23391.
2022-11-08 13:25:09 -08:00
Aman Agrawal
1b304c5296 left_sidebar: Match color of show-all-streams to other headers.
Specifically trying to match the color to PMs header.
2022-11-08 13:24:11 -08:00
Aman Agrawal
fc7ec5d8f9 left_sidebar: Left align show all streams with other buttons.
This includes a slight color change to `show-all-streams` to
match with the other headers.
2022-11-08 13:24:11 -08:00
Aman Agrawal
1192488240 left_sidebar: Left align all the section headers with the icons. 2022-11-08 13:24:11 -08:00
Aman Agrawal
41a60f84b9 left_sidebar: Correctly align user status icon.
Align the user status icons with the other icons in the left
sidebar so that their center falls in the same vertical line.
2022-11-08 13:24:11 -08:00
PALASH BADERIA
343e15a23d settings: Link to relevant help center articles in notification settings.
This provides a hook for users to get to these /help/ pages, which contain
details on exactly how these notifications/settings work, as well as
troubleshooting advice.

Fixes: #23369.
2022-11-08 11:12:19 -08:00
Lauryn Menard
62c9bb728e tests: Remove ignored field_type param in custom profile data test.
For PATCH requests to `/realm/profile_fields`, the field_type is
determined via the field.id, which is in the URL. Therefore,
`field_type` does not need to be passed as part of the request
data in tests.
2022-11-08 11:08:14 -08:00
Lauryn Menard
aac76bb185 narrow-banner: Update empty title for "pm-with" multiple users.
Instead of using "these people", we use "these users".

Note that the "pm-with" single user case has already been updated
to show the user's full name instead of "this person".
2022-11-08 11:07:38 -08:00
Lauryn Menard
c4d407e992 api-docs: Update 'construct-narrow' article.
Fixes small error in the example at the top of the article, and
adds a short statement about narrows searching the current user's
personal message history with a link to the help center article.

Gives the final section a subheader and adds the two other narrow
operators that take an ID.
2022-11-08 11:07:00 -08:00
David Rosa
81f3307da0 help center: Mention stream section labels.
Updates the relevant help center articles to reflect that the
sections for Pinned and Inactive streams in the left sidebar
now have labels.

Fixes #23423.
2022-11-08 10:44:57 -08:00
David Rosa
2eaff50a59 help center: Document viewing read receipts on mobile.
Adds instructions for viewing read receipts in the mobile app.

Fixes #23479.
2022-11-08 10:43:50 -08:00
Mateusz Mandera
34a0139c2b rate_limit: Add interface to override rate limiting rules. 2022-11-08 08:56:42 -08:00
Sahil Batra
7c4da60b53 message: Don't create historical UserMessage rows when marking as read.
We do not create historical UserMessage rows, for messages that didn't
have one, while marking messages as read and simply ignore those messages.
We do so because there is no user of creating UserMessage rows and it just
wastes storage.

Note that we still allow to mark messages from unsubscribed streams as
read but only those which have UserMessage rows for them to handle the
case when the unread messages were not marked as read while unsubscribing
from the stream due to some race condition. In such cases, messages
will not be included in the unread count shown in "All messages" menu
(and stream is anyways not present in the left sidebar), but the message
border on the left is green if viewing the stream after unsusbcribing it.
So, to avoid the confusion for users, the messages will be marked as read
when user scrolls down.
2022-11-08 08:50:17 -08:00
Zixuan James Li
390e2a12e5 webhooks: Use get_short_sha to get shortened sha.
This unifies the length of the shortened SHA our integrations generate,
and ensures that they are long enough for projects of various sizes with
a chosen value defined in get_short_sha.

Fixes #23475

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-11-08 08:20:51 -08:00
Zixuan James Li
4e46899494 webhooks: Pick a more reasonable length for short sha.
7 characters are not enough for large projects, so we change
it to reasonably longer. As an example, The Linux kernel needs
at least 11 characters of sha in its shortened form to identify
a revision. We pick 11 so it should work for most of the projects.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-11-08 08:20:51 -08:00
Lauryn Menard
2a1ceb58d9 api-docs: Return 404 for direct /api-doc-template call.
We use `templates/zerver/api/api-doc-template.md` as a base template
for the documented API endpoints in `zerver/openapi/zulip.yaml`.

Previously, if this template was called as an endpoint, then it
would fail an assertion check and send server error. Now we check
for specifically for that potential path and return a 404 error
response for no existing article.

Fixes #21876.
2022-11-08 08:10:15 -08:00
Alya Abbott
04dcca370b help center: Drop extraneous Desktop/Web tab from /help/emoji-reactions.
It is better not to use a tab in the instructions for how to
"Toggle whether names of reacting users are displayed", as this setting
applies to both web/desktop and mobile apps.

The instructions themselves still indicate that the setting is controlled
via the web/desktop app.
2022-11-08 08:09:04 -08:00
Anders Kaseorg
fc9f23a85f scripts: Pass --retry 3 to curl.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-08 08:07:36 -08:00
Anders Kaseorg
c2cbc57bc4 ruff: Specify all selected errors.
extend-select may be removed upstream.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-07 22:17:40 -08:00
Anders Kaseorg
66393640a8 ruff: Configure target-version.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-07 22:17:40 -08:00
Matt Keller
8aa7ff4bbb slack: Parse emoji skin tone variants.
Fixes part of #23276.
2022-11-07 14:25:49 -08:00
Lauryn Menard
2dd3f29c32 api-docs: Update example response header for potential plural.
The documentation for various API endpoints gives multiple response
examples. Update the headers to reflect this fact.
2022-11-07 12:31:55 -08:00
Lauryn Menard
fbe2ef9431 api-docs: Remove unused description in get-subscription-status. 2022-11-07 12:31:55 -08:00
Lauryn Menard
566a6823af api-docs: Use default example response description for get-messages. 2022-11-07 12:31:55 -08:00
Lauryn Menard
6f44681354 api-docs: Use default response example description for create-drafts. 2022-11-07 12:31:55 -08:00
Alya Abbott
9ce484e267 portico: Add a page about our values. 2022-11-07 12:27:09 -08:00
Alya Abbott
1ef94cc2b4 portico: Update /history page. 2022-11-07 12:27:09 -08:00
Lauryn Menard
19a4c3907f decorator: Put back check for dev env in ignore_unhashable_lru_cache.
Prior to 53231aa, the `ignore_unhashable_lru_cache` decorator had
a check for the development environment so that changes could be
seen on refresh.

Puts that check back in IgnoreUnhashableLruCacheWrapper class.
2022-11-07 12:17:59 -08:00
Lauryn Menard
66e607cf4c tests: Remove ignored message_id parameter in message edit tests.
For PATCH requests to edit messages, the message ID is in the URL
and does not need to be passed as part of the data in tests.
2022-11-07 12:16:28 -08:00
Javier González
63355c2a34 popovers: Add bottom margin to input.
Fixes: #23114
2022-11-07 11:31:37 -08:00
David Rosa
69bf8193a0 help center: Mention "Scroll to bottom" to mark Topics and PMs as read.
Updates "Reading Topics" and "Reading PMs" where only the keyboard
shortcut for this action is mentioned.

Fixes #23425.
2022-11-07 10:49:55 -08:00
Tim Abbott
b3e1f546f3 Revert "help-docs: Revise the article on searching for messages."
This reverts commit 8410990c42.

We'd like to rework this article more substantially.
2022-11-07 10:40:28 -08:00
m-e-l-u-h-a-n
06f0634ca5 css: Fix height issue for stream and user group creation forms.
Due to incorrect heights set for user-group creation and stream
creation body we had a UI bug because of which bottom part of
user group and stream creation forms were slightly visible
through the bottom.

It was due to somewhat fussy css height rules and incorrect
height calculations for that UI.
2022-11-06 22:02:41 -08:00
Aman Agrawal
244be5b71b resize: Increase minimum height for left sidebar blocks.
This function is only called to calculate the size of stream and
user list. Using 250px as minimum height for these blocks gives
them enough space to be usable regardless of their height ratio.
2022-11-05 15:15:44 -07:00
Aman Agrawal
b6a9819395 resize: Update buddy list height when resizing streams list.
If the buddy list is displayed in the left sidebar, height of
both these blocks needs to be changed to accommodate for the
changes.

The fixes the bug that stream list and user list don't fill
left sidebar and have 80px height regardless of viewport height.
2022-11-05 15:15:42 -07:00
Aman Agrawal
b8f7293dba resize: Use scroll element get the scroll height for streams.
Since streams and PMS now use left_sidebar_scroll_container
for scrolling, use it get the correct scroll height.
2022-11-05 15:15:25 -07:00
Anders Kaseorg
55342efd33 scim: Upgrade django-scim2; remove request.user monkey patching.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-05 15:13:50 -07:00
Anders Kaseorg
7e8ebd18b6 test_scim: Add test for missing or wrong authentication.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-05 15:13:46 -07:00
Lauryn Menard
cba8738eea search: Check if user can access stream topics before fetching history.
When building search suggestions for stream topics, instead of
assuming that the user has access to the stream's topic history
from the server, we check whether the user has access to the
stream's topics.
2022-11-05 15:09:49 -07:00
Eric Smith
c4823bfd03 docs: Remove unnecessary type annotations from tutorial.
In 4c3c976174, we removed the need
to explicitly declare types for Django model fields. Here, we update that detail 
in our documentation.
2022-11-04 15:31:42 -07:00
Tim Abbott
426c806a87 docs: Document docker-zulip postgres upgrade requirement.
Since this is a hard requirement for upgrading the Docker image, it's
worth highlighting here.
2022-11-04 15:19:57 -07:00
Alex Vandiver
d8ebbedbbb outgoing_webhook: Ignore the exception on failure if the stream is gone.
In the outgoing webhook handler, there is potentially several seconds
of trying between when a message triggering an outgoing webhook
arrives, and when it fails.  In the meantime, the stream the
triggering message was on may have been deleted, causing the
"Failure!" message to have no valid stream to be sent to.

Rather than raise an exception in the outgoing webhook worker, ignore
the exception and move on.
2022-11-04 14:46:17 -07:00
Alex Vandiver
eb7a2f2c38 queue: Do test retries in tests.
The lambda passed to `queue_json_publish` is used if
`settings.USING_RABBITMQ` is unset -- which is only true in tests.  As
such, this pattern causes failures to never actually retry within
tests.

This behaviour has existed ever since the outgoing webhook code was
introduced in 53a8b2ac87, with no explanation.  Not passing that
argument allows tests to verify the retry behaviour when webhooks
fail.
2022-11-04 14:46:17 -07:00
Zixuan James Li
7dbd98d25c rest: Restrict access to json views via basic auth.
Previously, test cases or clients accessing /json/ views using HTTP
Basic Auth would be accepted, while we intended to only allow clients
authenticated with a session cookie to access these views.

This adds a check on the accessed path to avoid this possibility.

It seems unlikely that any API clients clients were taking advantage
of this unintended quirk; so we're not going to bother documenting
this bug fix as an API change. In any case, it should be trivial for
anyone affected to consult the documentation and then switch their
/json/foo URL to a correct /api/v1/foo URL.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-11-04 14:44:07 -07:00
Anders Kaseorg
51d1ccb064 build_emoji: Guard mutable default with read-only type.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-04 14:42:33 -07:00
Alya Abbott
4316f47f8d help center: Update list of fields in full profile.
Also add documentation on what fields are shown in the mobile app.
2022-11-04 14:41:09 -07:00
Lauryn Menard
f17030a802 compose-validate: Use settings config value for policy check.
Updates the check in compose validate for the organization's
policy on sending private messages to use the code/value in
settings_config, instead of the number value.
2022-11-04 14:37:45 -07:00
Lauryn Menard
6b4ab21562 narrow-banner: Exclude bots when checking org sending pms policy.
Private messages between a user and a bot are not restricted by
the organization's policy setting for sending private messages.
So, for the empty banner text, we set the default title for
a single bot for the "pm-with" narrow.

Group private messages that include a bot are restricted by
this policy setting, so those messages stay the same.

Also, since bot's aren't people, we update the text for valid
"pm-with", "sender" and "group-pm-with" operands to include the
user's full name in the title.

When there are multiple people in the "pm-with" narrow, we still
send a generic "these people" message instead of listing all the
users in the narrow.

Finally, we make the default message end in a period instead of
an exclamation mark.
2022-11-04 14:37:45 -07:00
Lauryn Menard
f06143bc7c narrow-banner: Check private message policy for empty narrow title.
For narrows that focus on private messages ("is:private", "pm-with",
"group-pm-with"), we want to check the organization private message
policy and set an empty narrow title that matches that policy.

For these narrows with invalid users, we prioritize that message
for the empty narrow title, instead of the private message policy
message.

Fixes #21889.
2022-11-04 14:37:45 -07:00
Sahil Batra
1fce1c3c73 register: Handle "Pronouns" type fields for older mobile clients.
Mobile clients older than v27.192 do not support PRONOUNS type
custom profile fields, so we instead change the type of it to
SHORT_TEXT in the data sent with register response and also in
the events sent to those clients.
2022-11-04 14:31:18 -07:00
Sahil Batra
b2737b0878 migrations: Add migration to migrate pronouns custom profile fields.
This commit adds a migration to migrate SHORT_TEXT type profile
fields for pronouns to recently added PRONOUNS type.
2022-11-04 14:31:18 -07:00
Julia Bichler
16bed8ef42 stream settings: Hide email portion if unsubscribed.
This hides the stream email portion in the general settings
if the user is not subscribed to the stream.

Fixes part of #19519.
2022-11-04 14:22:27 -07:00
Julia Bichler
74f2d8ca7f stream settings: Allow modifying of email address.
This allows the user to modify the stream email address
by adding or removing tags before copying.

Fixes part of #19519.
2022-11-04 14:22:27 -07:00
Julia Bichler
6e163bb042 stream settings: Add copy email address modal.
This moves the stream email address to a modal
and adds a copy button.

Fixes part of #19519.
2022-11-04 14:22:27 -07:00
Lauryn Menard
54ad2f5266 compose-actions: Stop compose box load for invalid users with any trigger.
A user could trigger a "pm-with" narrow with an invalid user by moving
back/forward in the session, which would trigger the compose box to
open via a hash change. Updates the check to pass in any "pm-with"
narrow with an invalid user.

Also, if the compose box was active/started in the previous view, but
without any content, then we want to actively cancel/close it in the
invalid user "pm-with" narrow.
2022-11-04 14:08:25 -07:00
Lauryn Menard
09c4e2f662 compose-actions: Load compose box for PMs based on org policy.
If an organization has disabled sending private messages, we do not
want to load the compose box automatically for "pm-with" narrows.

We still open the compose box for private messages narrows with a
single bot user as this is not limited by this organization setting.

Also, if the compose box was active/started in a narrow with a bot
user, but had no content, then we want to close/cancel that in a
new narrow with a person or group.
2022-11-04 14:08:25 -07:00
Aman Agrawal
836db701aa recent: Fix cursor position after muting a topic above a PM row.
Fixes #23332

Check if col we are trying to focus exists for the row inside
`set_table_focus`.

We call `revive_current_focus` after `topics_widget` is defined
since it can be used inside it.
2022-11-04 13:59:22 -07:00
Aman Agrawal
4bd46f1cb4 recent: Simplify down arrow navigation.
Fixes #23331

Combine checks for last row between `vim_dowm` and `down_arrow`.

Check for the presence of unread counter in `set_table_focus`
directly so that it can be used in other cases as well. This is
especially useful when marking the last row in the table as read.
2022-11-04 13:59:22 -07:00
Aman Agrawal
c41c94e36e recent_topics: Improve behaviour of inplace rerender.
We used to hide and show topic rows in the DOM when topics are
updated. This resulted in incorrect calculations in the length of
visible topics. As a consequence, focus is sometimes set to hidden topic.
Removing hidden topics from DOM helps us keep
the calculations correct.

The fixes bugs related to focus being lost when trying to mute
or mark as read the last row.
2022-11-04 13:59:20 -07:00
Aman Agrawal
ef067eafad topic_list: Move topic filter out of topics list ul.
Instead of topic filter box being a part of the list when keeps
updating, we move it out and fix its position.

This should reduce rendering time of topics list and provide
a smoother experience to users when waiting for topics list to
load.
2022-11-04 13:40:46 -07:00
Anders Kaseorg
d717b38704 dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 14:48:40 -07:00
Anders Kaseorg
3a718d786f js: Fix type issue with FormatJS rich text elements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 14:48:40 -07:00
Anders Kaseorg
b582d5886c stylelint: Fix import-notation.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 14:48:40 -07:00
Anders Kaseorg
b9dfa23666 requirements: Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 14:08:58 -07:00
Anders Kaseorg
c6f6df986c openapi: Fix “contatining” typo.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 14:08:58 -07:00
Lauryn Menard
8410990c42 help-docs: Revise the article on searching for messages.
Updates the first part of the article to discuss the basics of
the search feature. Adds sub-headers / sections to the list of
search operators. Makes the exluding messages a section header
instead of a sub-section of the list.
2022-11-03 12:17:37 -07:00
Lauryn Menard
6f1d9ce466 help-docs: Fix "group-pm-with" format in search for messages article.
Updates the help center article on searching for messages to have
the correct format for the "group-pm-with" operator.

Also, reorders the list so that the private message searches are
all together, and the `streams:public` operator is last so that
it stands out a bit more.
2022-11-03 12:17:37 -07:00
M@
47ecd33d3a import: Narrow the id-window to just the current realm.
On multi-realm systems this results in traversal of all messages in
all realms and returns a massive payload of 1 row per stream on 
the server, not the intended one row per realm.
2022-11-03 12:13:43 -07:00
Anders Kaseorg
7021852627 install-node: Silence expected “node: command not found” on first run.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 12:11:08 -07:00
Anders Kaseorg
d494181127 ruff: Enable more errors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 12:10:15 -07:00
Anders Kaseorg
3d853caf16 ruff: Fix C417 Unnecessary map usage.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 12:10:15 -07:00
Anders Kaseorg
ab864be904 ruff: Fix C416 Unnecessary set comprehension (rewrite using set()).
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 12:10:15 -07:00
Anders Kaseorg
77c15547e6 ruff: Fix C414 Unnecessary list call within sorted().
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 12:10:15 -07:00
Anders Kaseorg
69e94b5991 ruff: Fix C413 Unnecessary list call around sorted().
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 12:10:15 -07:00
Anders Kaseorg
9e53f0c756 ruff: Fix C405 Unnecessary list literal (rewrite as a set literal).
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 12:10:15 -07:00
Anders Kaseorg
033d2615f6 ruff: Fix B017 assertRaises(Exception): should be considered evil.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 12:10:15 -07:00
Anders Kaseorg
e1a2894af9 ruff: Fix B011 Do not assert False (python -O removes these calls).
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 12:10:15 -07:00
Anders Kaseorg
9d2d6c8eb7 ruff: Fix M001 Unused noqa directive.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 12:10:15 -07:00
Anders Kaseorg
adffad384c lint: Replace pycodestyle and pyflakes with ruff.
https://github.com/charliermarsh/ruff

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-03 12:10:15 -07:00
Mateusz Mandera
05913f5e3a saml: Extract logic for enabling wantMessagesSigned locally.
As explained in 158287f998,
wantMessagesSigned can't be enabled globally (as it'll break setups with
IdPs that sign SAMLResponse assertions) - but is needed for
LogoutRequests, and will be for LogoutResponses in the SP-initiated SLO
flow in future commits.

We extract a function with the necessary hacky logic for re-use in the
SP-initiated SLO implementation.
2022-11-02 21:58:46 -07:00
1264 changed files with 33515 additions and 22316 deletions

View File

@@ -21,3 +21,7 @@ vise
falsy
ro
derails
forin
uper
slac
couldn

View File

@@ -47,6 +47,7 @@ jobs:
# the top explain how to build and upload these images.
# Ubuntu 20.04 ships with Python 3.8.10.
container: zulip/ci:focal
steps:
- name: Add required permissions
run: |
@@ -103,11 +104,22 @@ jobs:
path: /tmp/production-build
retention-days: 14
- name: Report status
if: failure()
env:
ZULIP_BOT_KEY: ${{ secrets.ZULIP_BOT_KEY }}
run: tools/ci/send-failure-message
- name: Generate failure report string
id: failure_report_string
if: ${{ failure() && github.repository == 'zulip/zulip' && github.event_name == 'push' }}
run: tools/ci/generate-failure-message >> $GITHUB_OUTPUT
- name: Report status to CZO
if: ${{ failure() && github.repository == 'zulip/zulip' && github.event_name == 'push' }}
uses: zulip/github-actions-zulip/send-message@v1
with:
api-key: ${{ secrets.ZULIP_BOT_KEY }}
email: "github-actions-bot@chat.zulip.org"
organization-url: "https://chat.zulip.org"
to: "automated testing"
topic: ${{ steps.failure_report_string.outputs.topic }}
type: "stream"
content: ${{ steps.failure_report_string.outputs.content }}
production_install:
# This job installs the server release tarball built above on a
@@ -160,7 +172,7 @@ jobs:
chmod +x /tmp/production-pgroonga
chmod +x /tmp/production-install
chmod +x /tmp/production-verify
chmod +x /tmp/send-failure-message
chmod +x /tmp/generate-failure-message
- name: Create cache directories
run: |
@@ -197,11 +209,22 @@ jobs:
if: ${{ matrix.os == 'focal' }}
run: sudo /tmp/production-verify ${{ matrix.extra-args }}
- name: Report status
if: failure()
env:
ZULIP_BOT_KEY: ${{ secrets.ZULIP_BOT_KEY }}
run: /tmp/send-failure-message
- name: Generate failure report string
id: failure_report_string
if: ${{ failure() && github.repository == 'zulip/zulip' && github.event_name == 'push' }}
run: tools/ci/generate-failure-message >> $GITHUB_OUTPUT
- name: Report status to CZO
if: ${{ failure() && github.repository == 'zulip/zulip' && github.event_name == 'push' }}
uses: zulip/github-actions-zulip/send-message@v1
with:
api-key: ${{ secrets.ZULIP_BOT_KEY }}
email: "github-actions-bot@chat.zulip.org"
organization-url: "https://chat.zulip.org"
to: "automated testing"
topic: ${{ steps.failure_report_string.outputs.topic }}
type: "stream"
content: ${{ steps.failure_report_string.outputs.content }}
production_upgrade:
# The production upgrade job starts with a container with a
@@ -225,6 +248,9 @@ jobs:
- docker_image: zulip/ci:bullseye-5.0
name: 5.0 Version Upgrade
os: bullseye
- docker_image: zulip/ci:bullseye-6.0
name: 6.0 Version Upgrade
os: bullseye
name: ${{ matrix.name }}
container:
@@ -251,7 +277,7 @@ jobs:
# of the tarball uploaded by the upload artifact fix those.
chmod +x /tmp/production-upgrade
chmod +x /tmp/production-verify
chmod +x /tmp/send-failure-message
chmod +x /tmp/generate-failure-message
- name: Create cache directories
run: |
@@ -268,8 +294,19 @@ jobs:
# - name: Verify install
# run: sudo /tmp/production-verify
- name: Report status
if: failure()
env:
ZULIP_BOT_KEY: ${{ secrets.ZULIP_BOT_KEY }}
run: /tmp/send-failure-message
- name: Generate failure report string
id: failure_report_string
if: ${{ failure() && github.repository == 'zulip/zulip' && github.event_name == 'push' }}
run: tools/ci/generate-failure-message >> $GITHUB_OUTPUT
- name: Report status to CZO
if: ${{ failure() && github.repository == 'zulip/zulip' && github.event_name == 'push' }}
uses: zulip/github-actions-zulip/send-message@v1
with:
api-key: ${{ secrets.ZULIP_BOT_KEY }}
email: "github-actions-bot@chat.zulip.org"
organization-url: "https://chat.zulip.org"
to: "automated testing"
topic: ${{ steps.failure_report_string.outputs.topic }}
type: "stream"
content: ${{ steps.failure_report_string.outputs.content }}

View File

@@ -22,6 +22,6 @@ jobs:
run: |
export PATH="$HOME/.local/bin:$PATH"
git clone https://github.com/zulip/marketplace-partners
pip3 install python-digitalocean zulip fab-classic
pip3 install python-digitalocean zulip fab-classic PyNaCl
echo $PATH
python3 tools/oneclickapps/prepare_digital_ocean_one_click_app_release.py

View File

@@ -233,8 +233,19 @@ jobs:
- name: Check development database build
run: ./tools/ci/setup-backend
- name: Report status
if: failure()
env:
ZULIP_BOT_KEY: ${{ secrets.ZULIP_BOT_KEY }}
run: tools/ci/send-failure-message
- name: Generate failure report string
id: failure_report_string
if: ${{ failure() && github.repository == 'zulip/zulip' && github.event_name == 'push' }}
run: tools/ci/generate-failure-message >> $GITHUB_OUTPUT
- name: Report status to CZO
if: ${{ failure() && github.repository == 'zulip/zulip' && github.event_name == 'push' }}
uses: zulip/github-actions-zulip/send-message@v1
with:
api-key: ${{ secrets.ZULIP_BOT_KEY }}
email: "github-actions-bot@chat.zulip.org"
organization-url: "https://chat.zulip.org"
to: "automated testing"
topic: ${{ steps.failure_report_string.outputs.topic }}
type: "stream"
content: ${{ steps.failure_report_string.outputs.content }}

1
.gitignore vendored
View File

@@ -33,6 +33,7 @@ package-lock.json
!/var/puppeteer/test_credentials.d.ts
/.dmypy.json
/.ruff_cache
# Generated i18n data
/locale/en

View File

@@ -24,6 +24,7 @@ Anders Kaseorg <anders@zulip.com> <anders@zulipchat.com>
Anders Kaseorg <anders@zulip.com> <andersk@mit.edu>
Aryan Shridhar <aryanshridhar7@gmail.com> <53977614+aryanshridhar@users.noreply.github.com>
Aryan Shridhar <aryanshridhar7@gmail.com>
aparna-bhatt <aparnabhatt2001@gmail.com> <86338542+aparna-bhatt@users.noreply.github.com>
Ashwat Kumar Singh <ashwat.kumarsingh.met20@itbhu.ac.in>
Austin Riba <austin@zulip.com> <austin@m51.io>
BIKI DAS <bikid475@gmail.com>
@@ -33,6 +34,8 @@ Brock Whittaker <brock@zulipchat.com> <brock@zulipchat.org>
Chris Bobbe <cbobbe@zulip.com> <cbobbe@zulipchat.com>
Chris Bobbe <cbobbe@zulip.com> <csbobbe@gmail.com>
Eeshan Garg <eeshan@zulip.com> <jerryguitarist@gmail.com>
Eric Smith <erwsmith@gmail.com> <99841919+erwsmith@users.noreply.github.com>
Ganesh Pawar <pawarg256@gmail.com> <58626718+ganpa3@users.noreply.github.com>
Greg Price <greg@zulip.com> <gnprice@gmail.com>
Greg Price <greg@zulip.com> <greg@zulipchat.com>
Greg Price <greg@zulip.com> <price@mit.edu>
@@ -47,21 +50,30 @@ Kevin Mehall <km@kevinmehall.net> <kevin@humbughq.com>
Kevin Mehall <km@kevinmehall.net> <kevin@zulip.com>
Kevin Scott <kevin.scott.98@gmail.com>
Lauryn Menard <lauryn@zulip.com> <lauryn.menard@gmail.com>
Lauryn Menard <lauryn@zulip.com> <63245456+laurynmm@users.noreply.github.com>
Mateusz Mandera <mateusz.mandera@zulip.com> <mateusz.mandera@protonmail.com>
Matt Keller <matt@zulip.com>
Matt Keller <matt@zulip.com> <m@cognusion.com>
m-e-l-u-h-a-n <purushottam.tiwari.cd.cse19@itbhu.ac.in>
Noble Mittal <noblemittal@outlook.com> <62551163+beingnoble03@users.noreply.github.com>
Palash Raghuwanshi <singhpalash0@gmail.com>
Parth <mittalparth22@gmail.com>
Priyam Seth <sethpriyam1@gmail.com> <b19188@students.iitmandi.ac.in>
Ray Kraesig <rkraesig@zulip.com> <rkraesig@zulipchat.com>
Reid Barton <rwbarton@gmail.com> <rwbarton@humbughq.com>
Rein Zustand (rht) <rhtbot@protonmail.com>
Rishi Gupta <rishig@zulipchat.com> <rishig+git@mit.edu>
Rishi Gupta <rishig@zulipchat.com> <rishig@kandralabs.com>
Rishi Gupta <rishig@zulipchat.com> <rishig@users.noreply.github.com>
Rishabh Maheshwari <b20063@students.iitmandi.ac.in>
Rixant Rokaha <rixantrokaha@gmail.com>
Rixant Rokaha <rixantrokaha@gmail.com> <rishantrokaha@gmail.com>
Rixant Rokaha <rixantrokaha@gmail.com> <rrokaha@caldwell.edu>
Sayam Samal <samal.sayam@gmail.com>
Scott Feeney <scott@oceanbase.org> <scott@humbughq.com>
Scott Feeney <scott@oceanbase.org> <scott@zulip.com>
Shlok Patel <shlokcpatel2001@gmail.com>
Somesh Ranjan <somesh.ranjan.met20@itbhu.ac.in> <77766761+somesh202@users.noreply.github.com>
Steve Howell <showell@zulip.com> <showell30@yahoo.com>
Steve Howell <showell@zulip.com> <showell@yahoo.com>
Steve Howell <showell@zulip.com> <showell@zulipchat.com>
@@ -79,5 +91,12 @@ Sahil Batra <sahil@zulip.com> <sahilbatra839@gmail.com>
Yash RE <33805964+YashRE42@users.noreply.github.com> <YashRE42@github.com>
Yash RE <33805964+YashRE42@users.noreply.github.com>
Yogesh Sirsat <yogeshsirsat56@gmail.com>
Yogesh Sirsat <yogeshsirsat56@gmail.com> <41695888+yogesh-sirsat@users.noreply.github.com>
Zeeshan Equbal <equbalzeeshan@gmail.com> <54993043+zee-bit@users.noreply.github.com>
Zeeshan Equbal <equbalzeeshan@gmail.com>
Zev Benjamin <zev@zulip.com> <zev@dropbox.com>
Zev Benjamin <zev@zulip.com> <zev@humbughq.com>
Zev Benjamin <zev@zulip.com> <zev@mit.edu>
Zixuan James Li <p359101898@gmail.com>
Zixuan James Li <p359101898@gmail.com> <39874143+PIG208@users.noreply.github.com>
Zixuan James Li <p359101898@gmail.com> <359101898@qq.com>

15
.readthedocs.yaml Normal file
View File

@@ -0,0 +1,15 @@
# https://docs.readthedocs.io/en/stable/config-file/v2.html
version: 2
build:
os: ubuntu-22.04
tools:
python: "3.10"
sphinx:
configuration: docs/conf.py
fail_on_warning: true
python:
install:
- requirements: requirements/docs.txt

View File

@@ -1,32 +1,39 @@
# Migrated from transifex-client format with `tx migrate`
#
# See https://developers.transifex.com/docs/using-the-client which hints at
# this format, but in general, the headings are in the format of:
#
# [o:<org>:p:<project>:r:<resource>]
[main]
host = https://www.transifex.com
lang_map = zh-Hans: zh_Hans, zh-Hant: zh_Hant
[zulip.djangopo]
[o:zulip:p:zulip:r:djangopo]
file_filter = locale/<lang>/LC_MESSAGES/django.po
source_file = locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO
[zulip.translationsjson]
file_filter = locale/<lang>/translations.json
source_file = locale/en/translations.json
source_lang = en
type = KEYVALUEJSON
[zulip.mobile]
[o:zulip:p:zulip:r:mobile]
file_filter = locale/<lang>/mobile.json
source_file = locale/en/mobile.json
source_lang = en
type = KEYVALUEJSON
[zulip-test.djangopo]
[o:zulip:p:zulip:r:translationsjson]
file_filter = locale/<lang>/translations.json
source_file = locale/en/translations.json
source_lang = en
type = KEYVALUEJSON
[o:zulip:p:zulip-test:r:djangopo]
file_filter = locale/<lang>/LC_MESSAGES/django.po
source_file = locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO
[zulip-test.translationsjson]
[o:zulip:p:zulip-test:r:translationsjson]
file_filter = locale/<lang>/translations.json
source_file = locale/en/translations.json
source_lang = en

View File

@@ -288,6 +288,7 @@ def do_aggregate_to_summary_table(
## Utility functions called from outside counts.py ##
# called from zerver.actions; should not throw any errors
def do_increment_logging_stat(
zerver_object: Union[Realm, UserProfile, Stream],

View File

@@ -8,7 +8,7 @@ from django.utils.timezone import now as timezone_now
from analytics.lib.counts import COUNT_STATS, CountStat
from analytics.models import installation_epoch
from zerver.lib.timestamp import TimeZoneNotUTCException, floor_to_day, floor_to_hour, verify_UTC
from zerver.lib.timestamp import TimeZoneNotUTCError, floor_to_day, floor_to_hour, verify_UTC
from zerver.models import Realm
states = {
@@ -48,7 +48,7 @@ class Command(BaseCommand):
last_fill = installation_epoch()
try:
verify_UTC(last_fill)
except TimeZoneNotUTCException:
except TimeZoneNotUTCError:
return {"status": 2, "message": f"FillState not in UTC for {property}"}
if stat.frequency == CountStat.DAY:

View File

@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("zerver", "0030_realm_org_type"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),

View File

@@ -2,7 +2,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("analytics", "0001_initial"),
]

View File

@@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("analytics", "0002_remove_huddlecount"),
]

View File

@@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("analytics", "0003_fillstate"),
]

View File

@@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("analytics", "0004_add_subgroup"),
]

View File

@@ -2,7 +2,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("analytics", "0005_alter_field_size"),
]

View File

@@ -3,7 +3,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("analytics", "0006_add_subgroup_to_unique_constraints"),
]

View File

@@ -3,7 +3,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("zerver", "0050_userprofile_avatar_version"),
("analytics", "0007_remove_interval"),

View File

@@ -1,5 +1,5 @@
from django.db import migrations
from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditor
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.migrations.state import StateApps
@@ -21,7 +21,6 @@ def delete_messages_sent_to_stream_stat(
class Migration(migrations.Migration):
dependencies = [
("analytics", "0008_add_count_indexes"),
]

View File

@@ -1,5 +1,5 @@
from django.db import migrations
from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditor
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.migrations.state import StateApps
@@ -21,7 +21,6 @@ def clear_message_sent_by_message_type_values(
class Migration(migrations.Migration):
dependencies = [("analytics", "0009_remove_messages_to_stream_stat")]
operations = [

View File

@@ -1,5 +1,5 @@
from django.db import migrations
from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditor
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.migrations.state import StateApps
@@ -18,7 +18,6 @@ def clear_analytics_tables(apps: StateApps, schema_editor: BaseDatabaseSchemaEdi
class Migration(migrations.Migration):
dependencies = [
("analytics", "0010_clear_messages_sent_values"),
]

View File

@@ -5,7 +5,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("analytics", "0011_clear_analytics_tables"),
]

View File

@@ -4,7 +4,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("analytics", "0012_add_on_delete"),
]

View File

@@ -4,7 +4,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("analytics", "0013_remove_anomaly"),
]

View File

@@ -1,5 +1,5 @@
from django.db import migrations
from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditor
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.migrations.state import StateApps
from django.db.models import Count, Sum
@@ -55,7 +55,6 @@ def clear_duplicate_counts(apps: StateApps, schema_editor: BaseDatabaseSchemaEdi
class Migration(migrations.Migration):
dependencies = [
("analytics", "0014_remove_fillstate_last_modified"),
]

View File

@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("analytics", "0015_clear_duplicate_counts"),
]

View File

@@ -53,7 +53,7 @@ from zerver.actions.users import do_deactivate_user
from zerver.lib.create_user import create_user
from zerver.lib.exceptions import InvitationError
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.timestamp import TimeZoneNotUTCException, floor_to_day
from zerver.lib.timestamp import TimeZoneNotUTCError, floor_to_day
from zerver.lib.topic import DB_TOPIC_NAME
from zerver.lib.utils import assert_is_not_none
from zerver.models import (
@@ -290,7 +290,7 @@ class TestProcessCountStat(AnalyticsTestCase):
stat = self.make_dummy_count_stat("test stat")
with self.assertRaises(ValueError):
process_count_stat(stat, installation_epoch() + 65 * self.MINUTE)
with self.assertRaises(TimeZoneNotUTCException):
with self.assertRaises(TimeZoneNotUTCError):
process_count_stat(stat, installation_epoch().replace(tzinfo=None))
# This tests the LoggingCountStat branch of the code in do_delete_counts_at_hour.

View File

@@ -8,7 +8,7 @@ from django.conf import settings
from django.db.backends.utils import CursorWrapper
from django.template import loader
from django.urls import reverse
from markupsafe import Markup as mark_safe
from markupsafe import Markup
from zerver.models import UserActivity
@@ -27,7 +27,6 @@ if settings.BILLING_ENABLED:
def make_table(
title: str, cols: Sequence[str], rows: Sequence[Any], has_row_class: bool = False
) -> str:
if not has_row_class:
def fix_row(row: Any) -> Dict[str, Any]:
@@ -58,36 +57,36 @@ def format_date_for_activity_reports(date: Optional[datetime]) -> str:
return ""
def user_activity_link(email: str, user_profile_id: int) -> mark_safe:
def user_activity_link(email: str, user_profile_id: int) -> Markup:
from analytics.views.user_activity import get_user_activity
url = reverse(get_user_activity, kwargs=dict(user_profile_id=user_profile_id))
email_link = f'<a href="{escape(url)}">{escape(email)}</a>'
return mark_safe(email_link)
return Markup(email_link)
def realm_activity_link(realm_str: str) -> mark_safe:
def realm_activity_link(realm_str: str) -> Markup:
from analytics.views.realm_activity import get_realm_activity
url = reverse(get_realm_activity, kwargs=dict(realm_str=realm_str))
realm_link = f'<a href="{escape(url)}">{escape(realm_str)}</a>'
return mark_safe(realm_link)
return Markup(realm_link)
def realm_stats_link(realm_str: str) -> mark_safe:
def realm_stats_link(realm_str: str) -> Markup:
from analytics.views.stats import stats_for_realm
url = reverse(stats_for_realm, kwargs=dict(realm_str=realm_str))
stats_link = f'<a href="{escape(url)}"><i class="fa fa-pie-chart"></i>{escape(realm_str)}</a>'
return mark_safe(stats_link)
return Markup(stats_link)
def remote_installation_stats_link(server_id: int, hostname: str) -> mark_safe:
def remote_installation_stats_link(server_id: int, hostname: str) -> Markup:
from analytics.views.stats import stats_for_remote_installation
url = reverse(stats_for_remote_installation, kwargs=dict(remote_server_id=server_id))
stats_link = f'<a href="{escape(url)}"><i class="fa fa-pie-chart"></i>{escape(hostname)}</a>'
return mark_safe(stats_link)
return Markup(stats_link)
def get_user_activity_summary(records: Collection[UserActivity]) -> Dict[str, Any]:

View File

@@ -10,7 +10,7 @@ from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
from django.template import loader
from django.utils.timezone import now as timezone_now
from markupsafe import Markup as mark_safe
from markupsafe import Markup
from psycopg2.sql import SQL, Composable, Literal
from analytics.lib.counts import COUNT_STATS
@@ -305,7 +305,7 @@ def realm_summary_table(realm_minutes: Dict[str, float]) -> str:
return content
def user_activity_intervals() -> Tuple[mark_safe, Dict[str, float]]:
def user_activity_intervals() -> Tuple[Markup, Dict[str, float]]:
day_end = timestamp_to_datetime(time.time())
day_start = day_end - timedelta(hours=24)
@@ -357,7 +357,7 @@ def user_activity_intervals() -> Tuple[mark_safe, Dict[str, float]]:
output += f"\nTotal duration: {total_duration}\n"
output += f"\nTotal duration in minutes: {total_duration.total_seconds() / 60.}\n"
output += f"Total duration amortized to a month: {total_duration.total_seconds() * 30. / 60.}"
content = mark_safe("<pre>" + output + "</pre>")
content = Markup("<pre>" + output + "</pre>")
return content, realm_minutes
@@ -372,7 +372,7 @@ def ad_hoc_queries() -> List[Dict[str, str]]:
cursor.close()
def fix_rows(
i: int, fixup_func: Union[Callable[[str], mark_safe], Callable[[datetime], str]]
i: int, fixup_func: Union[Callable[[str], Markup], Callable[[datetime], str]]
) -> None:
for row in rows:
row[i] = fixup_func(row[i])

View File

@@ -3,7 +3,7 @@ from datetime import datetime
from typing import Any, Dict, List, Optional, Set, Tuple
from django.db import connection
from django.db.models.query import QuerySet
from django.db.models import QuerySet
from django.http import HttpRequest, HttpResponse, HttpResponseNotFound
from django.shortcuts import render
from django.utils.timezone import now as timezone_now

View File

@@ -4,7 +4,7 @@ from datetime import datetime, timedelta, timezone
from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Union, cast
from django.conf import settings
from django.db.models.query import QuerySet
from django.db.models import QuerySet
from django.http import HttpRequest, HttpResponse, HttpResponseNotFound
from django.shortcuts import render
from django.utils import translation

View File

@@ -1,7 +1,7 @@
from typing import Any, Dict, List, Tuple
from django.conf import settings
from django.db.models.query import QuerySet
from django.db.models import QuerySet
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render

View File

@@ -14,7 +14,7 @@ module.exports = {
[
"@babel/preset-env",
{
corejs: "3.25",
corejs: "3.26",
shippedProposals: true,
useBuiltIns: "usage",
},

View File

@@ -3,7 +3,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("contenttypes", "0001_initial"),
]

View File

@@ -3,7 +3,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("confirmation", "0001_initial"),
]

View File

@@ -3,7 +3,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("confirmation", "0002_realmcreationkey"),
]

View File

@@ -3,7 +3,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("confirmation", "0003_emailchangeconfirmation"),
]

View File

@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("zerver", "0124_stream_enable_notifications"),
("confirmation", "0004_remove_confirmationmanager"),

View File

@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("confirmation", "0005_confirmation_realm"),
]

View File

@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("confirmation", "0006_realmcreationkey_presume_email_valid"),
]

View File

@@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("confirmation", "0007_add_indexes"),
]

View File

@@ -5,7 +5,7 @@ from datetime import timedelta
from django.conf import settings
from django.db import migrations, transaction
from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditor
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.migrations.state import StateApps

View File

@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("confirmation", "0009_confirmation_expiry_date_backfill"),
]

View File

@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("confirmation", "0010_alter_confirmation_expiry_date"),
]

View File

@@ -29,7 +29,7 @@ from zerver.models import (
)
class ConfirmationKeyException(Exception):
class ConfirmationKeyError(Exception):
WRONG_LENGTH = 1
EXPIRED = 2
DOES_NOT_EXIST = 3
@@ -40,11 +40,11 @@ class ConfirmationKeyException(Exception):
def render_confirmation_key_error(
request: HttpRequest, exception: ConfirmationKeyException
request: HttpRequest, exception: ConfirmationKeyError
) -> HttpResponse:
if exception.error_type == ConfirmationKeyException.WRONG_LENGTH:
if exception.error_type == ConfirmationKeyError.WRONG_LENGTH:
return render(request, "confirmation/link_malformed.html", status=404)
if exception.error_type == ConfirmationKeyException.EXPIRED:
if exception.error_type == ConfirmationKeyError.EXPIRED:
return render(request, "confirmation/link_expired.html", status=404)
return render(request, "confirmation/link_does_not_exist.html", status=404)
@@ -77,16 +77,16 @@ def get_object_from_key(
# Confirmation keys used to be 40 characters
if len(confirmation_key) not in (24, 40):
raise ConfirmationKeyException(ConfirmationKeyException.WRONG_LENGTH)
raise ConfirmationKeyError(ConfirmationKeyError.WRONG_LENGTH)
try:
confirmation = Confirmation.objects.get(
confirmation_key=confirmation_key, type__in=confirmation_types
)
except Confirmation.DoesNotExist:
raise ConfirmationKeyException(ConfirmationKeyException.DOES_NOT_EXIST)
raise ConfirmationKeyError(ConfirmationKeyError.DOES_NOT_EXIST)
if confirmation.expiry_date is not None and timezone_now() > confirmation.expiry_date:
raise ConfirmationKeyException(ConfirmationKeyException.EXPIRED)
raise ConfirmationKeyError(ConfirmationKeyError.EXPIRED)
obj = confirmation.content_object
assert obj is not None
@@ -96,10 +96,10 @@ def get_object_from_key(
if hasattr(obj, "status") and obj.status in [used_value, revoked_value]:
# Confirmations where the object has the status attribute are one-time use
# and are marked after being used (or revoked).
raise ConfirmationKeyException(ConfirmationKeyException.EXPIRED)
raise ConfirmationKeyError(ConfirmationKeyError.EXPIRED)
if mark_object_used:
# MultiuseInvite objects have no status field, since they are
# MultiuseInvite objects do not use the STATUS_USED status, since they are
# intended to be used more than once.
assert confirmation.type != Confirmation.MULTIUSE_INVITE
assert hasattr(obj, "status")
@@ -240,10 +240,10 @@ def validate_key(creation_key: Optional[str]) -> Optional["RealmCreationKey"]:
try:
key_record = RealmCreationKey.objects.get(creation_key=creation_key)
except RealmCreationKey.DoesNotExist:
raise RealmCreationKey.Invalid()
raise RealmCreationKey.InvalidError()
time_elapsed = timezone_now() - key_record.date_created
if time_elapsed.total_seconds() > settings.REALM_CREATION_LINK_VALIDITY_DAYS * 24 * 3600:
raise RealmCreationKey.Invalid()
raise RealmCreationKey.InvalidError()
return key_record
@@ -266,5 +266,5 @@ class RealmCreationKey(models.Model):
# is theirs, and skip sending mail to it to confirm that.
presume_email_valid = models.BooleanField(default=False)
class Invalid(Exception):
class InvalidError(Exception):
pass

View File

@@ -248,13 +248,13 @@ class UpgradeWithExistingPlanError(BillingError):
)
class InvalidBillingSchedule(Exception):
class InvalidBillingScheduleError(Exception):
def __init__(self, billing_schedule: int) -> None:
self.message = f"Unknown billing_schedule: {billing_schedule}"
super().__init__(self.message)
class InvalidTier(Exception):
class InvalidTierError(Exception):
def __init__(self, tier: int) -> None:
self.message = f"Unknown tier: {tier}"
super().__init__(self.message)
@@ -570,16 +570,16 @@ def get_price_per_license(
elif billing_schedule == CustomerPlan.MONTHLY:
price_per_license = 800
else: # nocoverage
raise InvalidBillingSchedule(billing_schedule)
raise InvalidBillingScheduleError(billing_schedule)
elif tier == CustomerPlan.PLUS:
if billing_schedule == CustomerPlan.ANNUAL:
price_per_license = 16000
elif billing_schedule == CustomerPlan.MONTHLY:
price_per_license = 1600
else: # nocoverage
raise InvalidBillingSchedule(billing_schedule)
raise InvalidBillingScheduleError(billing_schedule)
else:
raise InvalidTier(tier)
raise InvalidTierError(tier)
if discount is not None:
price_per_license = calculate_discounted_price_per_license(price_per_license, discount)
@@ -602,7 +602,7 @@ def compute_plan_parameters(
elif billing_schedule == CustomerPlan.MONTHLY:
period_end = add_months(billing_cycle_anchor, 1)
else: # nocoverage
raise InvalidBillingSchedule(billing_schedule)
raise InvalidBillingScheduleError(billing_schedule)
price_per_license = get_price_per_license(tier, billing_schedule, discount)

View File

@@ -5,7 +5,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [

View File

@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("corporate", "0001_initial"),
]

View File

@@ -5,7 +5,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("corporate", "0002_customer_default_discount"),
]

View File

@@ -5,7 +5,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("corporate", "0003_customerplan"),
]

View File

@@ -5,7 +5,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("corporate", "0004_licenseledger"),
]

View File

@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("corporate", "0005_customerplan_invoicing"),
]

View File

@@ -4,7 +4,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("corporate", "0006_nullable_stripe_customer_id"),
]

View File

@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("corporate", "0007_remove_deprecated_fields"),
]

View File

@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("corporate", "0008_nullable_next_invoice_date"),
]

View File

@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("corporate", "0009_customer_sponsorship_pending"),
]

View File

@@ -6,7 +6,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("zerver", "0333_alter_realm_org_type"),

View File

@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("corporate", "0012_zulipsponsorshiprequest"),
]

View File

@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("corporate", "0013_alter_zulipsponsorshiprequest_org_website"),
]

View File

@@ -5,7 +5,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("contenttypes", "0002_remove_content_type_name"),
("corporate", "0014_customerplan_end_date"),

View File

@@ -5,7 +5,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("zilencer", "0018_remoterealmauditlog"),
("zerver", "0370_realm_enable_spectator_access"),

Some files were not shown because too many files have changed in this diff Show More