Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
929cb0ed
Commit
929cb0ed
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Don't set currently_active for remote presence
parent
5f4eca38
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/handlers/presence.py
+12
-6
12 additions, 6 deletions
synapse/handlers/presence.py
tests/handlers/test_presence.py
+15
-4
15 additions, 4 deletions
tests/handlers/test_presence.py
with
27 additions
and
10 deletions
synapse/handlers/presence.py
+
12
−
6
View file @
929cb0ed
...
@@ -995,6 +995,18 @@ def handle_update(prev_state, new_state, is_mine, wheel_timer, now):
...
@@ -995,6 +995,18 @@ def handle_update(prev_state, new_state, is_mine, wheel_timer, now):
then
=
new_state
.
last_active_ts
+
IDLE_TIMER
then
=
new_state
.
last_active_ts
+
IDLE_TIMER
)
)
active
=
now
-
new_state
.
last_active_ts
<
LAST_ACTIVE_GRANULARITY
new_state
=
new_state
.
copy_and_replace
(
currently_active
=
active
,
)
if
active
:
wheel_timer
.
insert
(
now
=
now
,
obj
=
user_id
,
then
=
new_state
.
last_active_ts
+
LAST_ACTIVE_GRANULARITY
)
if
new_state
.
state
!=
PresenceState
.
OFFLINE
:
if
new_state
.
state
!=
PresenceState
.
OFFLINE
:
# User has stopped syncing
# User has stopped syncing
wheel_timer
.
insert
(
wheel_timer
.
insert
(
...
@@ -1018,12 +1030,6 @@ def handle_update(prev_state, new_state, is_mine, wheel_timer, now):
...
@@ -1018,12 +1030,6 @@ def handle_update(prev_state, new_state, is_mine, wheel_timer, now):
then
=
new_state
.
last_federation_update_ts
+
FEDERATION_TIMEOUT
then
=
new_state
.
last_federation_update_ts
+
FEDERATION_TIMEOUT
)
)
if
new_state
.
state
==
PresenceState
.
ONLINE
:
active
=
now
-
new_state
.
last_active_ts
<
LAST_ACTIVE_GRANULARITY
new_state
=
new_state
.
copy_and_replace
(
currently_active
=
active
,
)
# Check whether the change was something worth notifying about
# Check whether the change was something worth notifying about
if
should_notify
(
prev_state
,
new_state
):
if
should_notify
(
prev_state
,
new_state
):
new_state
=
new_state
.
copy_and_replace
(
new_state
=
new_state
.
copy_and_replace
(
...
...
This diff is collapsed.
Click to expand it.
tests/handlers/test_presence.py
+
15
−
4
View file @
929cb0ed
...
@@ -49,7 +49,7 @@ class PresenceUpdateTestCase(unittest.TestCase):
...
@@ -49,7 +49,7 @@ class PresenceUpdateTestCase(unittest.TestCase):
self
.
assertEquals
(
new_state
.
status_msg
,
state
.
status_msg
)
self
.
assertEquals
(
new_state
.
status_msg
,
state
.
status_msg
)
self
.
assertEquals
(
state
.
last_federation_update_ts
,
now
)
self
.
assertEquals
(
state
.
last_federation_update_ts
,
now
)
self
.
assertEquals
(
wheel_timer
.
insert
.
call_count
,
2
)
self
.
assertEquals
(
wheel_timer
.
insert
.
call_count
,
3
)
wheel_timer
.
insert
.
assert_has_calls
([
wheel_timer
.
insert
.
assert_has_calls
([
call
(
call
(
now
=
now
,
now
=
now
,
...
@@ -60,7 +60,12 @@ class PresenceUpdateTestCase(unittest.TestCase):
...
@@ -60,7 +60,12 @@ class PresenceUpdateTestCase(unittest.TestCase):
now
=
now
,
now
=
now
,
obj
=
user_id
,
obj
=
user_id
,
then
=
new_state
.
last_user_sync_ts
+
SYNC_ONLINE_TIMEOUT
then
=
new_state
.
last_user_sync_ts
+
SYNC_ONLINE_TIMEOUT
)
),
call
(
now
=
now
,
obj
=
user_id
,
then
=
new_state
.
last_active_ts
+
LAST_ACTIVE_GRANULARITY
),
],
any_order
=
True
)
],
any_order
=
True
)
def
test_online_to_online
(
self
):
def
test_online_to_online
(
self
):
...
@@ -91,7 +96,7 @@ class PresenceUpdateTestCase(unittest.TestCase):
...
@@ -91,7 +96,7 @@ class PresenceUpdateTestCase(unittest.TestCase):
self
.
assertEquals
(
new_state
.
status_msg
,
state
.
status_msg
)
self
.
assertEquals
(
new_state
.
status_msg
,
state
.
status_msg
)
self
.
assertEquals
(
state
.
last_federation_update_ts
,
now
)
self
.
assertEquals
(
state
.
last_federation_update_ts
,
now
)
self
.
assertEquals
(
wheel_timer
.
insert
.
call_count
,
2
)
self
.
assertEquals
(
wheel_timer
.
insert
.
call_count
,
3
)
wheel_timer
.
insert
.
assert_has_calls
([
wheel_timer
.
insert
.
assert_has_calls
([
call
(
call
(
now
=
now
,
now
=
now
,
...
@@ -102,7 +107,12 @@ class PresenceUpdateTestCase(unittest.TestCase):
...
@@ -102,7 +107,12 @@ class PresenceUpdateTestCase(unittest.TestCase):
now
=
now
,
now
=
now
,
obj
=
user_id
,
obj
=
user_id
,
then
=
new_state
.
last_user_sync_ts
+
SYNC_ONLINE_TIMEOUT
then
=
new_state
.
last_user_sync_ts
+
SYNC_ONLINE_TIMEOUT
)
),
call
(
now
=
now
,
obj
=
user_id
,
then
=
new_state
.
last_active_ts
+
LAST_ACTIVE_GRANULARITY
),
],
any_order
=
True
)
],
any_order
=
True
)
def
test_online_to_online_last_active
(
self
):
def
test_online_to_online_last_active
(
self
):
...
@@ -153,6 +163,7 @@ class PresenceUpdateTestCase(unittest.TestCase):
...
@@ -153,6 +163,7 @@ class PresenceUpdateTestCase(unittest.TestCase):
prev_state
=
UserPresenceState
.
default
(
user_id
)
prev_state
=
UserPresenceState
.
default
(
user_id
)
prev_state
=
prev_state
.
copy_and_replace
(
prev_state
=
prev_state
.
copy_and_replace
(
state
=
PresenceState
.
ONLINE
,
state
=
PresenceState
.
ONLINE
,
last_active_ts
=
now
,
)
)
new_state
=
prev_state
.
copy_and_replace
(
new_state
=
prev_state
.
copy_and_replace
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment