mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-17 02:10:41 -04:00
Add support for batch sending new events
This commit is contained in:
parent
a7bdc4a1ed
commit
4eddcf6653
6 changed files with 86 additions and 20 deletions
|
@ -84,6 +84,7 @@ class ReplicationSendEventRestServlet(ReplicationEndpoint):
|
|||
requester: Requester,
|
||||
ratelimit: bool,
|
||||
extra_users: List[UserID],
|
||||
dont_notify: bool,
|
||||
) -> JsonDict:
|
||||
"""
|
||||
Args:
|
||||
|
@ -94,6 +95,7 @@ class ReplicationSendEventRestServlet(ReplicationEndpoint):
|
|||
context
|
||||
ratelimit
|
||||
extra_users: Any extra users to notify about event
|
||||
dont_notify
|
||||
"""
|
||||
serialized_context = await context.serialize(event, store)
|
||||
|
||||
|
@ -108,6 +110,7 @@ class ReplicationSendEventRestServlet(ReplicationEndpoint):
|
|||
"requester": requester.serialize(),
|
||||
"ratelimit": ratelimit,
|
||||
"extra_users": [u.to_string() for u in extra_users],
|
||||
"dont_notify": dont_notify,
|
||||
}
|
||||
|
||||
return payload
|
||||
|
@ -133,13 +136,18 @@ class ReplicationSendEventRestServlet(ReplicationEndpoint):
|
|||
|
||||
ratelimit = content["ratelimit"]
|
||||
extra_users = [UserID.from_string(u) for u in content["extra_users"]]
|
||||
dont_notify = content["dont_notify"]
|
||||
|
||||
logger.info(
|
||||
"Got event to send with ID: %s into room: %s", event.event_id, event.room_id
|
||||
)
|
||||
|
||||
event = await self.event_creation_handler.persist_and_notify_client_events(
|
||||
requester, [(event, context)], ratelimit=ratelimit, extra_users=extra_users
|
||||
requester,
|
||||
[(event, context)],
|
||||
ratelimit=ratelimit,
|
||||
extra_users=extra_users,
|
||||
dont_notify=dont_notify,
|
||||
)
|
||||
|
||||
return (
|
||||
|
|
|
@ -82,6 +82,7 @@ class ReplicationSendEventsRestServlet(ReplicationEndpoint):
|
|||
requester: Requester,
|
||||
ratelimit: bool,
|
||||
extra_users: List[UserID],
|
||||
dont_notify: bool,
|
||||
) -> JsonDict:
|
||||
"""
|
||||
Args:
|
||||
|
@ -108,7 +109,7 @@ class ReplicationSendEventsRestServlet(ReplicationEndpoint):
|
|||
}
|
||||
serialized_events.append(serialized_event)
|
||||
|
||||
payload = {"events": serialized_events}
|
||||
payload = {"events": serialized_events, "dont_notify": dont_notify}
|
||||
|
||||
return payload
|
||||
|
||||
|
@ -118,6 +119,7 @@ class ReplicationSendEventsRestServlet(ReplicationEndpoint):
|
|||
with Measure(self.clock, "repl_send_events_parse"):
|
||||
events_and_context = []
|
||||
events = payload["events"]
|
||||
dont_notify = payload["dont_notify"]
|
||||
|
||||
for event_payload in events:
|
||||
event_dict = event_payload["event"]
|
||||
|
@ -152,7 +154,11 @@ class ReplicationSendEventsRestServlet(ReplicationEndpoint):
|
|||
|
||||
last_event = (
|
||||
await self.event_creation_handler.persist_and_notify_client_events(
|
||||
requester, events_and_context, ratelimit, extra_users
|
||||
requester,
|
||||
events_and_context,
|
||||
ratelimit,
|
||||
extra_users,
|
||||
dont_notify=dont_notify,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue