diff --git a/controllers/serveController.js b/controllers/serveController.js index 03831bdc..919dab2b 100644 --- a/controllers/serveController.js +++ b/controllers/serveController.js @@ -2,7 +2,7 @@ const lbryApi = require('../helpers/lbryApi.js'); const db = require('../models'); const logger = require('winston'); const getAllFreePublicClaims = require('../helpers/functions/getAllFreePublicClaims.js'); -const isFreePublicClaim = require('../helpers/functions/isFreePublicClaim.js'); +const isFreeClaim = require('../helpers/functions/isFreeClaim.js'); const serveHelpers = require('../helpers/serveHelpers.js'); function checkForLocalAssetByClaimId (claimId, name) { @@ -50,7 +50,7 @@ function getAssetByClaimId (fullClaimId, name) { lbryApi.resolveUri(`${name}#${fullClaimId}`) .then(resolveResult => { // if the claim is free and public, then get it - if (resolveResult.claim && isFreePublicClaim(resolveResult.claim)) { + if (resolveResult.claim && isFreeClaim(resolveResult.claim)) { lbryApi.getClaim(`${name}#${fullClaimId}`) .then(getResult => { let fileInfo = formatGetResultsToFileInfo(getResult); diff --git a/helpers/functions/getAllFreePublicClaims.js b/helpers/functions/getAllFreePublicClaims.js index 3c237bd7..98ab15b7 100644 --- a/helpers/functions/getAllFreePublicClaims.js +++ b/helpers/functions/getAllFreePublicClaims.js @@ -1,4 +1,4 @@ -const isFreePublicClaim = require('./isFreePublicClaim.js'); +const isFreeClaim = require('./isFreeClaim.js'); const lbryApi = require('../lbryApi.js'); const logger = require('winston'); @@ -11,7 +11,7 @@ function filterForFreePublicClaims (claimsListArray) { if (!claim.value) { return false; } - return isFreePublicClaim(claim); + return isFreeClaim(claim); }); return freePublicClaims; } diff --git a/helpers/functions/isFreeClaim.js b/helpers/functions/isFreeClaim.js new file mode 100644 index 00000000..51d9939a --- /dev/null +++ b/helpers/functions/isFreeClaim.js @@ -0,0 +1,11 @@ +const logger = require('winston'); + +module.exports = ({ value }) => { + if (!value.stream.metadata.fee || value.stream.metadata.fee.amount === 0) { + logger.debug('isFreeClaim?', true); + return true; + } else { + logger.debug('isFreePublicClaim?', false); + return false; + } +}; diff --git a/helpers/functions/isFreePublicClaim.js b/helpers/functions/isFreePublicClaim.js deleted file mode 100644 index bceb424e..00000000 --- a/helpers/functions/isFreePublicClaim.js +++ /dev/null @@ -1,12 +0,0 @@ -const logger = require('winston'); -const licenses = ['Creative Commons', 'Public Domain', 'Creative Commons Attribution 4.0 International', 'Creative Commons Attribution-ShareAlike 4.0 International', 'Creative Commons Attribution-NoDerivatives 4.0 International', 'Creative Commons Attribution-NonCommercial 4.0 International', 'Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International', 'Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International']; - -module.exports = ({ value }) => { - if ((licenses.includes(value.stream.metadata.license)) && (!value.stream.metadata.fee || value.stream.metadata.fee.amount === 0)) { - logger.debug('checking isFreePublicClaim...', true); - return true; - } else { - logger.debug('checking isFreePublicClaim...', false); - return false; - } -};