0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-16 15:01:23 +01:00

Fix the return type of send_nonmember_events. (#8112)

This commit is contained in:
Patrick Cloke 2020-08-18 09:53:13 -04:00 committed by GitHub
parent 5cf7c12995
commit 3c01724b33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

1
changelog.d/8112.misc Normal file
View file

@ -0,0 +1 @@
Return the previous stream token if a non-member event is a duplicate.

View file

@ -674,7 +674,7 @@ class EventCreationHandler(object):
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

View file

@ -582,6 +582,19 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
)
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:
@ -591,10 +604,8 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
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