diff --git a/dockerfiles/nginx/proxito.conf.template b/dockerfiles/nginx/proxito.conf.template index 592872f2737..24d80e9a947 100644 --- a/dockerfiles/nginx/proxito.conf.template +++ b/dockerfiles/nginx/proxito.conf.template @@ -121,8 +121,6 @@ server { # This header allows us to decide whether or not inject the script at CloudFlare level # Now, I'm injecting it in all the NGINX responses because `sub_filter` is not allowed inside an `if` statement. - set $rtd_hosting_integrations $upstream_http_x_rtd_hosting_integrations; - add_header X-RTD-Hosting-Integrations $rtd_hosting_integrations always; set $rtd_force_addons $upstream_http_x_rtd_force_addons; add_header X-RTD-Force-Addons $rtd_force_addons always; } diff --git a/readthedocs/proxito/middleware.py b/readthedocs/proxito/middleware.py index 03928ffc20a..5db6f24e5ca 100644 --- a/readthedocs/proxito/middleware.py +++ b/readthedocs/proxito/middleware.py @@ -5,11 +5,9 @@ Additional processing is done to get the project from the URL in the ``views.py`` as well. """ -import datetime import re from urllib.parse import urlparse -import pytz import structlog from corsheaders.middleware import ( ACCESS_CONTROL_ALLOW_METHODS, @@ -19,12 +17,10 @@ from django.core.exceptions import SuspiciousOperation from django.shortcuts import redirect from django.urls import reverse -from django.utils import timezone from django.utils.deprecation import MiddlewareMixin from django.utils.encoding import iri_to_uri from django.utils.html import escape -from readthedocs.builds.models import Version from readthedocs.core.unresolver import ( InvalidCustomDomainError, InvalidExternalDomainError, @@ -34,7 +30,7 @@ unresolver, ) from readthedocs.core.utils import get_cache_tag -from readthedocs.projects.models import Feature, Project +from readthedocs.projects.models import Project from readthedocs.proxito.cache import add_cache_tags, cache_response, private_response from readthedocs.proxito.redirects import redirect_to_https @@ -278,65 +274,21 @@ def add_hosting_integrations_headers(self, request, response): the old flyout integration based on HTTP headers. This method uses two different headers for these purposes: - - ``X-RTD-Hosting-Integrations``: inject ``readthedocs-addons.js`` to enable addons. - Enabled by default on projects using ``build.commands``. - ``X-RTD-Force-Addons``: inject ``readthedocs-addons.js`` and remove old flyout integration (via ``readthedocs-doc-embed.js``). - Enabled only on projects that opted-in via the admin settings. + Enabled on all projects by default starting on Oct 7, 2024. - Note these headers will not be required anymore eventually - since all the project will be using the new addons once we fully roll them out. """ addons = False project_slug = getattr(request, "path_project_slug", "") - version_slug = getattr(request, "path_version_slug", "") if project_slug: - tzinfo = pytz.timezone("America/Los_Angeles") - addons_enabled_by_default = timezone.now() > datetime.datetime( - 2024, - 10, - 7, - 0, - 0, - 0, - tzinfo=tzinfo, - ) - if addons_enabled_by_default: - addons = Project.objects.filter( - slug=project_slug, addons__enabled=True - ).exists() + addons = Project.objects.filter( + slug=project_slug, addons__enabled=True + ).exists() - if addons: - response["X-RTD-Force-Addons"] = "true" - return - - else: - # TODO: remove "else" code once DISABLE_SPHINX_MANIPULATION and addons becomes the default - # https://about.readthedocs.com/blog/2024/07/addons-by-default/ - disable_sphinx_manipulation_enabled = Feature.objects.filter( - feature_id=Feature.DISABLE_SPHINX_MANIPULATION, - projects__slug=Project.objects.filter(slug=project_slug).first(), - ).exists() - - force_addons = Project.objects.filter( - slug=project_slug, - addons__enabled=True, - ).exists() - - if force_addons or disable_sphinx_manipulation_enabled: - response["X-RTD-Force-Addons"] = "true" - return - - if version_slug: - addons = Version.objects.filter( - project__slug=project_slug, - slug=version_slug, - addons=True, - ).exists() - - if addons: - response["X-RTD-Hosting-Integrations"] = "true" + if addons: + response["X-RTD-Force-Addons"] = "true" def add_cors_headers(self, request, response): """