#NEWLINE# @ defer . inlineCallbacks #NEWLINE# def get_current_state( self , room_id , event_type = None , state_key = '' ) : #NEWLINE# #INDENT# if ( event_type and ( state_key is not None ) ) : #NEWLINE# #INDENT# result = ( yield self . get_current_state_for_key ( room_id , event_type , event_ids ) ) #NEWLINE# defer . returnValue ( result ) #NEWLINE# #UNINDENT# def f( txn ) : #NEWLINE# #INDENT# sql = 'SELECT event_id FROM current_state_events WHERE room_id = ? ' #NEWLINE# if ( event_type and ( state_key is not None ) ) : #NEWLINE# #INDENT# sql += ' AND type = ? AND state_key = ? ' #NEWLINE# args = ( room_id , event_type , state_key ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if event_type : #NEWLINE# #INDENT# sql += ' AND type = ?' #NEWLINE# args = ( room_id , event_type ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# args = ( room_id , ) #NEWLINE# #UNINDENT# #UNINDENT# txn . execute ( sql , args ) #NEWLINE# results = txn . fetchall ( ) #NEWLINE# return [ r [ 0 ] for r in results ] #NEWLINE# #UNINDENT# event_ids = ( yield self . runInteraction ( 'get_current_state' , f ) ) #NEWLINE# events = ( yield self . _get_events ( event_ids , get_prev_content = False ) ) #NEWLINE# defer . returnValue ( events )