#NEWLINE# @ defer . inlineCallbacks #NEWLINE# @ log_function #NEWLINE# def on_send_join_request( self , origin , pdu ) : #NEWLINE# #INDENT# ' We have received a join event for a room. Fully process it and\n        respond with the current state and auth chains.\n        ' #NEWLINE# event = pdu #NEWLINE# logger . debug ( 'on_send_join_request: Got event: %s, signatures: %s' , event . event_id , event . signatures ) #NEWLINE# event . internal_metadata . outlier = False #NEWLINE# ( context , event_stream_id , max_stream_id ) = ( yield self . _handle_new_event ( origin , event ) ) #NEWLINE# logger . debug ( 'on_send_join_request: After _handle_new_event: %s, sigs: %s' , event . event_id , event . signatures ) #NEWLINE# extra_users = [ ] #NEWLINE# if ( event . type == EventTypes . Member ) : #NEWLINE# #INDENT# target_user_id = event . state_key #NEWLINE# target_user = UserID . from_string ( target_user_id ) #NEWLINE# extra_users . append ( target_user ) #NEWLINE# #UNINDENT# with PreserveLoggingContext ( ) : #NEWLINE# #INDENT# self . notifier . on_new_room_event ( event , event_stream_id , max_stream_id , extra_users = extra_users ) #NEWLINE# #UNINDENT# if ( event . type == EventTypes . Member ) : #NEWLINE# #INDENT# if ( event . content [ 'membership' ] == Membership . JOIN ) : #NEWLINE# #INDENT# user = UserID . from_string ( event . state_key ) #NEWLINE# ( yield user_joined_room ( self . distributor , user , event . room_id ) ) #NEWLINE# #UNINDENT# #UNINDENT# new_pdu = origin #NEWLINE# destinations = set ( ) #NEWLINE# for ( k , s ) in context . current_state . items ( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( k [ 0 ] == EventTypes . Member ) : #NEWLINE# #INDENT# if ( s . content [ 'membership' ] == Membership . JOIN ) : #NEWLINE# #INDENT# destinations . add ( UserID . from_string ( s . state_key ) . domain ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# logger . warn ( 'Failed to get destination from event %s' , s . event_id ) #NEWLINE# #UNINDENT# #UNINDENT# destinations . discard ( origin ) #NEWLINE# logger . debug ( 'on_send_join_request: Sending event: %s, signatures: %s' , event . event_id , event . signatures ) #NEWLINE# self . replication_layer . send_pdu ( new_pdu , destinations ) #NEWLINE# state_ids = [ e . event_id for e in context . current_state . values ( ) ] #NEWLINE# auth_chain = ( yield self . store . get_auth_chain ( set ( ( [ event . event_id ] + state_ids ) ) ) ) #NEWLINE# defer . returnValue ( { #NEWLINE# #INDENT# 'state' : context . current_state . values ( ) , #NEWLINE# 'auth_chain' : auth_chain , #NEWLINE# #UNINDENT# } )