snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
This commit is contained in:
89
zerver/apps.py
Normal file
89
zerver/apps.py
Normal file
@@ -0,0 +1,89 @@
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import django_stubs_ext
|
||||
from django.apps import AppConfig
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
from django.core.checks import register
|
||||
from django.db import connection
|
||||
from django.db.models.signals import post_migrate, pre_migrate
|
||||
from typing_extensions import override
|
||||
|
||||
from zerver.checks import (
|
||||
check_auth_settings,
|
||||
check_external_host_setting,
|
||||
check_jitsi_server_url,
|
||||
check_required_settings,
|
||||
check_uploads_settings,
|
||||
)
|
||||
|
||||
|
||||
def flush_cache(sender: AppConfig | None, **kwargs: Any) -> None:
|
||||
logging.info("Clearing memcached cache after migrations")
|
||||
cache.clear()
|
||||
|
||||
|
||||
def create_zulip_schema(sender: AppConfig, **kwargs: Any) -> None: # nocoverage
|
||||
# We do this here, and not in a zerver migration, because we
|
||||
# cannot be sure that zerver migrations run _first_, of all of the
|
||||
# Django apps. Updating `SET search_path` is just for the current
|
||||
# connection; the user's default search_path is set in the
|
||||
# zerver/0001 migrations.
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute("CREATE SCHEMA IF NOT EXISTS zulip")
|
||||
cursor.execute("SET search_path = zulip,public")
|
||||
|
||||
|
||||
def skip_smokescreen_proxy_for_boto3() -> None:
|
||||
# https://github.com/boto/botocore/issues/2644: the request boto3
|
||||
# makes to fetch EC2 instance credentials from the IMDS endpoint
|
||||
# always reads the proxy configuration from the environment,
|
||||
# ignoring any per-client setting. Our application processes route
|
||||
# outgoing HTTP through Smokescreen, so that metadata request would
|
||||
# be proxied; and Smokescreen would refuse the internal
|
||||
# IMDS address (169.254.169.254). Disable proxying for boto3 so the
|
||||
# metadata request (and other boto3 traffic) goes direct.
|
||||
#
|
||||
# This must run at process startup so that it takes effect in every
|
||||
# process, including queue workers.
|
||||
import botocore.utils
|
||||
|
||||
botocore.utils.should_bypass_proxies = lambda url: True
|
||||
|
||||
|
||||
class ZerverConfig(AppConfig):
|
||||
name: str = "zerver"
|
||||
|
||||
@override
|
||||
def ready(self) -> None:
|
||||
register(check_required_settings)
|
||||
register(check_external_host_setting)
|
||||
register(check_auth_settings)
|
||||
register(check_uploads_settings)
|
||||
register(check_jitsi_server_url)
|
||||
|
||||
if settings.SENTRY_DSN: # nocoverage
|
||||
from zproject.config import get_config
|
||||
from zproject.sentry import setup_sentry
|
||||
|
||||
setup_sentry(settings.SENTRY_DSN, get_config("machine", "deploy_type", "development"))
|
||||
|
||||
from django.contrib.auth.forms import SetPasswordMixin
|
||||
|
||||
django_stubs_ext.monkeypatch(extra_classes=[SetPasswordMixin])
|
||||
|
||||
if settings.S3_SKIP_PROXY is True and settings.LOCAL_UPLOADS_DIR is None: # nocoverage
|
||||
skip_smokescreen_proxy_for_boto3()
|
||||
|
||||
# We import zerver.signals here for the side effect of
|
||||
# registering the user_logged_in signal receiver. This import
|
||||
# needs to be here (rather than e.g. at top-of-file) to avoid
|
||||
# running that code too early in Django's setup process, but
|
||||
# in any case, this is an intentionally unused import.
|
||||
import zerver.signals # noqa: F401
|
||||
|
||||
if settings.POST_MIGRATION_CACHE_FLUSHING:
|
||||
post_migrate.connect(flush_cache, sender=self)
|
||||
|
||||
pre_migrate.connect(create_zulip_schema)
|
||||
Reference in New Issue
Block a user