mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Start application service stream token tracking from 1 (#12193)
Co-authored-by: Erik Johnston <erik@matrix.org>
This commit is contained in:
parent
9b67715bc3
commit
c8cbd66d3b
1
changelog.d/12193.misc
Normal file
1
changelog.d/12193.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Omit sending "offline" presence updates to application services after they are initially configured.
|
@ -1625,7 +1625,7 @@ class PresenceEventSource(EventSource[int, UserPresenceState]):
|
|||||||
# We'll actually pull the presence updates for these users at the end.
|
# We'll actually pull the presence updates for these users at the end.
|
||||||
interested_and_updated_users: Union[Set[str], FrozenSet[str]] = set()
|
interested_and_updated_users: Union[Set[str], FrozenSet[str]] = set()
|
||||||
|
|
||||||
if from_key:
|
if from_key is not None:
|
||||||
# First get all users that have had a presence update
|
# First get all users that have had a presence update
|
||||||
updated_users = stream_change_cache.get_all_entities_changed(from_key)
|
updated_users = stream_change_cache.get_all_entities_changed(from_key)
|
||||||
|
|
||||||
|
@ -446,7 +446,8 @@ class ApplicationServiceTransactionWorkerStore(
|
|||||||
)
|
)
|
||||||
last_stream_id = txn.fetchone()
|
last_stream_id = txn.fetchone()
|
||||||
if last_stream_id is None or last_stream_id[0] is None: # no row exists
|
if last_stream_id is None or last_stream_id[0] is None: # no row exists
|
||||||
return 0
|
# Stream tokens always start from 1, to avoid foot guns around `0` being falsey.
|
||||||
|
return 1
|
||||||
else:
|
else:
|
||||||
return int(last_stream_id[0])
|
return int(last_stream_id[0])
|
||||||
|
|
||||||
|
@ -476,12 +476,12 @@ class ApplicationServiceStoreTypeStreamIds(unittest.HomeserverTestCase):
|
|||||||
value = self.get_success(
|
value = self.get_success(
|
||||||
self.store.get_type_stream_id_for_appservice(self.service, "read_receipt")
|
self.store.get_type_stream_id_for_appservice(self.service, "read_receipt")
|
||||||
)
|
)
|
||||||
self.assertEqual(value, 0)
|
self.assertEqual(value, 1)
|
||||||
|
|
||||||
value = self.get_success(
|
value = self.get_success(
|
||||||
self.store.get_type_stream_id_for_appservice(self.service, "presence")
|
self.store.get_type_stream_id_for_appservice(self.service, "presence")
|
||||||
)
|
)
|
||||||
self.assertEqual(value, 0)
|
self.assertEqual(value, 1)
|
||||||
|
|
||||||
def test_get_type_stream_id_for_appservice_invalid_type(self) -> None:
|
def test_get_type_stream_id_for_appservice_invalid_type(self) -> None:
|
||||||
self.get_failure(
|
self.get_failure(
|
||||||
|
Loading…
Reference in New Issue
Block a user