#NEWLINE# @ defer . inlineCallbacks #NEWLINE# def _get_interested_parties( self , states ) : #NEWLINE# #INDENT# 'Given a list of states return which entities (rooms, users, servers)\n        are interested in the given states.\n\n        Returns:\n            3-tuple: `(room_ids_to_states, users_to_states, hosts_to_states)`,\n            with each item being a dict of `entity_name` -> `[UserPresenceState]`\n        ' #NEWLINE# room_ids_to_states = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# users_to_states = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for state in states : #NEWLINE# #INDENT# events = ( yield self . store . get_rooms_for_user ( state . user_id ) ) #NEWLINE# for e in events : #NEWLINE# #INDENT# room_ids_to_states . setdefault ( e . room_id , [ ] ) . append ( state ) #NEWLINE# #UNINDENT# plist = ( yield self . store . get_presence_list_observers_accepted ( state . user_id ) ) #NEWLINE# for u in plist : #NEWLINE# #INDENT# users_to_states . setdefault ( u , [ ] ) . append ( state ) #NEWLINE# #UNINDENT# users_to_states . setdefault ( state . user_id , [ ] ) . append ( state ) #NEWLINE# #UNINDENT# hosts_to_states = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( room_id , states ) in room_ids_to_states . items ( ) : #NEWLINE# #INDENT# local_states = filter ( ( lambda s : self . hs . is_mine_id ( s . user_id ) ) , states ) #NEWLINE# if ( not local_states ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# hosts = ( yield self . store . get_joined_hosts_for_room ( room_id ) ) #NEWLINE# for host in hosts : #NEWLINE# #INDENT# hosts_to_states . setdefault ( host , [ ] ) . extend ( local_states ) #NEWLINE# #UNINDENT# #UNINDENT# for ( user_id , states ) in users_to_states . items ( ) : #NEWLINE# #INDENT# local_states = filter ( ( lambda s : self . hs . is_mine_id ( s . user_id ) ) , states ) #NEWLINE# if ( not local_states ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# host = UserID . from_string ( user_id ) . domain #NEWLINE# hosts_to_states . setdefault ( host , [ ] ) . extend ( local_states ) #NEWLINE# #UNINDENT# defer . returnValue ( ( room_ids_to_states , users_to_states , hosts_to_states ) )