Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
migration: Rename 'populate_db' Client to 'ZulipDataImport'.
userAdityaa354a16fb0aa0
diff --git a/zerver/data_import/import_util.py b/zerver/data_import/import_util.pyindex 269812ac675..0c25b1d06ba 100644--- a/zerver/data_import/import_util.py+++ b/zerver/data_import/import_util.py@@ -38,6 +38,17 @@ from zproject.backends import all_default_backend_names# stubsZerverFieldsT: TypeAlias = dict[str, Any]+DATA_IMPORT_CLIENTS = {+ # Match low ID clients in zerver/lib/server_initialization.py.+ # This has no functional impact other than ensuring low IDs.+ "Internal": 1,+ "website": 2,+ "ZulipMobile": 3,+ "ZulipElectron": 4,+ # Special client key to be used for data import messages.+ "ZulipDataImport": 5,+}+class SubscriberHandler:def __init__(self) -> None:@@ -352,9 +363,8 @@ def build_realm() -> ZerverFieldsT:realm = dict(zerver_client=[- {"name": "populate_db", "id": 1},- {"name": "website", "id": 2},- {"name": "API", "id": 3},+ {"name": client_name, "id": client_id}+ for client_name, client_id in DATA_IMPORT_CLIENTS.items()],zerver_customprofilefield=[],zerver_customprofilefieldvalue=[],@@ -520,7 +530,7 @@ def build_message(zulip_message, exclude=["recipient", "sender", "sending_client"])zulip_message_dict["sender"] = user_id- zulip_message_dict["sending_client"] = 1+ zulip_message_dict["sending_client"] = DATA_IMPORT_CLIENTS["ZulipDataImport"]zulip_message_dict["recipient"] = recipient_idzulip_message_dict["date_sent"] = date_sentdiff --git a/zerver/lib/server_initialization.py b/zerver/lib/server_initialization.pyindex 96bc750ff6f..9ba556724b0 100644--- a/zerver/lib/server_initialization.py+++ b/zerver/lib/server_initialization.py@@ -56,6 +56,8 @@ def create_internal_realm() -> None:# just ensures these get low IDs in production, and in development# avoids an extra database write for the first HTTP request in# most tests.+ #+ # These are currently also present in DATA_IMPORT_CLIENTS.get_client("Internal")get_client("website")get_client("ZulipMobile")diff --git a/zerver/migrations/0702_rename_populate_db_client_to_zulip_data_import.py b/zerver/migrations/0702_rename_populate_db_client_to_zulip_data_import.pynew file mode 100644index 00000000000..9261c24e12d--- /dev/null+++ b/zerver/migrations/0702_rename_populate_db_client_to_zulip_data_import.py@@ -0,0 +1,27 @@+from django.db import migrations+from django.db.backends.base.schema import BaseDatabaseSchemaEditor+from django.db.migrations.state import StateApps+++def rename_populate_db_client(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:+ """Renames the 'populate_db' client to 'ZulipDataImport' to+ better reflect its use in production, which is messages imported+ into Zulip via official data import tools.+ """+ Client = apps.get_model("zerver", "Client")++ Client.objects.filter(name="populate_db").update(name="ZulipDataImport")+++class Migration(migrations.Migration):+ dependencies = [+ ("zerver", "0701_merge"),+ ]++ operations = [+ migrations.RunPython(+ rename_populate_db_client,+ reverse_code=migrations.RunPython.noop,+ elidable=True,+ ),+ ]diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex f47134f9d03..750a306d71b 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -7494,7 +7494,7 @@ paths:"sender_full_name": "King Hamlet","recipient_id": 27,"topic_links": [],- "client": "populate_db",+ "client": "ZulipDataImport","avatar_url": "https://secure.gravatar.com/avatar/6d8cad0fd00256e7b40691d27ddfd466?d=identicon&version=1","submessages": [],"sender_email": "[email protected]",@@ -7516,7 +7516,7 @@ paths:"sender_full_name": "King Hamlet","recipient_id": 20,"topic_links": [],- "client": "populate_db",+ "client": "ZulipDataImport","avatar_url": "https://secure.gravatar.com/avatar/6d8cad0fd00256e7b40691d27ddfd466?d=identicon&version=1","submessages": [],"sender_email": "[email protected]",@@ -8846,7 +8846,7 @@ paths:"sender_full_name": "King Hamlet","recipient_id": 27,"topic_links": [],- "client": "populate_db",+ "client": "ZulipDataImport","avatar_url": "https://secure.gravatar.com/avatar/6d8cad0fd00256e7b40691d27ddfd466?d=identicon&version=1","submessages": [],"sender_email": "[email protected]",diff --git a/zerver/tests/test_slack_importer.py b/zerver/tests/test_slack_importer.pyindex d1dd4f5a854..297143bdf9b 100644--- a/zerver/tests/test_slack_importer.py+++ b/zerver/tests/test_slack_importer.py@@ -1017,6 +1017,7 @@ class SlackImporter(ZulipTestCase):) = slack_workspace_to_realm("testdomain", realm_id, user_list, "test-realm", "./random_path", {})+test_zerver_realmdomain = [{"realm": realm_id, "allow_subdomains": False, "domain": "testdomain", "id": realm_id}]diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.pyindex 767f7e559e6..4696756c072 100644--- a/zilencer/management/commands/populate_db.py+++ b/zilencer/management/commands/populate_db.py@@ -836,7 +836,7 @@ class Command(ZulipBaseCommand):# cURL example to delete an existing scheduled message.check_schedule_message(sender=iago,- client=get_client("populate_db"),+ client=get_client("ZulipDataImport"),recipient_type_name="stream",message_to=[Stream.objects.get(name="Denmark", realm=zulip_realm).id],topic_name="test-api",@@ -846,7 +846,7 @@ class Command(ZulipBaseCommand):)check_schedule_message(sender=iago,- client=get_client("populate_db"),+ client=get_client("ZulipDataImport"),recipient_type_name="private",message_to=[iago.id],topic_name=None,@@ -1242,7 +1242,7 @@ def generate_and_send_messages(while num_messages < tot_messages:saved_data: dict[str, Any] = {}message = Message(realm=realm)- message.sending_client = get_client("populate_db")+ message.sending_client = get_client("ZulipDataImport")message.content = next(texts)