mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
migration: Rename 'populate_db' Client to 'ZulipDataImport'.
This commit: * Creates a migration to rename any existing Client with name="populate_db" to "ZulipDataImport". * Updates populate_db.py to use ZulipDataImport for new message creation These changes should make code to identify imported messages considerably more readable. Fixes #33909.
This commit is contained in:
@@ -38,6 +38,17 @@ from zproject.backends import all_default_backend_names
|
||||
# stubs
|
||||
ZerverFieldsT: 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_id
|
||||
zulip_message_dict["date_sent"] = date_sent
|
||||
|
||||
|
||||
Reference in New Issue
Block a user