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

64 lines
1.6 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');
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,
description,
title,
author: details.title,
languages: ['en'],
license,
license_url: licenseUrl,
tags: [],
2018-04-27 18:54:36 +02:00
claim_address: publishing.primaryClaimAddress,
};
// add thumbnail to channel if video
if (thumbnail) {
publishParams['thumbnail_url'] = thumbnail;
}
if (nsfw) {
2019-05-26 00:00:20 +02:00
publishParams.tags = ['mature'];
2018-04-27 18:54:36 +02:00
}
2018-07-27 20:05:10 +02:00
// add channel details if publishing to a channel
2019-05-24 22:39:46 +02:00
if (channelName && channelClaimId) {
2018-07-27 20:05:10 +02:00
publishParams['channel_id'] = channelClaimId;
2019-05-24 22:39:46 +02:00
publishParams['channel_name'] = channelName;
2018-07-27 20:05:10 +02:00
}
// 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;