2018-04-27 09:54:36 -07:00
|
|
|
const logger = require('winston');
|
2018-06-05 19:34:24 -07:00
|
|
|
const { details, publishing } = require('@config/siteConfig');
|
2018-07-27 11:05:10 -07:00
|
|
|
const createPublishParams = (filePath, name, title, description, license, nsfw, thumbnail, channelName, channelClaimId) => {
|
2018-04-27 09:54:36 -07:00
|
|
|
// provide defaults for title
|
|
|
|
if (title === null || title.trim() === '') {
|
|
|
|
title = name;
|
|
|
|
}
|
|
|
|
// provide default for description
|
|
|
|
if (description === null || description.trim() === '') {
|
|
|
|
description = '';
|
|
|
|
}
|
|
|
|
// provide default for license
|
|
|
|
if (license === null || license.trim() === '') {
|
|
|
|
license = ' '; // default to empty string
|
|
|
|
}
|
2018-07-27 11:05:10 -07:00
|
|
|
// create the basic publish params
|
2018-04-27 09:54:36 -07:00
|
|
|
const publishParams = {
|
|
|
|
name,
|
|
|
|
file_path: filePath,
|
2018-10-31 23:59:01 -04:00
|
|
|
bid : publishing.fileClaimBidAmount,
|
2018-04-27 09:54:36 -07:00
|
|
|
metadata : {
|
|
|
|
description,
|
|
|
|
title,
|
|
|
|
author : details.title,
|
|
|
|
language: 'en',
|
|
|
|
license,
|
|
|
|
nsfw,
|
|
|
|
},
|
|
|
|
claim_address: publishing.primaryClaimAddress,
|
|
|
|
};
|
|
|
|
// add thumbnail to channel if video
|
|
|
|
if (thumbnail) {
|
|
|
|
publishParams['metadata']['thumbnail'] = thumbnail;
|
|
|
|
}
|
2018-07-27 11:05:10 -07:00
|
|
|
// add channel details if publishing to a channel
|
|
|
|
if (channelName && channelClaimId) {
|
|
|
|
publishParams['channel_name'] = channelName;
|
|
|
|
publishParams['channel_id'] = channelClaimId;
|
|
|
|
}
|
|
|
|
// log params
|
2018-05-02 18:16:23 -07:00
|
|
|
logger.debug('publish params:', publishParams);
|
2018-07-27 11:05:10 -07:00
|
|
|
// return
|
2018-04-27 09:54:36 -07:00
|
|
|
return publishParams;
|
|
|
|
};
|
|
|
|
|
2018-07-27 11:05:10 -07:00
|
|
|
module.exports = createPublishParams;
|