Resolve channels #150

Merged
bones7242 merged 23 commits from resolve-channels into master 2017-08-25 18:35:40 +02:00
Showing only changes of commit bcf0484b5b - Show all commits

View file

@ -20,15 +20,24 @@ function checkForLocalAssetByClaimId (claimId, name) {
}); });
} }
function formatGetResultsToFileInfo ({ name, claim_id, outpoint, file_name, download_path, mime_type, metadata }) { function addGetResultsToFileRecord (fileInfo, getResult) {
fileInfo.fileName = getResult.file_name;
fileInfo.filePath = getResult.download_path;
fileInfo.fileType = getResult.mime_type;
return fileInfo;
}
function createFileRecord ({ name, claimId, outpoint, height, address, nsfw }) {
return { return {
name, name,
claimId : claim_id, claimId,
outpoint, outpoint,
fileName: file_name, height,
filePath: download_path, address,
fileType: mime_type, fileName: '',
nsfw : metadata.stream.metadata.nsfw, filePath: '',
fileType: '',
nsfw,
}; };
} }
@ -57,9 +66,8 @@ function getAssetByClaimId (fullClaimId, name) {
lbryApi.getClaim(`${name}#${fullClaimId}`) lbryApi.getClaim(`${name}#${fullClaimId}`)
.then(getResult => { .then(getResult => {
logger.debug('getResult >>', getResult); logger.debug('getResult >>', getResult);
fileRecord = formatGetResultsToFileInfo(getResult); fileRecord = createFileRecord(resolveResult);
fileRecord['address'] = (resolveResult.address || 0); fileRecord = addGetResultsToFileRecord(fileRecord, getResult);
fileRecord['height'] = resolveResult.height;
// insert a record in the File table & Update Claim table // insert a record in the File table & Update Claim table
return db.File.create(fileRecord); return db.File.create(fileRecord);
}) })