|
|
|
@ -48,7 +48,7 @@ from synapse.metrics.background_process_metrics import run_as_background_process |
|
|
|
|
from synapse.replication.http.send_event import ReplicationSendEventRestServlet |
|
|
|
|
from synapse.storage.data_stores.main.events_worker import EventRedactBehaviour |
|
|
|
|
from synapse.storage.state import StateFilter |
|
|
|
|
from synapse.types import RoomAlias, UserID, create_requester |
|
|
|
|
from synapse.types import Collection, RoomAlias, UserID, create_requester |
|
|
|
|
from synapse.util.async_helpers import Linearizer |
|
|
|
|
from synapse.util.frozenutils import frozendict_json_encoder |
|
|
|
|
from synapse.util.metrics import measure_func |
|
|
|
@ -497,10 +497,14 @@ class EventCreationHandler(object): |
|
|
|
|
if txn_id is not None: |
|
|
|
|
builder.internal_metadata.txn_id = txn_id |
|
|
|
|
|
|
|
|
|
prev_event_ids = ( |
|
|
|
|
None |
|
|
|
|
if prev_events_and_hashes is None |
|
|
|
|
else [event_id for event_id, _, _ in prev_events_and_hashes] |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
event, context = yield self.create_new_client_event( |
|
|
|
|
builder=builder, |
|
|
|
|
requester=requester, |
|
|
|
|
prev_events_and_hashes=prev_events_and_hashes, |
|
|
|
|
builder=builder, requester=requester, prev_event_ids=prev_event_ids, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# In an ideal world we wouldn't need the second part of this condition. However, |
|
|
|
@ -714,7 +718,7 @@ class EventCreationHandler(object): |
|
|
|
|
@measure_func("create_new_client_event") |
|
|
|
|
@defer.inlineCallbacks |
|
|
|
|
def create_new_client_event( |
|
|
|
|
self, builder, requester=None, prev_events_and_hashes=None |
|
|
|
|
self, builder, requester=None, prev_event_ids: Optional[Collection[str]] = None |
|
|
|
|
): |
|
|
|
|
"""Create a new event for a local client |
|
|
|
|
|
|
|
|
@ -723,10 +727,9 @@ class EventCreationHandler(object): |
|
|
|
|
|
|
|
|
|
requester (synapse.types.Requester|None): |
|
|
|
|
|
|
|
|
|
prev_events_and_hashes (list[(str, dict[str, str], int)]|None): |
|
|
|
|
prev_event_ids: |
|
|
|
|
the forward extremities to use as the prev_events for the |
|
|
|
|
new event. For each event, a tuple of (event_id, hashes, depth) |
|
|
|
|
where *hashes* is a map from algorithm to hash. |
|
|
|
|
new event. |
|
|
|
|
|
|
|
|
|
If None, they will be requested from the database. |
|
|
|
|
|
|
|
|
@ -734,12 +737,11 @@ class EventCreationHandler(object): |
|
|
|
|
Deferred[(synapse.events.EventBase, synapse.events.snapshot.EventContext)] |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
if prev_events_and_hashes is not None: |
|
|
|
|
assert len(prev_events_and_hashes) <= 10, ( |
|
|
|
|
if prev_event_ids is not None: |
|
|
|
|
assert len(prev_event_ids) <= 10, ( |
|
|
|
|
"Attempting to create an event with %i prev_events" |
|
|
|
|
% (len(prev_events_and_hashes),) |
|
|
|
|
% (len(prev_event_ids),) |
|
|
|
|
) |
|
|
|
|
prev_event_ids = [event_id for event_id, _, _ in prev_events_and_hashes] |
|
|
|
|
else: |
|
|
|
|
prev_event_ids = yield self.store.get_prev_events_for_room(builder.room_id) |
|
|
|
|
|
|
|
|
|