diff --git a/helpers/functions/getAllFreePublicClaims.js b/helpers/functions/getAllFreePublicClaims.js index 98ab15b7..b886c477 100644 --- a/helpers/functions/getAllFreePublicClaims.js +++ b/helpers/functions/getAllFreePublicClaims.js @@ -32,7 +32,7 @@ module.exports = (claimName) => { return new Promise((resolve, reject) => { // make a call to the daemon to get the claims list lbryApi - .getClaimsList(claimName) + .getClaimList(claimName) .then(({ claims }) => { logger.debug(`Number of claims: ${claims.length}`); // return early if no claims were found diff --git a/helpers/lbryApi.js b/helpers/lbryApi.js index e7292cdb..a05c268e 100644 --- a/helpers/lbryApi.js +++ b/helpers/lbryApi.js @@ -61,7 +61,7 @@ module.exports = { }); }); }, - getClaimsList (claimName) { + getClaimList (claimName) { logger.debug(`lbryApi >> Getting claim_list for "${claimName}"`); return new Promise((resolve, reject) => { axios diff --git a/helpers/claimModelWrapper.js b/helpers/lbryLocalApi.js similarity index 89% rename from helpers/claimModelWrapper.js rename to helpers/lbryLocalApi.js index 3e355cb1..89079d98 100644 --- a/helpers/claimModelWrapper.js +++ b/helpers/lbryLocalApi.js @@ -2,13 +2,12 @@ const logger = require('winston'); const db = require('../models'); module.exports = { - getLocalClaimsList (name) { + getLocalClaimList (name) { logger.debug(`db.Claim >> Getting claim_list for "${name}"`); return db.Claim.findAll({ name }) .then(result => { logger.debug('db.claim result length', result.length); if (result.length >= 1) { - console.log('there was a result'); result = result.map(claim => { return claim.dataValues; }); @@ -40,8 +39,8 @@ module.exports = { return error; }); }, - createClaimEntryFromLbryResolve (claim) { - logger.debug('db.Claim >> creating claim entry from lbry resolve'); + updateLocalClaimRecordFromResolve (claim) { + logger.debug('db.Claim >> creating claim entry from lbry resolve results'); // parse the resolved data let claimData = {}; claimData['address'] = claim.address; @@ -84,14 +83,14 @@ module.exports = { claimData['valueVersion'] = claim.value.version; } // create search criteria - const searchCriteria = { name: claimData.name, claimId: claimData.claimId }; + const updateCriteria = { name: claimData.name, claimId: claimData.claimId }; // create entry in db - db.upsert(db.Claim, claimData, searchCriteria) - .then(() => { - logger.debug('successfully added data to db.Claim'); + db.Claim.update(claimData, updateCriteria) + .then((rows, result) => { + logger.debug('successfully updated record in db.Claim'); }) .catch(error => { - logger.error('Sequelize findOne error', error); + logger.error('db.Claim.update error', error); }); }, }; diff --git a/helpers/serveHelpers.js b/helpers/serveHelpers.js index c251f1ee..d737bc9c 100644 --- a/helpers/serveHelpers.js +++ b/helpers/serveHelpers.js @@ -118,9 +118,9 @@ module.exports = { return new Promise((resolve, reject) => { logger.debug('getting claim_id from short url'); // use the daemon to check for claims list - lbryApi.getClaimsList(name) + lbryApi.getClaimList(name) .then(({ claims }) => { - logger.debug('Number of claims from getClaimsList:', claims.length); + logger.debug('Number of claims from getClaimList:', claims.length); // if no claims were found, check locally for possible claims if (claims.length === 0) { return checkLocalDbForClaims(name, shortId); @@ -159,7 +159,7 @@ module.exports = { return new Promise((resolve, reject) => { logger.debug('finding short claim id from full claim id'); // get a list of all the claims - lbryApi.getClaimsList(name) + lbryApi.getClaimList(name) // find the smallest possible unique url for this claim .then(({ claims }) => { const shortId = determineShortClaimId(claimId, height, claims); diff --git a/models/claim.js b/models/claim.js index 162a1e50..b6a72a92 100644 --- a/models/claim.js +++ b/models/claim.js @@ -66,18 +66,26 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D type : STRING, default: null, }, + certificateId: { + type : STRING, + default: null, + }, author: { type : STRING, default: null, }, description: { - type : STRING, + type : TEXT('long'), default: null, }, language: { type : STRING, default: null, }, + license: { + type : STRING, + default: null, + }, licenseUrl: { type : STRING, default: null, diff --git a/routes/api-routes.js b/routes/api-routes.js index b8ebea90..a2a6955f 100644 --- a/routes/api-routes.js +++ b/routes/api-routes.js @@ -14,7 +14,7 @@ module.exports = (app, hostedContentPath) => { sendGoogleAnalytics('SERVE', headers, ip, originalUrl); // serve the content lbryApi - .getClaimsList(params.name) + .getClaimList(params.name) .then(claimsList => { postToStats('serve', originalUrl, ip, null, null, 'success'); res.status(200).json(claimsList);