mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 18:06:44 +00:00
Avoid saving user_presence twice when creating a new object.
(imported from commit 72af41b4e0b85f9a8605f5040c321c80e16e8a97)
This commit is contained in:
@@ -795,7 +795,8 @@ def do_update_user_presence(user_profile, client, log_time, status):
|
|||||||
(presence, created) = UserPresence.objects.get_or_create(
|
(presence, created) = UserPresence.objects.get_or_create(
|
||||||
user_profile = user_profile,
|
user_profile = user_profile,
|
||||||
client = client,
|
client = client,
|
||||||
defaults = {'timestamp': log_time})
|
defaults = {'timestamp': log_time,
|
||||||
|
'status': status})
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
transaction.commit()
|
transaction.commit()
|
||||||
presence = UserPresence.objects.get(user_profile = user_profile,
|
presence = UserPresence.objects.get(user_profile = user_profile,
|
||||||
@@ -806,6 +807,7 @@ def do_update_user_presence(user_profile, client, log_time, status):
|
|||||||
was_idle = presence.status == UserPresence.IDLE
|
was_idle = presence.status == UserPresence.IDLE
|
||||||
became_online = (status == UserPresence.ACTIVE) and (stale_status or was_idle)
|
became_online = (status == UserPresence.ACTIVE) and (stale_status or was_idle)
|
||||||
|
|
||||||
|
if not created:
|
||||||
presence.timestamp = log_time
|
presence.timestamp = log_time
|
||||||
presence.status = status
|
presence.status = status
|
||||||
presence.save(update_fields=["timestamp", "status"])
|
presence.save(update_fields=["timestamp", "status"])
|
||||||
|
|||||||
Reference in New Issue
Block a user