diff --git a/oml/item/api.py b/oml/item/api.py index a3a31a2..8599de9 100644 --- a/oml/item/api.py +++ b/oml/item/api.py @@ -247,17 +247,18 @@ def findMetadata(data): elif key == 'id': import user.models items = {} + value = data[key] for u in user.models.User.query.filter_by(peered=True): peer = utils.get_peer(u.id) - if data[key] in peer.library: - h = peer.get_metahash(data[key]) + if value in peer.library: + h = peer.get_metahash(value) if h not in items: - items[h] = peer.library[data[key]].get('meta', {}).copy() + items[h] = peer.library[value].get('meta', {}).copy() items[h]['users'] = [u.id] j = items[h] - for key in [k['id'] for k in settings.config['itemKeys'] if isinstance(k['type'], list)]: - if key in j and not isinstance(j[key], list): - j[key] = [j[key]] if j[key] else [] + for key_ in [k['id'] for k in settings.config['itemKeys'] if isinstance(k['type'], list)]: + if key_ in j and not isinstance(j[key_], list): + j[key_] = [j[key_]] if j[key_] else [] else: items[h]['users'].append(u.id) response['items'] = list(items.values())