Make 'persist_and_notify_client_event' only return EventBase and document

pull/8476/head
Erik Johnston 2020-10-12 14:22:55 +01:00
parent 7a1c417766
commit 8f5931d504
2 changed files with 16 additions and 8 deletions

View File

@ -933,7 +933,7 @@ class EventCreationHandler:
event.internal_metadata.stream_ordering = stream_id
return event
event, stream_id = await self.persist_and_notify_client_event(
event = await self.persist_and_notify_client_event(
requester, event, context, ratelimit=ratelimit, extra_users=extra_users
)
@ -982,11 +982,16 @@ class EventCreationHandler:
context: EventContext,
ratelimit: bool = True,
extra_users: List[UserID] = [],
) -> Tuple[EventBase, int]:
) -> EventBase:
"""Called when we have fully built the event, have already
calculated the push actions for the event, and checked auth.
This should only be run on the instance in charge of persisting events.
Returns:
The persisted event. This may be different than the given event if
it was de-duplicated (e.g. because we had already persisted an
event with the same transaction ID.)
"""
assert self.storage.persistence is not None
assert self._events_shard_config.should_handle(
@ -1181,7 +1186,7 @@ class EventCreationHandler:
# matters as sometimes presence code can take a while.
run_in_background(self._bump_active_time, requester.user)
return event, event_pos.stream
return event
async def _bump_active_time(self, user: UserID) -> None:
try:

View File

@ -116,14 +116,17 @@ class ReplicationSendEventRestServlet(ReplicationEndpoint):
"Got event to send with ID: %s into room: %s", event.event_id, event.room_id
)
(
event,
stream_id,
) = await self.event_creation_handler.persist_and_notify_client_event(
event = await self.event_creation_handler.persist_and_notify_client_event(
requester, event, context, ratelimit=ratelimit, extra_users=extra_users
)
return 200, {"stream_id": stream_id, "event_id": event.event_id}
return (
200,
{
"stream_id": event.internal_metadata.stream_ordering,
"event_id": event.event_id,
},
)
def register_servlets(hs, http_server):