Remove unused hashes and depths from create_event params

This commit is contained in:
Richard van der Hoff 2020-01-03 16:19:55 +00:00
parent 66ca914dc0
commit 3bef62488e
3 changed files with 13 additions and 22 deletions

View File

@ -422,7 +422,7 @@ class EventCreationHandler(object):
event_dict,
token_id=None,
txn_id=None,
prev_events_and_hashes=None,
prev_event_ids: Optional[Collection[str]] = None,
require_consent=True,
):
"""
@ -439,10 +439,9 @@ class EventCreationHandler(object):
token_id (str)
txn_id (str)
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.
@ -497,12 +496,6 @@ 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_event_ids=prev_event_ids,
)
@ -1038,11 +1031,7 @@ class EventCreationHandler(object):
# For each room we need to find a joined member we can use to send
# the dummy event with.
prev_events_and_hashes = yield self.store.get_prev_events_and_hashes_for_room(
room_id
)
latest_event_ids = (event_id for (event_id, _, _) in prev_events_and_hashes)
latest_event_ids = yield self.store.get_prev_events_for_room(room_id)
members = yield self.state.get_current_users_in_room(
room_id, latest_event_ids=latest_event_ids
@ -1061,7 +1050,7 @@ class EventCreationHandler(object):
"room_id": room_id,
"sender": user_id,
},
prev_events_and_hashes=prev_events_and_hashes,
prev_event_ids=latest_event_ids,
)
event.internal_metadata.proactively_send = False

View File

@ -164,6 +164,12 @@ class RoomMemberHandler(object):
if requester.is_guest:
content["kind"] = "guest"
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.event_creation_handler.create_event(
requester,
{
@ -177,7 +183,7 @@ class RoomMemberHandler(object):
},
token_id=requester.access_token_id,
txn_id=txn_id,
prev_events_and_hashes=prev_events_and_hashes,
prev_event_ids=prev_event_ids,
require_consent=require_consent,
)

View File

@ -522,10 +522,6 @@ class HomeserverTestCase(TestCase):
secrets = self.hs.get_secrets()
requester = Requester(user, None, False, None, None)
prev_events_and_hashes = None
if prev_event_ids:
prev_events_and_hashes = [[p, {}, 0] for p in prev_event_ids]
event, context = self.get_success(
event_creator.create_event(
requester,
@ -535,7 +531,7 @@ class HomeserverTestCase(TestCase):
"sender": user.to_string(),
"content": {"body": secrets.token_hex(), "msgtype": "m.text"},
},
prev_events_and_hashes=prev_events_and_hashes,
prev_event_ids=prev_event_ids,
)
)