@@ -2681,19 +2681,18 @@ async def on_exchange_third_party_invite_request(
2681
2681
member_handler = self .hs .get_room_member_handler ()
2682
2682
await member_handler .send_membership_event (None , event , context )
2683
2683
2684
- @defer .inlineCallbacks
2685
- def add_display_name_to_third_party_invite (
2684
+ async def add_display_name_to_third_party_invite (
2686
2685
self , room_version , event_dict , event , context
2687
2686
):
2688
2687
key = (
2689
2688
EventTypes .ThirdPartyInvite ,
2690
2689
event .content ["third_party_invite" ]["signed" ]["token" ],
2691
2690
)
2692
2691
original_invite = None
2693
- prev_state_ids = yield context .get_prev_state_ids ()
2692
+ prev_state_ids = await context .get_prev_state_ids ()
2694
2693
original_invite_id = prev_state_ids .get (key )
2695
2694
if original_invite_id :
2696
- original_invite = yield self .store .get_event (
2695
+ original_invite = await self .store .get_event (
2697
2696
original_invite_id , allow_none = True
2698
2697
)
2699
2698
if original_invite :
@@ -2714,14 +2713,13 @@ def add_display_name_to_third_party_invite(
2714
2713
2715
2714
builder = self .event_builder_factory .new (room_version , event_dict )
2716
2715
EventValidator ().validate_builder (builder )
2717
- event , context = yield self .event_creation_handler .create_new_client_event (
2716
+ event , context = await self .event_creation_handler .create_new_client_event (
2718
2717
builder = builder
2719
2718
)
2720
2719
EventValidator ().validate_new (event , self .config )
2721
2720
return (event , context )
2722
2721
2723
- @defer .inlineCallbacks
2724
- def _check_signature (self , event , context ):
2722
+ async def _check_signature (self , event , context ):
2725
2723
"""
2726
2724
Checks that the signature in the event is consistent with its invite.
2727
2725
@@ -2738,12 +2736,12 @@ def _check_signature(self, event, context):
2738
2736
signed = event .content ["third_party_invite" ]["signed" ]
2739
2737
token = signed ["token" ]
2740
2738
2741
- prev_state_ids = yield context .get_prev_state_ids ()
2739
+ prev_state_ids = await context .get_prev_state_ids ()
2742
2740
invite_event_id = prev_state_ids .get ((EventTypes .ThirdPartyInvite , token ))
2743
2741
2744
2742
invite_event = None
2745
2743
if invite_event_id :
2746
- invite_event = yield self .store .get_event (invite_event_id , allow_none = True )
2744
+ invite_event = await self .store .get_event (invite_event_id , allow_none = True )
2747
2745
2748
2746
if not invite_event :
2749
2747
raise AuthError (403 , "Could not find invite" )
@@ -2792,7 +2790,7 @@ def _check_signature(self, event, context):
2792
2790
raise
2793
2791
try :
2794
2792
if "key_validity_url" in public_key_object :
2795
- yield self ._check_key_revocation (
2793
+ await self ._check_key_revocation (
2796
2794
public_key , public_key_object ["key_validity_url" ]
2797
2795
)
2798
2796
except Exception :
@@ -2806,8 +2804,7 @@ def _check_signature(self, event, context):
2806
2804
last_exception = e
2807
2805
raise last_exception
2808
2806
2809
- @defer .inlineCallbacks
2810
- def _check_key_revocation (self , public_key , url ):
2807
+ async def _check_key_revocation (self , public_key , url ):
2811
2808
"""
2812
2809
Checks whether public_key has been revoked.
2813
2810
@@ -2821,7 +2818,7 @@ def _check_key_revocation(self, public_key, url):
2821
2818
for revocation.
2822
2819
"""
2823
2820
try :
2824
- response = yield self .http_client .get_json (url , {"public_key" : public_key })
2821
+ response = await self .http_client .get_json (url , {"public_key" : public_key })
2825
2822
except Exception :
2826
2823
raise SynapseError (502 , "Third party certificate could not be checked" )
2827
2824
if "valid" not in response or not response ["valid" ]:
@@ -2916,8 +2913,7 @@ async def user_joined_room(self, user: UserID, room_id: str) -> None:
2916
2913
else :
2917
2914
user_joined_room (self .distributor , user , room_id )
2918
2915
2919
- @defer .inlineCallbacks
2920
- def get_room_complexity (self , remote_room_hosts , room_id ):
2916
+ async def get_room_complexity (self , remote_room_hosts , room_id ):
2921
2917
"""
2922
2918
Fetch the complexity of a remote room over federation.
2923
2919
@@ -2931,12 +2927,12 @@ def get_room_complexity(self, remote_room_hosts, room_id):
2931
2927
"""
2932
2928
2933
2929
for host in remote_room_hosts :
2934
- res = yield self .federation_client .get_room_complexity (host , room_id )
2930
+ res = await self .federation_client .get_room_complexity (host , room_id )
2935
2931
2936
2932
# We got a result, return it.
2937
2933
if res :
2938
- defer . returnValue ( res )
2934
+ return res
2939
2935
2940
2936
# We fell off the bottom, couldn't get the complexity from anyone. Oh
2941
2937
# well.
2942
- defer . returnValue ( None )
2938
+ return None
0 commit comments