From 7af789c48fd39be0a870754d3a6a47dbb6f024cc Mon Sep 17 00:00:00 2001 From: Mateusz Mandera Date: Mon, 26 Jul 2021 17:42:44 +0200 Subject: [PATCH] models: Make realm_id arg of get_system_bot required. --- zerver/models.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/zerver/models.py b/zerver/models.py index 233ad6d3ec..1e72bb3db3 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -3096,7 +3096,16 @@ def get_user_including_cross_realm(email: str, realm: Realm) -> UserProfile: @cache_with_key(bot_profile_cache_key, timeout=3600 * 24 * 7) -def get_system_bot(email: str, realm_id: Optional[int] = None) -> UserProfile: +def get_system_bot(email: str, realm_id: int) -> UserProfile: + """ + This function doesn't use the realm_id argument yet, but requires + passing it as preparation for adding system bots to each realm instead + of having them all in a separate system bot realm. + If you're calling this function, use the id of the realm in which the system + bot will be after that migration. If the bot is supposed to send a message, + the same realm as the one *to* which the message will be sent should be used - because + cross-realm messages will be eliminated as part of the migration. + """ return UserProfile.objects.select_related().get(email__iexact=email.strip())