diff --git a/lib/share.js b/lib/share.js index 930ce8a..5103392 100644 --- a/lib/share.js +++ b/lib/share.js @@ -60,8 +60,8 @@ export function findMatchesAsync(share) { console.log(match) if (match.id) { models.match.create({ - trackId: share.albumName ? share.id : null, - albumId: share.albumName ? null : share.id, + trackId: share.$modelOptions.name.singular == 'track' ? share.id : null, + albumId: share.$modelOptions.name.singular == 'album' ? share.id : null, externalId: match.id, service: match.service, name: match.name, @@ -72,8 +72,8 @@ export function findMatchesAsync(share) { }); } else { models.match.create({ - trackId: share.trackId ? share.id : null, - albumId: share.albumId ? share.id : null, + trackId: share.$modelOptions.name.singular == 'track' ? share.id : null, + albumId: share.$modelOptions.name.singular == 'album' ? share.id : null, externalId: null, service: match.service, name: null,