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

Commit

Permalink
Fix the return type of send_nonmember_events. (#8112)
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep authored Aug 18, 2020
1 parent 5cf7c12 commit 3c01724
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog.d/8112.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Return the previous stream token if a non-member event is a duplicate.
2 changes: 1 addition & 1 deletion synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ async def send_nonmember_event(
event.event_id,
prev_event.event_id,
)
return await self.store.get_stream_token_for_event(prev_event.event_id)
return await self.store.get_stream_id_for_event(prev_event.event_id)

return await self.handle_new_client_event(
requester=requester, event=event, context=context, ratelimit=ratelimit
Expand Down
19 changes: 15 additions & 4 deletions synapse/storage/databases/main/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,19 @@ async def get_room_events_max_id(self, room_id: Optional[str] = None) -> str:
)
return "t%d-%d" % (topo, token)

async def get_stream_id_for_event(self, event_id: str) -> int:
"""The stream ID for an event
Args:
event_id: The id of the event to look up a stream token for.
Raises:
StoreError if the event wasn't in the database.
Returns:
A stream ID.
"""
return await self.db_pool.simple_select_one_onecol(
table="events", keyvalues={"event_id": event_id}, retcol="stream_ordering"
)

async def get_stream_token_for_event(self, event_id: str) -> str:
"""The stream token for an event
Args:
Expand All @@ -591,10 +604,8 @@ async def get_stream_token_for_event(self, event_id: str) -> str:
Returns:
A "s%d" stream token.
"""
row = await self.db_pool.simple_select_one_onecol(
table="events", keyvalues={"event_id": event_id}, retcol="stream_ordering"
)
return "s%d" % (row,)
stream_id = await self.get_stream_id_for_event(event_id)
return "s%d" % (stream_id,)

async def get_topological_token_for_event(self, event_id: str) -> str:
"""The stream token for an event
Expand Down

0 comments on commit 3c01724

Please sign in to comment.