Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
do_deactivate_user: Revoke sessions in transaction.on_commit().
Mateusz Manderaa94b2572beff
diff --git a/zerver/actions/users.py b/zerver/actions/users.pyindex 07202910be4..901fac2fb6f 100644--- a/zerver/actions/users.py+++ b/zerver/actions/users.py@@ -163,7 +163,8 @@ def do_deactivate_user(if settings.BILLING_ENABLED:update_license_ledger_if_needed(user_profile.realm, event_time)- delete_user_sessions(user_profile)+ transaction.on_commit(lambda: delete_user_sessions(user_profile))+event = dict(type="realm_user",op="remove",diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.pyindex db75a724c62..a819f4084b2 100644--- a/zerver/tests/test_decorators.py+++ b/zerver/tests/test_decorators.py@@ -1266,7 +1266,8 @@ class InactiveUserTest(ZulipTestCase):"""user_profile = self.example_user("hamlet")self.login_user(user_profile)- do_deactivate_user(user_profile, acting_user=None)+ with self.captureOnCommitCallbacks(execute=True):+ do_deactivate_user(user_profile, acting_user=None)result = self.client_post("/json/messages",diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.pyindex 9c91435ef5c..d866bce28ed 100644--- a/zerver/tests/test_users.py+++ b/zerver/tests/test_users.py@@ -1625,7 +1625,8 @@ class ActivateTest(ZulipTestCase):self.assert_json_success(result)self.assertEqual(Session.objects.filter(pk=session_key).count(), 1)- do_deactivate_user(user, acting_user=None)+ with self.captureOnCommitCallbacks(execute=True):+ do_deactivate_user(user, acting_user=None)self.assertEqual(Session.objects.filter(pk=session_key).count(), 0)result = self.client_get("/json/users")