@defer.inlineCallbacks
    def _get_interested_parties(self, states):
        room_ids_to_states = {}
        users_to_states = {}
        for state in states:
            events = yield self.store.get_rooms_for_user(state.user_id)
            for e in events:
                room_ids_to_states.setdefault(e.room_id, []).append(state)

            plist = yield self.store.get_presence_list_observers_accepted(state.user_id)
            for u in plist:
                users_to_states.setdefault(u, []).append(state)

            # Always notify self
            users_to_states.setdefault(state.user_id, []).append(state)

        hosts_to_states = {}
        for room_id, states in room_ids_to_states.items():
            local_states = filter(lambda s: self.hs.is_mine_id(s.user_id), states)
            if not local_states:
                continue

            hosts = yield self.store.get_joined_hosts_for_room(room_id)
            for host in hosts:
                hosts_to_states.setdefault(host, []).extend(local_states)

        for user_id, states in users_to_states.items():
            local_states = filter(lambda s: self.hs.is_mine_id(s.user_id), states)
            if not local_states:
                continue

            host = UserID.from_string(user_id).domain
            hosts_to_states.setdefault(host, []).extend(local_states)

        # TODO: de-dup hosts_to_states, as a single host might have multiple
        # of same presence

        defer.returnValue((room_ids_to_states, users_to_states, hosts_to_states))
Add a authentication policy to this response
dataset/ETHPy150Open matrix-org/synapse/synapse/handlers/presence.py/PresenceHandler._get_interested_parties--crossover with--dataset/ETHPy150Open CollabQ/CollabQ/openid/extensions/pape.py/Response.addPolicyURI