Adds License and LicenseUrl to AssetInfo and Publish/Edit Forms #935

Merged
jessopb merged 3 commits from licenseDev2 into master 2019-02-26 09:44:03 +01:00
21 changed files with 312 additions and 104 deletions

View file

@ -1,6 +1,7 @@
select {
margin: 0;
display: inline-block;
background: $base-color;
background: $background-color;
border: 0;
color: $text-color;
}

View file

@ -7,9 +7,6 @@ const ChannelSelectDropdown = ({ selectedChannel, handleSelection, loggedInChann
id='channel-name-select'
value={selectedChannel}
onChange={handleSelection}>
{ loggedInChannelName && (
<option value={loggedInChannelName} >{loggedInChannelName}</option>
)}
<option value={LOGIN}>Existing</option>
<option value={CREATE}>New</option>
</select>

View file

@ -1,23 +1,28 @@
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
import React from 'react';
import RowLabeled from '@components/RowLabeled';
import Label from '@components/Label';
import { LICENSES } from '@clientConstants/publish_license_urls';
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
const PublishLicenseInput = ({ handleSelect }) => {
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
const PublishLicenseInput = ({ handleSelect, license }) => {
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
return (
<RowLabeled
label={
<Label value={'License:'} />
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
<Label value={'License'} />
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
}
content={
<select
type='text'
name='license'
id='publish-license'
value={license}
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
onChange={handleSelect}
>
<option value=''>Unspecified</option>
<option value='Public Domain'>Public Domain</option>
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
<option value='Creative Commons'>Creative Commons</option>
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
{
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
LICENSES.map(function(item, i){
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
return <option key={item + 'license key'} value={item}>{item}</option>;
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
})
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
}
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
</select>
}
/>

skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`
skhameneh commented 2019-02-26 06:50:18 +01:00 (Migrated from github.com)
Review

We should have a more suitable alias to use instead of the ../../

We should have a more suitable alias to use instead of the `../../`

View file

@ -0,0 +1,32 @@
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
import React from 'react';
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
import RowLabeled from '@components/RowLabeled';
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
import Label from '@components/Label';
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
import { CC_LICENSES } from '@clientConstants/publish_license_urls';
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
const PublishLicenseUrlInput = ({ handleSelect, licenseUrl }) => {
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
return (
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
<RowLabeled
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
label={
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
<Label value={'License Url'} />
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
}
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
content={
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
<select
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
type='text'
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
name='licenseUrl'
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
id='publish-license-url'
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
value={licenseUrl}
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
onChange={handleSelect}
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
>
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
<option value=''>Unspecified</option>
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
{
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
CC_LICENSES.map(function(item, i){
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
return <option key={item.url} value={item.url}>{item.value}</option>
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
})
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
}
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
</select>
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
}
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
/>
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
);
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
};
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias
export default PublishLicenseUrlInput;
skhameneh commented 2019-02-26 06:50:29 +01:00 (Migrated from github.com)
Review

alias

alias

View file

@ -0,0 +1,33 @@
export const CC_LICENSES = [
{
value: 'CC Attr. 4.0 Int',
url: 'https://creativecommons.org/licenses/by/4.0/legalcode',
},
{
value: 'CC Attr-ShareAlike 4.0 Int',
url: 'https://creativecommons.org/licenses/by-sa/4.0/legalcode',
},
{
value: 'CC Attr-NoDerivatives 4.0 Int',
url: 'https://creativecommons.org/licenses/by-nd/4.0/legalcode',
},
{
value: 'CC Attr-NonComm 4.0 Int',
url: 'https://creativecommons.org/licenses/by-nc/4.0/legalcode',
},
{
value: 'CC Attr-NonComm-ShareAlike 4.0 Int',
url: 'https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode',
},
{
value: 'CC Attr-NonComm-NoDerivatives 4.0 Int',
url: 'https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode',
},
];
export const LICENSES = ['Public Domain', 'Other', 'Copyright', 'Creative Commons'];
export const PUBLIC_DOMAIN = 'Public Domain';
export const OTHER = 'other';
export const COPYRIGHT = 'copyright';
export const CREATIVE_COMMONS = 'Creative Commons';

View file

@ -7,7 +7,7 @@ import AssetShareButtons from '@components/AssetShareButtons';
import ClickToCopy from '@components/ClickToCopy';
import siteConfig from '@config/siteConfig.json';
import createCanonicalLink from '@globalutils/createCanonicalLink';
import AssetInfoFooter from '../../components/AssetInfoFooter/index';
import AssetInfoFooter from '@components/AssetInfoFooter/index';
import { createPermanentURI } from '@clientutils/createPermanentURI';
import ReactMarkdown from 'react-markdown';
@ -18,7 +18,20 @@ class AssetInfo extends React.Component {
render () {
const { editable, asset } = this.props;
const { claimViews, claimData } = asset;
const { channelName, claimId, channelShortId, description, name, fileExt, contentType, host, certificateId } = claimData;
const {
channelName,
claimId,
channelShortId,
description,
name,
fileExt,
contentType,
host,
certificateId,
license,
licenseUrl,
transactionTime
} = claimData;
const canonicalUrl = createCanonicalLink({ asset: { ...claimData, shortId: asset.shortId }});
const assetCanonicalUrl = `${host}${canonicalUrl}`;
@ -55,7 +68,7 @@ class AssetInfo extends React.Component {
{editable && (
<RowLabeled
label={<Label value={'Edit'} />}
content={<Link to={`/edit${canonicalUrl}`}>{name}</Link>}
content={<Link className='link--primary' to={`/edit${canonicalUrl}`}>{name}</Link>}
/>
)}
{channelName && (
@ -71,6 +84,7 @@ class AssetInfo extends React.Component {
}
/>
)}
<SpaceBetween>
{claimViews ? (
<RowLabeled
label={
@ -83,7 +97,22 @@ class AssetInfo extends React.Component {
}
/>
) : null}
{license && (
<RowLabeled
label={
<Label value={'License'} />
}
content={
<div className='text'>
{licenseUrl ? (
<a className={'link--primary'} href={licenseUrl} target={'_blank'}>{license}</a>
) : (
<span>{license}</span> )}
</div>
}
/>
)}
</SpaceBetween>
<RowLabeled
label={
<Label value={'Share'} />

View file

@ -7,6 +7,7 @@ const mapStateToProps = ({ publish }) => {
showMetadataInputs: publish.showMetadataInputs,
description: publish.metadata.description,
license: publish.metadata.license,
licenseUrl: publish.metadata.licenseUrl,
nsfw: publish.metadata.nsfw,
isUpdate: publish.isUpdate,
};
@ -17,10 +18,13 @@ const mapDispatchToProps = dispatch => {
onMetadataChange: (name, value) => {
dispatch(updateMetadata(name, value));
},
onToggleMetadataInputs: (value) => {
onToggleMetadataInputs: value => {
dispatch(toggleMetadataInputs(value));
},
};
};
export default connect(mapStateToProps, mapDispatchToProps)(View);
export default connect(
mapStateToProps,
mapDispatchToProps
)(View);

View file

@ -1,9 +1,9 @@
import React from 'react';
import PublishDescriptionInput from '@components/PublishDescriptionInput';
import PublishLicenseInput from '@components/PublishLicenseInput';
import PublishLicenseUrlInput from '@components/PublishLicenseUrlInput';
import PublishNsfwInput from '@components/PublishNsfwInput';
import ButtonSecondary from '@components/ButtonSecondary';
import Row from '@components/Row';
class PublishMetadataInputs extends React.Component {
constructor (props) {
@ -25,22 +25,32 @@ class PublishMetadataInputs extends React.Component {
const name = event.target.name;
const selectedOption = event.target.selectedOptions[0].value;
this.props.onMetadataChange(name, selectedOption);
if (name === 'license' && selectedOption !== 'Creative Commons'){
this.props.onMetadataChange('licenseUrl', '');
}
}
render () {
const { showMetadataInputs, description, isUpdate, nsfw } = this.props;
const { showMetadataInputs, description, isUpdate, nsfw, license, licenseUrl } = this.props;
return (
<div>
{(showMetadataInputs || isUpdate) && (
<React.Fragment>
<PublishDescriptionInput
description={this.props.description}
description={description}
handleInput={this.handleInput}
/>
<PublishLicenseInput
handleSelect={this.handleSelect}
license={license}
/>
{ (this.props.license === 'Creative Commons') && (
<PublishLicenseUrlInput
handleSelect={this.handleSelect}
licenseUrl={licenseUrl}
/>
)}
<PublishNsfwInput
nsfw={this.props.nsfw}
nsfw={nsfw}
handleInput={this.handleInput}
/>
</React.Fragment>

View file

@ -9,7 +9,7 @@ class EditPage extends React.Component {
onHandleShowPageUri(match.params);
setUpdateTrue();
if (asset) {
['title', 'description', 'license', 'nsfw'].forEach(meta => updateMetadata(meta, asset.claimData[meta]));
['title', 'description', 'license', 'licenseUrl', 'nsfw'].forEach(meta => updateMetadata(meta, asset.claimData[meta]));
}
setHasChanged(false);
}

View file

@ -39,6 +39,7 @@ const initialState = {
title: '',
description: '',
license: '',
licenseUrl: '',
nsfw: false,
},
isUpdate: false,
@ -51,7 +52,8 @@ const initialState = {
export default function(state = initialState, action) {
switch (action.type) {
case actions.FILE_SELECTED:
return Object.assign({}, state.isUpdate ? state : initialState, { // note: clears to initial state
return Object.assign({}, state.isUpdate ? state : initialState, {
// note: clears to initial state
file: action.data,
hasChanged: true,
});
@ -112,4 +114,4 @@ export default function (state = initialState, action) {
default:
return state;
}
};
}

View file

@ -1,9 +1,16 @@
export const createPublishMetadata = (claim, { type }, { title, description, license, nsfw }, publishInChannel, selectedChannel) => {
export const createPublishMetadata = (
claim,
{ type },
{ title, description, license, licenseUrl, nsfw },
publishInChannel,
selectedChannel
) => {
let metadata = {
name: claim,
title,
description,
license,
licenseUrl,
nsfw,
type,
};

View file

@ -6,7 +6,7 @@ const {
const getterMethods = {
generated_extension() {
logger.info('trying to generate extension', this.content_type);
logger.debug('trying to generate extension', this.content_type);
if (customFileExtensions.hasOwnProperty(this.content_type)) {
return customFileExtensions[this.content_type];
} else {
@ -136,6 +136,14 @@ export default (sequelize, { BOOLEAN, DATE, DECIMAL, ENUM, INTEGER, STRING, TEXT
type: STRING,
set() {},
},
license: {
type: STRING,
set() {},
},
license_url: {
type: STRING,
set() {},
},
},
{
freezeTableName: true,

View file

@ -1,8 +1,10 @@
const chainquery = require('chainquery').default;
const logger = require('winston');
const getClaimData = require('server/utils/getClaimData');
const { returnPaginatedChannelClaims } = require('./channelPagination.js');
const getChannelClaims = async (channelName, channelLongId, page) => {
logger.debug(`getChannelClaims: ${channelName}, ${channelLongId}, ${page}`);
let channelShortId = await chainquery.claim.queries.getShortClaimIdFromLongClaimId(
channelLongId,
channelName

View file

@ -1,6 +1,17 @@
const logger = require('winston');
const { details, publishing } = require('@config/siteConfig');
const createPublishParams = (filePath, name, title, description, license, nsfw, thumbnail, channelName, channelClaimId) => {
const createPublishParams = (
filePath,
name,
title,
description,
license,
licenseUrl,
nsfw,
thumbnail,
channelName,
channelClaimId
) => {
// provide defaults for title
if (title === null || title.trim() === '') {
title = name;
@ -13,6 +24,10 @@ const createPublishParams = (filePath, name, title, description, license, nsfw,
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,
@ -24,6 +39,7 @@ const createPublishParams = (filePath, name, title, description, license, nsfw,
author: details.title,
language: 'en',
license,
licenseUrl,
nsfw,
},
claim_address: publishing.primaryClaimAddress,

View file

@ -1,7 +1,7 @@
const logger = require('winston');
const { details, publishing } = require('@config/siteConfig');
const createThumbnailPublishParams = (thumbnailFilePath, claimName, license, nsfw) => {
const createThumbnailPublishParams = (thumbnailFilePath, claimName, license, licenseUrl, nsfw) => {
if (!thumbnailFilePath) {
return;
}
@ -17,6 +17,7 @@ const createThumbnailPublishParams = (thumbnailFilePath, claimName, license, nsf
author: details.title,
language: 'en',
license,
licenseUrl,
nsfw,
},
claim_address: publishing.primaryClaimAddress,

View file

@ -1,10 +1,15 @@
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
const logger = require('winston');
const { details: { host }, publishing: { disabled, disabledMessage } } = require('@config/siteConfig');
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
const {
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
details: { host },
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
publishing: { disabled, disabledMessage },
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
} = require('@config/siteConfig');
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
const { sendGATimingEvent } = require('../../../../utils/googleAnalytics.js');
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
const { sendGATimingEvent } = require('server/utils/googleAnalytics.js');
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
const isApprovedChannel = require('@globalutils/isApprovedChannel');
const { publishing: { publishOnlyApproved, approvedChannels } } = require('@config/siteConfig');
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
const {
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
publishing: { publishOnlyApproved, approvedChannels },
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
} = require('@config/siteConfig');
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
@ -55,6 +60,7 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
fileType,
gaStartTime,
license,
licenseUrl,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
name,
nsfw,
thumbnail,
@ -69,8 +75,24 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
// validate the body and files of the request
try {
// validateApiPublishRequest(body, files);
({name, nsfw, license, title, description, thumbnail} = parsePublishApiRequestBody(body));
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
({fileName, filePath, fileExtension, fileType, thumbnailFileName, thumbnailFilePath, thumbnailFileType} = parsePublishApiRequestFiles(files));
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
({
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
name,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
nsfw,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
license,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
licenseUrl,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
title,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
description,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
thumbnail,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
} = parsePublishApiRequestBody(body));
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
({
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
fileName,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
filePath,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
fileExtension,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
fileType,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
thumbnailFileName,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
thumbnailFilePath,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
thumbnailFileType,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
} = parsePublishApiRequestFiles(files));
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
({ channelName, channelId, channelPassword } = body);
} catch (error) {
return res.status(400).json({ success: false, message: error.message });
@ -88,8 +110,19 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
return Promise.all([
checkClaimAvailability(name),
createPublishParams(filePath, name, title, description, license, nsfw, thumbnail, channelName, channelClaimId),
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
createThumbnailPublishParams(thumbnailFilePath, name, license, nsfw),
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
createPublishParams(
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
filePath,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
name,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
title,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
description,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
license,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
licenseUrl,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
nsfw,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
thumbnail,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
channelName,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
channelClaimId
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
),
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
createThumbnailPublishParams(thumbnailFilePath, name, license, licenseUrl, nsfw),
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
]);
})
.then(([claimAvailable, publishParams, thumbnailPublishParams]) => {
@ -113,9 +146,15 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
({ claimId } = claimData);
if (channelName) {
return chainquery.claim.queries.getShortClaimIdFromLongClaimId(claimData.certificateId, channelName);
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
logger.info(`api/claim/publish: claimData.certificateId ${claimData.certificateId}`);
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
return chainquery.claim.queries.getShortClaimIdFromLongClaimId(
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
claimData.certificateId,
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
channelName
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
);
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
} else {
return chainquery.claim.queries.getShortClaimIdFromLongClaimId(claimId, name, claimData).catch(() => {
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
return chainquery.claim.queries
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
.getShortClaimIdFromLongClaimId(claimId, name, claimData)
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
.catch(() => {
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
return claimId.slice(0, 1);
});
}

skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?
skhameneh commented 2019-02-26 06:53:38 +01:00 (Migrated from github.com)
Review

Would you mind cleaning up this path while you're here?

Would you mind cleaning up this path while you're here?

View file

@ -1,15 +1,26 @@
const parsePublishApiRequestBody = ({name, nsfw, license, title, description, thumbnail}) => {
const parsePublishApiRequestBody = ({
name,
nsfw,
license,
licenseUrl,
title,
description,
thumbnail,
}) => {
// validate name
if (!name) {
throw new Error('no name field found in request');
}
const invalidNameCharacters = /[^A-Za-z0-9,-]/.exec(name);
if (invalidNameCharacters) {
throw new Error('The claim name you provided is not allowed. Only the following characters are allowed: A-Z, a-z, 0-9, and "-"');
throw new Error(
'The claim name you provided is not allowed. Only the following characters are allowed: A-Z, a-z, 0-9, and "-"'
);
}
// optional parameters
nsfw = (nsfw === 'true');
nsfw = nsfw === 'true';
license = license || null;
licenseUrl = licenseUrl || null;
title = title || null;
description = description || null;
thumbnail = thumbnail || null;
@ -18,6 +29,7 @@ const parsePublishApiRequestBody = ({name, nsfw, license, title, description, th
name,
nsfw,
license,
licenseUrl,
title,
description,
thumbnail,

View file

@ -19,10 +19,11 @@ const createCanonicalLink = require('@globalutils/createCanonicalLink');
route to update a claim through the daemon
*/
const updateMetadata = ({ nsfw, license, title, description }) => {
const updateMetadata = ({ nsfw, license, licenseUrl, title, description }) => {
const update = {};
if (nsfw) update['nsfw'] = nsfw;
if (license) update['license'] = license;
if (licenseUrl) update['license_url'] = licenseUrl;
if (title) update['title'] = title;
if (description) update['description'] = description;
return update;
@ -65,6 +66,7 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res)
thumbnail,
fileExtension,
license,
licenseUrl,
name,
nsfw,
thumbnailFileName,
@ -127,10 +129,11 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res)
description: claimRecord.description,
nsfw: claimRecord.nsfw,
license: claimRecord.license,
licenseUrl: claimRecord.license_url,
language: 'en',
author: details.title,
},
updateMetadata({ title, description, nsfw, license })
updateMetadata({ title, description, nsfw, license, licenseUrl })
);
const publishParams = {
name,

View file

@ -1,10 +1,12 @@
const logger = require('winston');
const transformImage = require('./transformImage');
const isValidQueryObject = require('../../../utils/isValidQueryObj');
const isValidQueryObject = require('server/utils/isValidQueryObj');
const {
serving: { dynamicFileSizing },
} = require('@config/siteConfig');
const { enabled: dynamicEnabled } = dynamicFileSizing;
const serveFile = async ({ filePath, fileType }, res, originalUrl) => {
const queryObject = {};
// TODO: replace quick/dirty try catch with better practice

View file

@ -59,5 +59,8 @@ module.exports = async (data, chName = null, chShortId = null) => {
host,
pending: Boolean(dataVals.height === 0),
blocked: blocked,
license: dataVals.license,
licenseUrl: dataVals.license_url,
transactionTime: dataVals.transaction_time,
};
};

View file

@ -39,6 +39,9 @@ module.exports = () => {
moduleAliases['@clientutils'] = resolve(`${DEFAULT_ROOT}/utils`);
// moduleAliases['@serverutils'] = resolve('server/utils');
// aliases for constants
moduleAliases['@clientConstants'] = resolve(`${DEFAULT_ROOT}/constants`);
// create specific aliases for locally defined components in the following folders
moduleAliases = addAliasesForCustomComponentFolder('containers', moduleAliases);
moduleAliases = addAliasesForCustomComponentFolder('components', moduleAliases);
@ -53,7 +56,6 @@ module.exports = () => {
moduleAliases['@sagas'] = resolve(`${DEFAULT_ROOT}/sagas`);
moduleAliases['@app'] = resolve(`${DEFAULT_ROOT}/app.js`);
// return finished aliases
return moduleAliases;
};