<s> from twisted . internet import defer <EOL> class AccountDataEventSource ( object ) : <EOL> def __init__ ( self , hs ) : <EOL> self . store = hs . get_datastore ( ) <EOL> def get_current_key ( self , direction = '<STR_LIT:f>' ) : <EOL> return self . store . get_max_account_data_stream_id ( ) <EOL> @ defer . inlineCallbacks <EOL> def get_new_events ( self , user , from_key , ** kwargs ) : <EOL> user_id = user . to_string ( ) <EOL> last_stream_id = from_key <EOL> current_stream_id = yield self . store . get_max_account_data_stream_id ( ) <EOL> results = [ ] <EOL> tags = yield self . store . get_updated_tags ( user_id , last_stream_id ) <EOL> for room_id , room_tags in tags . items ( ) : <EOL> results . append ( { <EOL> "<STR_LIT:type>" : "<STR_LIT>" , <EOL> "<STR_LIT:content>" : { "<STR_LIT>" : room_tags } , <EOL> "<STR_LIT>" : room_id , <EOL> } ) <EOL> account_data , room_account_data = ( <EOL> yield self . store . get_updated_account_data_for_user ( user_id , last_stream_id ) <EOL> ) <EOL> for account_data_type , content in account_data . items ( ) : <EOL> results . append ( { <EOL> "<STR_LIT:type>" : account_data_type , <EOL> "<STR_LIT:content>" : content , <EOL> } ) <EOL> for room_id , account_data in room_account_data . items ( ) : <EOL> for account_data_type , content in account_data . items ( ) : <EOL> results . append ( { <EOL> "<STR_LIT:type>" : account_data_type , <EOL> "<STR_LIT:content>" : content , <EOL> "<STR_LIT>" : room_id , <EOL> } ) <EOL> defer . returnValue ( ( results , current_stream_id ) ) <EOL> @ defer . inlineCallbacks <EOL> def get_pagination_rows ( self , user , config , key ) : <EOL> defer . returnValue ( ( [ ] , config . to_id ) ) </s>
