Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Replace exception with log & empty return when stream tokens invalid.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Nov 2, 2021
1 parent 9445883 commit bc991c2
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions synapse/handlers/appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ async def _notify_interested_services_ephemeral(
service, events
)

# Persist the latest handled stream token for this appservice
await self.store.set_type_stream_id_for_appservice(
service, "read_receipt", new_token
)
# Persist the latest handled stream token for this appservice
await self.store.set_type_stream_id_for_appservice(
service, "read_receipt", new_token
)

elif stream_key == "presence_key":
events = await self._handle_presence(service, users, new_token)
Expand All @@ -280,10 +280,10 @@ async def _notify_interested_services_ephemeral(
service, events
)

# Persist the latest handled stream token for this appservice
await self.store.set_type_stream_id_for_appservice(
service, "presence", new_token
)
# Persist the latest handled stream token for this appservice
await self.store.set_type_stream_id_for_appservice(
service, "presence", new_token
)

async def _handle_typing(
self, service: ApplicationService, new_token: int
Expand Down Expand Up @@ -342,7 +342,8 @@ async def _handle_receipts(
service, "read_receipt"
)
if new_token is not None and new_token <= from_key:
raise Exception("Rejecting token lower than stored: %s" % (new_token,))
logger.debug("Rejecting token lower than stored: %s" % (new_token,))
return []

receipts_source = self.event_sources.sources.receipt
receipts, _ = await receipts_source.get_new_events_as(
Expand Down Expand Up @@ -378,7 +379,8 @@ async def _handle_presence(
service, "presence"
)
if new_token is not None and new_token <= from_key:
raise Exception("Rejecting token lower than stored: %s" % (new_token,))
logger.debug("Rejecting token lower than stored: %s" % (new_token,))
return []

for user in users:
if isinstance(user, str):
Expand Down

0 comments on commit bc991c2

Please sign in to comment.