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.
This commit is contained in:
Alex Vandiver
2022-12-16 09:17:00 -05:00
committed by Tim Abbott
parent 13ad9e8323
commit 7613928e8a
4 changed files with 48 additions and 25 deletions

View File

@@ -798,6 +798,14 @@ urls += [
path("policies/<slug:article>", policy_documentation_view),
]
if not settings.CORPORATE_ENABLED:
# This conditional behavior cannot be tested directly, since
# urls.py is not readily reloaded in Django tests. See the block
# comment inside apps_view for details.
urls += [
path("apps/", RedirectView.as_view(url="https://zulip.com/apps/", permanent=True)),
]
# Two-factor URLs
if settings.TWO_FACTOR_AUTHENTICATION_ENABLED:
urls += [path("", include(tf_urls)), path("", include(tf_twilio_urls))]