mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
presence: Record stats for invisible users.
This commit is contained in:
@@ -154,6 +154,7 @@ Zulip.
|
||||
|
||||
With this setting, your "Last active" time displayed to other users in
|
||||
the UI will be frozen as the approximate time you enabled this setting.
|
||||
Your activity will still be included in your organization's [statistics](/help/analytics).
|
||||
|
||||
!!! tip ""
|
||||
|
||||
|
@@ -290,6 +290,7 @@ def update_user_presence(
|
||||
client,
|
||||
status,
|
||||
)
|
||||
do_update_user_presence(user_profile, client, log_time, status)
|
||||
if user_profile.presence_enabled:
|
||||
do_update_user_presence(user_profile, client, log_time, status)
|
||||
if new_user_input:
|
||||
update_user_activity_interval(user_profile, log_time)
|
||||
|
@@ -996,23 +996,30 @@ class GetRealmStatusesTest(ZulipTestCase):
|
||||
othello.save(update_fields=["presence_enabled"])
|
||||
hamlet.save(update_fields=["presence_enabled"])
|
||||
|
||||
# Verify the initial UserActivityInterval state is as expected.
|
||||
self.assertEqual(UserActivityInterval.objects.filter(user_profile=othello).count(), 0)
|
||||
|
||||
result = self.api_post(
|
||||
othello,
|
||||
"/api/v1/users/me/presence",
|
||||
dict(status="active"),
|
||||
# Include new_user_input=true to test the UserActivityInterval update
|
||||
# codepath.
|
||||
dict(status="active", new_user_input="true"),
|
||||
HTTP_USER_AGENT="ZulipAndroid/1.0",
|
||||
)
|
||||
|
||||
result = self.api_post(
|
||||
hamlet,
|
||||
"/api/v1/users/me/presence",
|
||||
dict(status="idle"),
|
||||
HTTP_USER_AGENT="ZulipDesktop/1.0",
|
||||
)
|
||||
|
||||
json = self.assert_json_success(result)
|
||||
|
||||
# Othello's presence status is disabled so it won't be reported.
|
||||
self.assertEqual(set(json["presences"].keys()), {hamlet.email})
|
||||
# However, UserActivit Interval still gets updated.
|
||||
self.assertEqual(UserActivityInterval.objects.filter(user_profile=othello).count(), 1)
|
||||
|
||||
result = self.api_post(
|
||||
hamlet,
|
||||
|
@@ -164,10 +164,10 @@ def update_active_status_backend(
|
||||
status_val = UserPresence.status_from_string(status)
|
||||
if status_val is None:
|
||||
raise JsonableError(_("Invalid status: {status}").format(status=status))
|
||||
elif user_profile.presence_enabled:
|
||||
client = RequestNotes.get_notes(request).client
|
||||
assert client is not None
|
||||
update_user_presence(user_profile, client, timezone_now(), status_val, new_user_input)
|
||||
|
||||
client = RequestNotes.get_notes(request).client
|
||||
assert client is not None
|
||||
update_user_presence(user_profile, client, timezone_now(), status_val, new_user_input)
|
||||
|
||||
if ping_only:
|
||||
ret: dict[str, Any] = {}
|
||||
|
Reference in New Issue
Block a user