spee.ch/server/controllers/api/claim/publish/createPublishParams.js
Tom 1b069ba2a1 WIP - 0.37 SDK changes
Needs the metadata sub object removed, everything should be passed at the publish level - no need to set protobuf metadata directly.

Thumbnail > thumbnail_url, licenseURL > license_url and possibly a few others.
changes

fix: 1 of many
fix 2 of many
fix: 3 of many
fix: 4 of many
more fixes
fix license
fix thumb
remove tags
fix thumb?
remove log
fix
fix txid
2019-05-24 13:09:07 -04:00

62 lines
1.5 KiB
JavaScript

const logger = require('winston');
const { details, publishing } = require('@config/siteConfig');
const createPublishParams = (
filePath,
name,
title,
description,
license,
licenseUrl,
nsfw,
thumbnail,
channelName,
channelClaimId
) => {
// 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
}
// provide default for licenseUrl
if (licenseUrl === null || licenseUrl.trim() === '') {
licenseUrl = ''; // default to empty string
}
// create the basic publish params
const publishParams = {
name,
file_path: filePath,
bid: publishing.fileClaimBidAmount,
description,
title,
author: details.title,
languages: ['en'],
license,
license_url: licenseUrl,
tags: [],
claim_address: publishing.primaryClaimAddress,
};
// add thumbnail to channel if video
if (thumbnail) {
publishParams['thumbnail_url'] = thumbnail;
}
if (nsfw) {
publishParams.tags.push = 'mature';
}
// add channel details if publishing to a channel
if (channelClaimId) {
publishParams['channel_id'] = channelClaimId;
}
// log params
logger.debug('publish params:', publishParams);
// return
return publishParams;
};
module.exports = createPublishParams;