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) => {
let publishResults;
let channel;
let fileRecord;
let filePath = publishParams.file_path;
let newFile = Boolean(filePath);
@ -16,19 +15,8 @@ const publish = async (publishParams, fileName, fileType) => {
publishResults = await publishClaim(publishParams);
logger.info(`Successfully published ${publishParams.name} ${fileName}`, publishResults);
// get the channel information
if (publishParams.channel_name) {
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 certificateId = publishParams.channel_id || null;
const channelName = publishParams.channel_name || null;
const claimRecord = await createClaimRecordDataAfterPublish(certificateId, channelName, fileName, fileType, publishParams, publishResults);
const {claimId} = claimRecord;