From 2e45314610af8a9053f59bbfca80abd2fe57c3de Mon Sep 17 00:00:00 2001 From: Shawn Date: Wed, 10 Oct 2018 12:19:51 -0500 Subject: [PATCH] Fix remaining chainquery exceptions and bad logic --- server/controllers/api/claim/data/index.js | 2 +- server/controllers/api/claim/shortId/index.js | 2 +- server/controllers/assets/utils/getClaimIdAndServeAsset.js | 4 ++-- server/controllers/utils/getClaimId.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/controllers/api/claim/data/index.js b/server/controllers/api/claim/data/index.js index 482be972..b72751a4 100644 --- a/server/controllers/api/claim/data/index.js +++ b/server/controllers/api/claim/data/index.js @@ -16,7 +16,7 @@ const claimData = async ({ ip, originalUrl, body, params }, res) => { try { let resolvedClaim = await chainquery.claim.queries.resolveClaim(claimName, claimId).catch(() => {}); - + if(!resolvedClaim) { resolvedClaim = await db.Claim.resolveClaim(claimName, claimId); } diff --git a/server/controllers/api/claim/shortId/index.js b/server/controllers/api/claim/shortId/index.js index 34bf6d8e..e8d820e2 100644 --- a/server/controllers/api/claim/shortId/index.js +++ b/server/controllers/api/claim/shortId/index.js @@ -10,7 +10,7 @@ const chainquery = require('chainquery'); const claimShortId = async ({ ip, originalUrl, body, params }, res) => { try { - let shortId = await chainquery.claim.queries.getShortClaimIdFromLongClaimId(params.longId, params.name); + let shortId = await chainquery.claim.queries.getShortClaimIdFromLongClaimId(params.longId, params.name).catch(() => {}); if(shortId === null) { shortId = await db.Claim.getShortClaimIdFromLongClaimId(params.longId, params.name); diff --git a/server/controllers/assets/utils/getClaimIdAndServeAsset.js b/server/controllers/assets/utils/getClaimIdAndServeAsset.js index cca00f74..4e4cbafe 100644 --- a/server/controllers/assets/utils/getClaimIdAndServeAsset.js +++ b/server/controllers/assets/utils/getClaimIdAndServeAsset.js @@ -25,11 +25,11 @@ const getClaimIdAndServeAsset = (channelName, channelClaimId, claimName, claimId }) .then(claim => { if (!claim) { - logger.debug('Full claim id:', fullClaimId); + logger.debug('Full claim id:', claimId); return db.Claim.findOne({ where: { name : claimName, - claimId: fullClaimId, + claimId, }, }); } diff --git a/server/controllers/utils/getClaimId.js b/server/controllers/utils/getClaimId.js index 3eab179e..76ea1f47 100644 --- a/server/controllers/utils/getClaimId.js +++ b/server/controllers/utils/getClaimId.js @@ -28,7 +28,7 @@ const getClaimId = async (channelName, channelClaimId, name, claimId) => { } else { let claimIdResult = await chainquery.claim.queries.getLongClaimId(name, claimId); - if(claimIdResult === null) { + if(!claimIdResult) { claimIdResult = await db.Claim.getLongClaimId(name, claimId); }