get channel data from publish params

This commit is contained in:
Travis Eden 2018-09-17 16:19:38 -04:00
parent 34a66f1968
commit 3935715e29

View file

@ -7,7 +7,6 @@ const deleteFile = require('./deleteFile.js');
const publish = async (publishParams, fileName, fileType) => { const publish = async (publishParams, fileName, fileType) => {
let publishResults; let publishResults;
let channel;
let fileRecord; let fileRecord;
let filePath = publishParams.file_path; let filePath = publishParams.file_path;
let newFile = Boolean(filePath); let newFile = Boolean(filePath);
@ -16,19 +15,8 @@ const publish = async (publishParams, fileName, fileType) => {
publishResults = await publishClaim(publishParams); publishResults = await publishClaim(publishParams);
logger.info(`Successfully published ${publishParams.name} ${fileName}`, publishResults); logger.info(`Successfully published ${publishParams.name} ${fileName}`, publishResults);
// get the channel information const certificateId = publishParams.channel_id || null;
if (publishParams.channel_name) { const channelName = publishParams.channel_name || null;
logger.debug(`this claim was published in channel: ${publishParams.channel_name}`);
channel = await db.Channel.findOne({
where: {
channelName: publishParams.channel_name,
},
});
} else {
channel = null;
}
const certificateId = channel ? channel.channelClaimId : null;
const channelName = channel ? channel.channelName : null;
const claimRecord = await createClaimRecordDataAfterPublish(certificateId, channelName, fileName, fileType, publishParams, publishResults); const claimRecord = await createClaimRecordDataAfterPublish(certificateId, channelName, fileName, fileType, publishParams, publishResults);
const {claimId} = claimRecord; const {claimId} = claimRecord;