mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Don't set currently_active for remote presence
This commit is contained in:
parent
5f4eca3816
commit
929cb0ed7d
@ -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):
|
|||||||
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(
|
||||||
|
@ -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):
|
|||||||
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):
|
|||||||
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):
|
|||||||
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):
|
|||||||
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(
|
||||||
|
Loading…
Reference in New Issue
Block a user