mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 15:33:30 +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
|
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.
|
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 ""
|
!!! tip ""
|
||||||
|
|
||||||
|
|||||||
@@ -290,6 +290,7 @@ def update_user_presence(
|
|||||||
client,
|
client,
|
||||||
status,
|
status,
|
||||||
)
|
)
|
||||||
|
if user_profile.presence_enabled:
|
||||||
do_update_user_presence(user_profile, client, log_time, status)
|
do_update_user_presence(user_profile, client, log_time, status)
|
||||||
if new_user_input:
|
if new_user_input:
|
||||||
update_user_activity_interval(user_profile, log_time)
|
update_user_activity_interval(user_profile, log_time)
|
||||||
|
|||||||
@@ -996,23 +996,30 @@ class GetRealmStatusesTest(ZulipTestCase):
|
|||||||
othello.save(update_fields=["presence_enabled"])
|
othello.save(update_fields=["presence_enabled"])
|
||||||
hamlet.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(
|
result = self.api_post(
|
||||||
othello,
|
othello,
|
||||||
"/api/v1/users/me/presence",
|
"/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",
|
HTTP_USER_AGENT="ZulipAndroid/1.0",
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.api_post(
|
result = self.api_post(
|
||||||
hamlet,
|
hamlet,
|
||||||
"/api/v1/users/me/presence",
|
"/api/v1/users/me/presence",
|
||||||
dict(status="idle"),
|
dict(status="idle"),
|
||||||
HTTP_USER_AGENT="ZulipDesktop/1.0",
|
HTTP_USER_AGENT="ZulipDesktop/1.0",
|
||||||
)
|
)
|
||||||
|
|
||||||
json = self.assert_json_success(result)
|
json = self.assert_json_success(result)
|
||||||
|
|
||||||
# Othello's presence status is disabled so it won't be reported.
|
# Othello's presence status is disabled so it won't be reported.
|
||||||
self.assertEqual(set(json["presences"].keys()), {hamlet.email})
|
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(
|
result = self.api_post(
|
||||||
hamlet,
|
hamlet,
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ def update_active_status_backend(
|
|||||||
status_val = UserPresence.status_from_string(status)
|
status_val = UserPresence.status_from_string(status)
|
||||||
if status_val is None:
|
if status_val is None:
|
||||||
raise JsonableError(_("Invalid status: {status}").format(status=status))
|
raise JsonableError(_("Invalid status: {status}").format(status=status))
|
||||||
elif user_profile.presence_enabled:
|
|
||||||
client = RequestNotes.get_notes(request).client
|
client = RequestNotes.get_notes(request).client
|
||||||
assert client is not None
|
assert client is not None
|
||||||
update_user_presence(user_profile, client, timezone_now(), status_val, new_user_input)
|
update_user_presence(user_profile, client, timezone_now(), status_val, new_user_input)
|
||||||
|
|||||||
Reference in New Issue
Block a user