Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
users: Directly access id of foreign keys instead of full object.
Sahil Batrac11cf8eb5417
diff --git a/zerver/actions/create_user.py b/zerver/actions/create_user.pyindex cb1f0040522..fffce761168 100644--- a/zerver/actions/create_user.py+++ b/zerver/actions/create_user.py@@ -379,8 +379,8 @@ def created_bot_event(user_profile: UserProfile) -> Dict[str, Any]:# Set the owner key only when the bot has an owner.# The default bots don't have an owner. So don't# set the owner key while reactivating them.- if user_profile.bot_owner is not None:- bot["owner_id"] = user_profile.bot_owner.id+ if user_profile.bot_owner_id is not None:+ bot["owner_id"] = user_profile.bot_owner_idreturn dict(type="realm_bot", op="add", bot=bot)diff --git a/zerver/lib/addressee.py b/zerver/lib/addressee.pyindex 567e021664d..06a786eff8d 100644--- a/zerver/lib/addressee.py+++ b/zerver/lib/addressee.py@@ -118,9 +118,9 @@ class Addressee:# This is a hack to deal with the fact that we still support# default streams (and the None will be converted later in the# call path).- if sender.default_sending_stream:+ if sender.default_sending_stream_id:# Use the user's default stream- stream_name_or_id = sender.default_sending_stream.id+ stream_name_or_id = sender.default_sending_stream_idelse:raise JsonableError(_("Missing stream"))diff --git a/zerver/models.py b/zerver/models.pyindex d93dab4037f..fa3788e043e 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -1990,7 +1990,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin, UserBaseSettings): # typedef can_admin_user(self, target_user: "UserProfile") -> bool:"""Returns whether this user has permission to modify target_user"""- if target_user.bot_owner == self:+ if target_user.bot_owner_id == self.id:return Trueelif self.is_realm_admin and self.realm == target_user.realm:return Truediff --git a/zerver/views/streams.py b/zerver/views/streams.pyindex 534a70ed70a..948034815dd 100644--- a/zerver/views/streams.py+++ b/zerver/views/streams.py@@ -140,7 +140,7 @@ def user_directly_controls_user(user_profile: UserProfile, target: UserProfile)owned by the current user"""if user_profile == target:return True- if target.is_bot and target.bot_owner == user_profile:+ if target.is_bot and target.bot_owner_id == user_profile.id:return Truereturn False