presence: Core last_update_id mechanism without API changes.

This commit has the mechanism for setting the .last_update_id on the
backend for UserPresence objects, without introducing any API changes.
Therefore this should invisible to clients and able to be deployed
safely without impact to users.
This commit is contained in:
Mateusz Mandera
2024-05-31 21:02:47 +02:00
committed by Tim Abbott
parent b1d50b511c
commit 016880f54d
2 changed files with 114 additions and 17 deletions

View File

@@ -574,10 +574,15 @@ def do_change_user_setting(
seconds=settings.OFFLINE_THRESHOLD_SECS + 120
)
do_update_user_presence(
user_profile,
get_client("website"),
presence_time,
status,
force_send_update=True,
# do_update_user_presence doesn't allow being run inside another
# transaction.atomic block, so we need to use on_commit here to ensure
# it gets executed outside of our current transaction.
transaction.on_commit(
lambda: do_update_user_presence(
user_profile,
get_client("website"),
presence_time,
status,
force_send_update=True,
)
)