Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
import_util: Refactor a `get_domain_name_for_import`.
Mateusz Mandera192fb999930d
diff --git a/zerver/data_import/import_util.py b/zerver/data_import/import_util.pyindex d40f29f0fe8..7ad8315f907 100644--- a/zerver/data_import/import_util.py+++ b/zerver/data_import/import_util.py@@ -9,9 +9,11 @@ from collections.abc import Callable, Iterable, Iterator, Mappingfrom collections.abc import Set as AbstractSetfrom dataclasses import dataclassfrom typing import Any, Protocol, TypeAlias, TypeVar+from urllib.parse import SplitResultimport orjsonimport requests+from django.conf import settingsfrom django.core.exceptions import ValidationErrorfrom django.core.validators import validate_emailfrom django.forms.models import model_to_dict@@ -929,3 +931,9 @@ def get_attachment_path_and_content(markdown_link = get_markdown_link_for_url(link_name, attachment_url)return AttachmentLinkResult(path_id=path_id, markdown_link=markdown_link)+++def get_domain_name_for_import() -> str:+ hostname = SplitResult("", settings.EXTERNAL_HOST, "", "", "").hostname+ assert hostname is not None+ return hostnamediff --git a/zerver/data_import/slack.py b/zerver/data_import/slack.pyindex 59b5c6667cc..1469b029e77 100644--- a/zerver/data_import/slack.py+++ b/zerver/data_import/slack.py@@ -13,7 +13,7 @@ from datetime import datetime, timezonefrom email.errors import HeaderDefectfrom email.headerregistry import Addressfrom typing import Any, TypeAlias-from urllib.parse import SplitResult, urlsplit+from urllib.parse import urlsplitimport orjsonimport requests@@ -41,6 +41,7 @@ from zerver.data_import.import_util import (download_and_export_upload_file,get_attachment_path_and_content,get_data_file,+ get_domain_name_for_import,long_term_idle_helper,make_subscriber_map,process_avatars,@@ -1748,7 +1749,7 @@ def do_convert_directory(# Subdomain is set by the user while running the import commandrealm_subdomain = ""realm_id = 0- domain_name = SplitResult("", settings.EXTERNAL_HOST, "", "", "").hostname+ domain_name = get_domain_name_for_import()assert isinstance(domain_name, str)(