'Get E2E device keys for local users
Args:
query (dict[string, list[string]|None): map from user_id to a list
of devices to query (None for all devices)
Returns:
defer.Deferred: (resolves to dict[string, dict[string, dict]]):
map from user_id -> device_id -> device details'

@defer.inlineCallbacks
def query_local_devices(self, query):

    local_query = []
    result_dict = {}
    for (user_id, device_ids) in query.items():
        if (not self.is_mine_id(user_id)):
            logger.warning('Request    for    keys    for    non-local    user    %s', user_id)
            raise SynapseError(400, 'Not    a    user    here')
        if (not device_ids):
            local_query.append((user_id, None))
        else:
            for device_id in device_ids:
                local_query.append((user_id, device_id))
        result_dict[user_id] = {}
    results = (yield self.store.get_e2e_device_keys(local_query))
    for (user_id, device_keys) in results.items():
        for (device_id, device_info) in device_keys.items():
            r = dict(device_info['keys'])
            r['unsigned'] = {}
            display_name = device_info['device_display_name']
            if (display_name is not None):
                r['unsigned']['device_display_name'] = display_name
            result_dict[user_id][device_id] = r
    defer.returnValue(result_dict)
