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