diff --git a/server/controllers/api/claim/get/addGetResultsToFileData.js b/server/controllers/api/claim/get/addGetResultsToFileData.js deleted file mode 100644 index b07c556d..00000000 --- a/server/controllers/api/claim/get/addGetResultsToFileData.js +++ /dev/null @@ -1,7 +0,0 @@ -const addGetResultsToFileData = (fileInfo, getResult) => { - fileInfo.fileName = getResult.file_name; - fileInfo.filePath = getResult.download_path; - return fileInfo; -}; - -module.exports = addGetResultsToFileData; diff --git a/server/controllers/api/claim/get/createFileData.js b/server/controllers/api/claim/get/createFileData.js index d7f69137..00594ea5 100644 --- a/server/controllers/api/claim/get/createFileData.js +++ b/server/controllers/api/claim/get/createFileData.js @@ -1,14 +1,11 @@ -const createFileData = ({ name, claimId, outpoint, height, address, nsfw, contentType }) => { +const createFileData = ({ name, claimId, outpoint, contentType: fileType }, { file_name: fileName, download_path: filePath }) => { return { name, claimId, outpoint, - height, - address, - fileName: '', - filePath: '', - fileType: contentType, - nsfw, + fileName, + filePath, + fileType, }; }; diff --git a/server/controllers/api/claim/get/index.js b/server/controllers/api/claim/get/index.js index f0a76d71..0d33b7a3 100644 --- a/server/controllers/api/claim/get/index.js +++ b/server/controllers/api/claim/get/index.js @@ -1,5 +1,4 @@ const { getClaim } = require('../../../../lbrynet'); -const addGetResultsToFileData = require('./addGetResultsToFileData.js'); const createFileData = require('./createFileData.js'); const { handleErrorResponse } = require('../../../utils/errorHandlers.js'); const db = require('../../../../models'); @@ -13,15 +12,11 @@ const db = require('../../../../models'); const claimGet = ({ ip, originalUrl, params }, res) => { const name = params.name; const claimId = params.claimId; - let fileData; let resolveResult; let getResult; - let message; - let completed; // resolve the claim db.Claim.resolveClaim(name, claimId) .then(result => { - // make sure a claim actually exists at that uri if (!result) { throw new Error('No matching uri found in Claim table'); } @@ -30,13 +25,14 @@ const claimGet = ({ ip, originalUrl, params }, res) => { }) .then(result => { getResult = result; - fileData = createFileData(resolveResult); - fileData = addGetResultsToFileData(fileData, getResult); - const upsertCriteria = { name, claimId}; - return db.upsert(db.File, fileData, upsertCriteria, 'File'); }) .then(() => { - ({ message, completed } = getResult); + const fileData = createFileData(resolveResult, getResult); + const upsertCriteria = { name, claimId}; + return db.upsert(db.File, fileData, upsertCriteria, 'File') + }) + .then(() => { + const { message, completed } = getResult; res.status(200).json({ success: true, message,