#NEWLINE# def get_updated_account_data_for_user( self , user_id , stream_id ) : #NEWLINE# #INDENT# "Get all the client account_data for a that's changed for a user\n\n        Args:\n            user_id(str): The user to get the account_data for.\n            stream_id(int): The point in the stream since which to get updates\n        Returns:\n            A deferred pair of a dict of global account_data and a dict\n            mapping from room_id string to per room account_data dicts.\n        " #NEWLINE# def get_updated_account_data_for_user_txn( txn ) : #NEWLINE# #INDENT# sql = 'SELECT account_data_type, content FROM account_data WHERE user_id = ? AND stream_id > ?' #NEWLINE# txn . execute ( sql , ( user_id , stream_id ) ) #NEWLINE# global_account_data = { row [ 0 ] : json . loads ( row [ 1 ] ) for row in txn . fetchall ( ) } #NEWLINE# sql = 'SELECT room_id, account_data_type, content FROM room_account_data WHERE user_id = ? AND stream_id > ?' #NEWLINE# txn . execute ( sql , ( user_id , stream_id ) ) #NEWLINE# account_data_by_room = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for row in txn . fetchall ( ) : #NEWLINE# #INDENT# room_account_data = account_data_by_room . setdefault ( row [ 0 ] , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# room_account_data [ row [ 1 ] ] = json . loads ( row [ 2 ] ) #NEWLINE# #UNINDENT# return ( global_account_data , account_data_by_room ) #NEWLINE# #UNINDENT# changed = self . _account_data_stream_cache . has_entity_changed ( user_id , int ( stream_id ) ) #NEWLINE# if ( not changed ) : #NEWLINE# #INDENT# return ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return self . runInteraction ( 'get_updated_account_data_for_user' , changed )