@@ -285,6 +285,7 @@ async def _local_membership_update(
285285 allow_no_prev_events : bool = False ,
286286 prev_event_ids : Optional [List [str ]] = None ,
287287 state_event_ids : Optional [List [str ]] = None ,
288+ depth : Optional [int ] = None ,
288289 txn_id : Optional [str ] = None ,
289290 ratelimit : bool = True ,
290291 content : Optional [dict ] = None ,
@@ -315,6 +316,9 @@ async def _local_membership_update(
315316 prev_events are set so we need to set them ourself via this argument.
316317 This should normally be left as None, which will cause the auth_event_ids
317318 to be calculated based on the room state at the prev_events.
319+ depth: Override the depth used to order the event in the DAG.
320+ Should normally be set to None, which will cause the depth to be calculated
321+ based on the prev_events.
318322
319323 txn_id:
320324 ratelimit:
@@ -370,6 +374,7 @@ async def _local_membership_update(
370374 allow_no_prev_events = allow_no_prev_events ,
371375 prev_event_ids = prev_event_ids ,
372376 state_event_ids = state_event_ids ,
377+ depth = depth ,
373378 require_consent = require_consent ,
374379 outlier = outlier ,
375380 historical = historical ,
@@ -466,6 +471,7 @@ async def update_membership(
466471 allow_no_prev_events : bool = False ,
467472 prev_event_ids : Optional [List [str ]] = None ,
468473 state_event_ids : Optional [List [str ]] = None ,
474+ depth : Optional [int ] = None ,
469475 ) -> Tuple [str , int ]:
470476 """Update a user's membership in a room.
471477
@@ -501,6 +507,9 @@ async def update_membership(
501507 prev_events are set so we need to set them ourself via this argument.
502508 This should normally be left as None, which will cause the auth_event_ids
503509 to be calculated based on the room state at the prev_events.
510+ depth: Override the depth used to order the event in the DAG.
511+ Should normally be set to None, which will cause the depth to be calculated
512+ based on the prev_events.
504513
505514 Returns:
506515 A tuple of the new event ID and stream ID.
@@ -540,6 +549,7 @@ async def update_membership(
540549 allow_no_prev_events = allow_no_prev_events ,
541550 prev_event_ids = prev_event_ids ,
542551 state_event_ids = state_event_ids ,
552+ depth = depth ,
543553 )
544554
545555 return result
@@ -562,6 +572,7 @@ async def update_membership_locked(
562572 allow_no_prev_events : bool = False ,
563573 prev_event_ids : Optional [List [str ]] = None ,
564574 state_event_ids : Optional [List [str ]] = None ,
575+ depth : Optional [int ] = None ,
565576 ) -> Tuple [str , int ]:
566577 """Helper for update_membership.
567578
@@ -599,6 +610,9 @@ async def update_membership_locked(
599610 prev_events are set so we need to set them ourself via this argument.
600611 This should normally be left as None, which will cause the auth_event_ids
601612 to be calculated based on the room state at the prev_events.
613+ depth: Override the depth used to order the event in the DAG.
614+ Should normally be set to None, which will cause the depth to be calculated
615+ based on the prev_events.
602616
603617 Returns:
604618 A tuple of the new event ID and stream ID.
@@ -732,6 +746,7 @@ async def update_membership_locked(
732746 allow_no_prev_events = allow_no_prev_events ,
733747 prev_event_ids = prev_event_ids ,
734748 state_event_ids = state_event_ids ,
749+ depth = depth ,
735750 content = content ,
736751 require_consent = require_consent ,
737752 outlier = outlier ,
@@ -967,6 +982,7 @@ async def update_membership_locked(
967982 ratelimit = ratelimit ,
968983 prev_event_ids = latest_event_ids ,
969984 state_event_ids = state_event_ids ,
985+ depth = depth ,
970986 content = content ,
971987 require_consent = require_consent ,
972988 outlier = outlier ,
@@ -1322,7 +1338,9 @@ async def do_3pid_invite(
13221338 requester : Requester ,
13231339 txn_id : Optional [str ],
13241340 id_access_token : Optional [str ] = None ,
1325- ) -> int :
1341+ prev_event_ids : Optional [List [str ]] = None ,
1342+ depth : Optional [int ] = None ,
1343+ ) -> Tuple [str , int ]:
13261344 """Invite a 3PID to a room.
13271345
13281346 Args:
@@ -1335,9 +1353,13 @@ async def do_3pid_invite(
13351353 txn_id: The transaction ID this is part of, or None if this is not
13361354 part of a transaction.
13371355 id_access_token: The optional identity server access token.
1356+ depth: Override the depth used to order the event in the DAG.
1357+ prev_event_ids: The event IDs to use as the prev events
1358+ Should normally be set to None, which will cause the depth to be calculated
1359+ based on the prev_events.
13381360
13391361 Returns:
1340- The new stream ID.
1362+ Tuple of event ID and stream ordering position
13411363
13421364 Raises:
13431365 ShadowBanError if the requester has been shadow-banned.
@@ -1383,7 +1405,7 @@ async def do_3pid_invite(
13831405 # We don't check the invite against the spamchecker(s) here (through
13841406 # user_may_invite) because we'll do it further down the line anyway (in
13851407 # update_membership_locked).
1386- _ , stream_id = await self .update_membership (
1408+ event_id , stream_id = await self .update_membership (
13871409 requester , UserID .from_string (invitee ), room_id , "invite" , txn_id = txn_id
13881410 )
13891411 else :
@@ -1402,7 +1424,7 @@ async def do_3pid_invite(
14021424 additional_fields = spam_check [1 ],
14031425 )
14041426
1405- stream_id = await self ._make_and_store_3pid_invite (
1427+ event , stream_id = await self ._make_and_store_3pid_invite (
14061428 requester ,
14071429 id_server ,
14081430 medium ,
@@ -1411,9 +1433,12 @@ async def do_3pid_invite(
14111433 inviter ,
14121434 txn_id = txn_id ,
14131435 id_access_token = id_access_token ,
1436+ prev_event_ids = prev_event_ids ,
1437+ depth = depth ,
14141438 )
1439+ event_id = event .event_id
14151440
1416- return stream_id
1441+ return event_id , stream_id
14171442
14181443 async def _make_and_store_3pid_invite (
14191444 self ,
@@ -1425,7 +1450,9 @@ async def _make_and_store_3pid_invite(
14251450 user : UserID ,
14261451 txn_id : Optional [str ],
14271452 id_access_token : Optional [str ] = None ,
1428- ) -> int :
1453+ prev_event_ids : Optional [List [str ]] = None ,
1454+ depth : Optional [int ] = None ,
1455+ ) -> Tuple [EventBase , int ]:
14291456 room_state = await self ._storage_controllers .state .get_current_state (
14301457 room_id ,
14311458 StateFilter .from_types (
@@ -1518,8 +1545,10 @@ async def _make_and_store_3pid_invite(
15181545 },
15191546 ratelimit = False ,
15201547 txn_id = txn_id ,
1548+ prev_event_ids = prev_event_ids ,
1549+ depth = depth ,
15211550 )
1522- return stream_id
1551+ return event , stream_id
15231552
15241553 async def _is_host_in_room (self , current_state_ids : StateMap [str ]) -> bool :
15251554 # Have we just created the room, and is this about to be the very
0 commit comments