email_mirror_message: Move endpoint under /api/internal/.

This also has the side effect that it saves the endpint from being
improperly redirected by the HostDomainMiddleware's canonicalization
code.
This commit is contained in:
Alex Vandiver 2024-02-08 19:15:01 +00:00 committed by Tim Abbott
parent 84fa9be73a
commit e6fa1f5436
3 changed files with 6 additions and 13 deletions

View File

@ -32,7 +32,7 @@ Also you can use optional keys to configure the script and change default values
-d HOST Destination Zulip host for email uploading. Address must contain type of -d HOST Destination Zulip host for email uploading. Address must contain type of
HTTP protocol, e.g. "https://example.com". Default value: "https://127.0.0.1". HTTP protocol, e.g. "https://example.com". Default value: "https://127.0.0.1".
-u URL Destination relative for email uploading. Default value: "/email_mirror_message". -u URL Destination relative for email uploading. Default value: "/api/internal/email_mirror_message".
-n Disable checking ssl certificate. This option is used for -n Disable checking ssl certificate. This option is used for
self-signed certificates. Default value: False. self-signed certificates. Default value: False.
@ -76,7 +76,7 @@ parser.add_argument(
"-u", "-u",
"--dst-url", "--dst-url",
dest="url", dest="url",
default="/email_mirror_message", default="/api/internal/email_mirror_message",
help="Destination relative URL for uploading email from email mirror.", help="Destination relative URL for uploading email from email mirror.",
) )

View File

@ -1543,7 +1543,7 @@ class TestEmailMirrorTornadoView(ZulipTestCase):
with mock_queue_publish("zerver.lib.email_mirror.queue_json_publish") as m: with mock_queue_publish("zerver.lib.email_mirror.queue_json_publish") as m:
m.side_effect = check_queue_json_publish m.side_effect = check_queue_json_publish
return self.client_post("/email_mirror_message", post_data) return self.client_post("/api/internal/email_mirror_message", post_data)
def test_success_stream(self) -> None: def test_success_stream(self) -> None:
stream = get_stream("Denmark", get_realm("zulip")) stream = get_stream("Denmark", get_realm("zulip"))

View File

@ -726,11 +726,6 @@ v1_api_mobile_patterns = [
path("jwt/fetch_api_key", jwt_fetch_api_key), path("jwt/fetch_api_key", jwt_fetch_api_key),
] ]
# View for uploading messages from email mirror
urls += [
path("email_mirror_message", email_mirror_message),
]
# Include URL configuration files for site-specified extra installed # Include URL configuration files for site-specified extra installed
# Django apps # Django apps
for app_name in settings.EXTRA_INSTALLED_APPS: for app_name in settings.EXTRA_INSTALLED_APPS:
@ -739,12 +734,10 @@ for app_name in settings.EXTRA_INSTALLED_APPS:
urls += [path("", include(f"{app_name}.urls"))] urls += [path("", include(f"{app_name}.urls"))]
i18n_urls += import_string(f"{app_name}.urls.i18n_urlpatterns") i18n_urls += import_string(f"{app_name}.urls.i18n_urlpatterns")
# Tornado views # Used internally for communication between command-line, Django,
# and Tornado processes
urls += [ urls += [
# Used internally for communication between Django and Tornado processes path("api/internal/email_mirror_message", email_mirror_message),
#
# Since these views don't use rest_dispatch, they cannot have
# asynchronous Tornado behavior.
path("api/internal/notify_tornado", notify), path("api/internal/notify_tornado", notify),
path("api/v1/events/internal", get_events_internal), path("api/v1/events/internal", get_events_internal),
] ]