spee.ch/server/controllers/api/claim/publish/createPublishParams.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

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');
2018-07-27 20:05:10 +02:00
const createPublishParams = (filePath, name, title, description, license, 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() === '') {
license = ''; // 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,
2018-11-01 04:59:01 +01:00
bid : publishing.fileClaimBidAmount,
2018-04-27 18:54:36 +02: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 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;