users: Change bot owner only if needed.

This is a small optimization to avoid DB queries if the bot owner
is not changed.

This also helps in avoiding showing the error message in UI if
anything other than the owner is updated for a deactivated bot.
Ideally if the bot owner is not changed, the bot_owner_id field
should not be passed in the request, but we would handle that
later given this is anyways a small nice optimization and we
follow this pattern at other places as well in the API.
This commit is contained in:
Sahil Batra 2024-07-17 13:23:23 +05:30 committed by Tim Abbott
parent 13eb1381de
commit cf14d8f611
1 changed files with 1 additions and 1 deletions

View File

@ -357,7 +357,7 @@ def patch_bot_backend(
do_change_user_role(bot, role, acting_user=user_profile)
if bot_owner_id is not None:
if bot_owner_id is not None and bot.bot_owner_id != bot_owner_id:
try:
owner = get_user_profile_by_id_in_realm(bot_owner_id, user_profile.realm)
except UserProfile.DoesNotExist: