commit
68d2f303c1
15 changed files with 173 additions and 146 deletions
|
@ -188,8 +188,8 @@ inquirer
|
||||||
.post('http://localhost:5279', {
|
.post('http://localhost:5279', {
|
||||||
method: 'channel_new',
|
method: 'channel_new',
|
||||||
params: {
|
params: {
|
||||||
channel_name: thumbnailChannelDefault,
|
name: thumbnailChannelDefault,
|
||||||
amount: channelBid,
|
bid: channelBid,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
@ -197,7 +197,6 @@ inquirer
|
||||||
if (response.data.error) {
|
if (response.data.error) {
|
||||||
throw new Error(response.data.error.message);
|
throw new Error(response.data.error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
thumbnailChannel = thumbnailChannelDefault;
|
thumbnailChannel = thumbnailChannelDefault;
|
||||||
thumbnailChannelId = response.data.result.claim_id;
|
thumbnailChannelId = response.data.result.claim_id;
|
||||||
siteConfig['publishing']['thumbnailChannel'] = thumbnailChannel;
|
siteConfig['publishing']['thumbnailChannel'] = thumbnailChannel;
|
||||||
|
@ -237,7 +236,9 @@ inquirer
|
||||||
'\nIt\'s a good idea to BACK UP YOUR MASTER PASSWORD \nin "/site/private/authConfig.json" so that you don\'t lose \ncontrol of your channel.'
|
'\nIt\'s a good idea to BACK UP YOUR MASTER PASSWORD \nin "/site/private/authConfig.json" so that you don\'t lose \ncontrol of your channel.'
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('\nNext step: run "npm run start" to build and start your server!');
|
console.log(
|
||||||
|
'\nNext step: run "npm run build" (or "npm run dev") to compiles, and "npm run start" to start your server!'
|
||||||
|
);
|
||||||
console.log(
|
console.log(
|
||||||
'If you want to change any settings, you can edit the files in the "/site" folder.'
|
'If you want to change any settings, you can edit the files in the "/site" folder.'
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import {connect} from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {updateMetadata} from '../../actions/publish';
|
import { updateMetadata } from '../../actions/publish';
|
||||||
import View from './view';
|
import View from './view';
|
||||||
|
|
||||||
const mapStateToProps = ({ publish }) => {
|
const mapStateToProps = ({ publish }) => {
|
||||||
|
@ -16,4 +16,7 @@ const mapDispatchToProps = dispatch => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(View);
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(View);
|
||||||
|
|
|
@ -40,7 +40,7 @@ const initialState = {
|
||||||
description: '',
|
description: '',
|
||||||
license: '',
|
license: '',
|
||||||
licenseUrl: '',
|
licenseUrl: '',
|
||||||
nsfw: false,
|
tags: [],
|
||||||
},
|
},
|
||||||
isUpdate: false,
|
isUpdate: false,
|
||||||
hasChanged: false,
|
hasChanged: false,
|
||||||
|
|
|
@ -9,11 +9,22 @@ import { selectShowState, selectAsset } from '../selectors/show';
|
||||||
import { validateChannelSelection, validateNoPublishErrors } from '../utils/validate';
|
import { validateChannelSelection, validateNoPublishErrors } from '../utils/validate';
|
||||||
import { createPublishMetadata, createPublishFormData, createThumbnailUrl } from '../utils/publish';
|
import { createPublishMetadata, createPublishFormData, createThumbnailUrl } from '../utils/publish';
|
||||||
import { makePublishRequestChannel } from '../channels/publish';
|
import { makePublishRequestChannel } from '../channels/publish';
|
||||||
|
// yep
|
||||||
function * publishFile (action) {
|
function* publishFile(action) {
|
||||||
const { history } = action.data;
|
const { history } = action.data;
|
||||||
const publishState = yield select(selectPublishState);
|
const publishState = yield select(selectPublishState);
|
||||||
const { publishInChannel, selectedChannel, file, claim, metadata, thumbnailChannel, thumbnailChannelId, thumbnail, isUpdate, error: publishToolErrors } = publishState;
|
const {
|
||||||
|
publishInChannel,
|
||||||
|
selectedChannel,
|
||||||
|
file,
|
||||||
|
claim,
|
||||||
|
metadata,
|
||||||
|
thumbnailChannel,
|
||||||
|
thumbnailChannelId,
|
||||||
|
thumbnail,
|
||||||
|
isUpdate,
|
||||||
|
error: publishToolErrors,
|
||||||
|
} = publishState;
|
||||||
const { loggedInChannel } = yield select(selectChannelState);
|
const { loggedInChannel } = yield select(selectChannelState);
|
||||||
const { host } = yield select(selectSiteState);
|
const { host } = yield select(selectSiteState);
|
||||||
|
|
||||||
|
@ -39,7 +50,7 @@ function * publishFile (action) {
|
||||||
// create metadata
|
// create metadata
|
||||||
publishMetadata = createPublishMetadata(
|
publishMetadata = createPublishMetadata(
|
||||||
isUpdate ? asset.name : claim,
|
isUpdate ? asset.name : claim,
|
||||||
isUpdate ? {type: asset.claimData.contentType} : file,
|
isUpdate ? { type: asset.claimData.contentType } : file,
|
||||||
metadata,
|
metadata,
|
||||||
publishInChannel,
|
publishInChannel,
|
||||||
selectedChannel
|
selectedChannel
|
||||||
|
@ -49,7 +60,12 @@ function * publishFile (action) {
|
||||||
}
|
}
|
||||||
if (thumbnail) {
|
if (thumbnail) {
|
||||||
// add thumbnail to publish metadata
|
// add thumbnail to publish metadata
|
||||||
publishMetadata['thumbnail'] = createThumbnailUrl(thumbnailChannel, thumbnailChannelId, claim, host);
|
publishMetadata['thumbnail'] = createThumbnailUrl(
|
||||||
|
thumbnailChannel,
|
||||||
|
thumbnailChannelId,
|
||||||
|
claim,
|
||||||
|
host
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// create form data for main publish
|
// create form data for main publish
|
||||||
publishFormData = createPublishFormData(file, thumbnail, publishMetadata);
|
publishFormData = createPublishFormData(file, thumbnail, publishMetadata);
|
||||||
|
@ -57,7 +73,7 @@ function * publishFile (action) {
|
||||||
publishChannel = yield call(makePublishRequestChannel, publishFormData, isUpdate);
|
publishChannel = yield call(makePublishRequestChannel, publishFormData, isUpdate);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const {loadStart, progress, load, success, error: publishError} = yield take(publishChannel);
|
const { loadStart, progress, load, success, error: publishError } = yield take(publishChannel);
|
||||||
if (publishError) {
|
if (publishError) {
|
||||||
return yield put(updatePublishStatus(publishStates.FAILED, publishError.message));
|
return yield put(updatePublishStatus(publishStates.FAILED, publishError.message));
|
||||||
}
|
}
|
||||||
|
@ -67,7 +83,7 @@ function * publishFile (action) {
|
||||||
yield put({
|
yield put({
|
||||||
type: 'ASSET_UPDATE_CLAIMDATA',
|
type: 'ASSET_UPDATE_CLAIMDATA',
|
||||||
data: {
|
data: {
|
||||||
id : `a#${success.data.name}#${success.data.claimId}`,
|
id: `a#${success.data.name}#${success.data.claimId}`,
|
||||||
claimData: success.data.claimData,
|
claimData: success.data.claimData,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -91,6 +107,6 @@ function * publishFile (action) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function * watchPublishStart () {
|
export function* watchPublishStart() {
|
||||||
yield takeLatest(actions.PUBLISH_START, publishFile);
|
yield takeLatest(actions.PUBLISH_START, publishFile);
|
||||||
};
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ export const createPublishMetadata = (
|
||||||
publishInChannel,
|
publishInChannel,
|
||||||
selectedChannel
|
selectedChannel
|
||||||
) => {
|
) => {
|
||||||
|
// this metadata stuff needs to be removed...
|
||||||
let metadata = {
|
let metadata = {
|
||||||
name: claim,
|
name: claim,
|
||||||
title,
|
title,
|
||||||
|
|
26
package-lock.json
generated
26
package-lock.json
generated
|
@ -2617,7 +2617,6 @@
|
||||||
"resolved": "http://registry.npmjs.org/bl/-/bl-1.2.2.tgz",
|
"resolved": "http://registry.npmjs.org/bl/-/bl-1.2.2.tgz",
|
||||||
"integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==",
|
"integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"readable-stream": "^2.3.5",
|
"readable-stream": "^2.3.5",
|
||||||
"safe-buffer": "^5.1.1"
|
"safe-buffer": "^5.1.1"
|
||||||
|
@ -3959,7 +3958,6 @@
|
||||||
"resolved": "https://registry.npmjs.org/decompress-tar/-/decompress-tar-4.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/decompress-tar/-/decompress-tar-4.1.1.tgz",
|
||||||
"integrity": "sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ==",
|
"integrity": "sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"file-type": "^5.2.0",
|
"file-type": "^5.2.0",
|
||||||
"is-stream": "^1.1.0",
|
"is-stream": "^1.1.0",
|
||||||
|
@ -3994,7 +3992,6 @@
|
||||||
"resolved": "https://registry.npmjs.org/decompress-targz/-/decompress-targz-4.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/decompress-targz/-/decompress-targz-4.1.1.tgz",
|
||||||
"integrity": "sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==",
|
"integrity": "sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"decompress-tar": "^4.1.1",
|
"decompress-tar": "^4.1.1",
|
||||||
"file-type": "^5.2.0",
|
"file-type": "^5.2.0",
|
||||||
|
@ -5385,8 +5382,7 @@
|
||||||
"version": "5.2.0",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz",
|
||||||
"integrity": "sha1-LdvqfHP/42No365J3DOMBYwritY=",
|
"integrity": "sha1-LdvqfHP/42No365J3DOMBYwritY=",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"fill-range": {
|
"fill-range": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
|
@ -5584,8 +5580,7 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
|
||||||
"integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==",
|
"integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"fs-extra": {
|
"fs-extra": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
|
@ -5641,8 +5636,7 @@
|
||||||
"ansi-regex": {
|
"ansi-regex": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"aproba": {
|
"aproba": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
|
@ -6057,8 +6051,7 @@
|
||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"safer-buffer": {
|
"safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
|
@ -6114,7 +6107,6 @@
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-regex": "^2.0.0"
|
"ansi-regex": "^2.0.0"
|
||||||
}
|
}
|
||||||
|
@ -6158,14 +6150,12 @@
|
||||||
"wrappy": {
|
"wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -15171,7 +15161,6 @@
|
||||||
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz",
|
||||||
"integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==",
|
"integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"bl": "^1.0.0",
|
"bl": "^1.0.0",
|
||||||
"buffer-alloc": "^1.2.0",
|
"buffer-alloc": "^1.2.0",
|
||||||
|
@ -15434,8 +15423,7 @@
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz",
|
||||||
"integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==",
|
"integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"to-fast-properties": {
|
"to-fast-properties": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
|
|
|
@ -33,25 +33,26 @@ const createPublishParams = (
|
||||||
name,
|
name,
|
||||||
file_path: filePath,
|
file_path: filePath,
|
||||||
bid: publishing.fileClaimBidAmount,
|
bid: publishing.fileClaimBidAmount,
|
||||||
metadata: {
|
|
||||||
description,
|
description,
|
||||||
title,
|
title,
|
||||||
author: details.title,
|
author: details.title,
|
||||||
language: 'en',
|
languages: ['en'],
|
||||||
license,
|
license,
|
||||||
licenseUrl,
|
license_url: licenseUrl,
|
||||||
nsfw,
|
tags: [],
|
||||||
},
|
|
||||||
claim_address: publishing.primaryClaimAddress,
|
claim_address: publishing.primaryClaimAddress,
|
||||||
};
|
};
|
||||||
// add thumbnail to channel if video
|
// add thumbnail to channel if video
|
||||||
if (thumbnail) {
|
if (thumbnail) {
|
||||||
publishParams['metadata']['thumbnail'] = thumbnail;
|
publishParams['thumbnail_url'] = thumbnail;
|
||||||
|
}
|
||||||
|
if (nsfw) {
|
||||||
|
publishParams.tags = ['mature'];
|
||||||
}
|
}
|
||||||
// add channel details if publishing to a channel
|
// add channel details if publishing to a channel
|
||||||
if (channelName && channelClaimId) {
|
if (channelName && channelClaimId) {
|
||||||
publishParams['channel_name'] = channelName;
|
|
||||||
publishParams['channel_id'] = channelClaimId;
|
publishParams['channel_id'] = channelClaimId;
|
||||||
|
publishParams['channel_name'] = channelName;
|
||||||
}
|
}
|
||||||
// log params
|
// log params
|
||||||
logger.debug('publish params:', publishParams);
|
logger.debug('publish params:', publishParams);
|
||||||
|
|
|
@ -7,19 +7,25 @@ const createThumbnailPublishParams = (thumbnailFilePath, claimName, license, lic
|
||||||
}
|
}
|
||||||
logger.debug(`Creating Thumbnail Publish Parameters`);
|
logger.debug(`Creating Thumbnail Publish Parameters`);
|
||||||
// create the publish params
|
// create the publish params
|
||||||
|
|
||||||
|
if (license === null || license.trim() === '') {
|
||||||
|
license = ''; // default to empty string
|
||||||
|
}
|
||||||
|
// provide default for licenseUrl
|
||||||
|
if (licenseUrl === null || licenseUrl.trim() === '') {
|
||||||
|
licenseUrl = ''; // default to empty string
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: `${claimName}-thumb`,
|
name: `${claimName}-thumb`,
|
||||||
file_path: thumbnailFilePath,
|
file_path: thumbnailFilePath,
|
||||||
bid: publishing.fileClaimBidAmount,
|
bid: publishing.fileClaimBidAmount,
|
||||||
metadata: {
|
|
||||||
title: `${claimName} thumbnail`,
|
title: `${claimName} thumbnail`,
|
||||||
description: `a thumbnail for ${claimName}`,
|
description: `a thumbnail for ${claimName}`,
|
||||||
author: details.title,
|
author: details.title,
|
||||||
language: 'en',
|
languages: ['en'],
|
||||||
license,
|
license,
|
||||||
licenseUrl,
|
license_url: licenseUrl,
|
||||||
nsfw,
|
|
||||||
},
|
|
||||||
claim_address: publishing.primaryClaimAddress,
|
claim_address: publishing.primaryClaimAddress,
|
||||||
channel_name: publishing.thumbnailChannel,
|
channel_name: publishing.thumbnailChannel,
|
||||||
channel_id: publishing.thumbnailChannelId,
|
channel_id: publishing.thumbnailChannelId,
|
||||||
|
|
|
@ -12,24 +12,32 @@ const publish = async (publishParams, fileName, fileType) => {
|
||||||
let channel;
|
let channel;
|
||||||
let fileRecord;
|
let fileRecord;
|
||||||
let newFile = Boolean(publishParams.file_path);
|
let newFile = Boolean(publishParams.file_path);
|
||||||
|
let publishResultsOutput;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
publishResults = await publishClaim(publishParams);
|
publishResults = await publishClaim(publishParams);
|
||||||
|
publishResultsOutput = publishResults && publishResults.outputs && publishResults.outputs[0];
|
||||||
|
|
||||||
logger.verbose(`Successfully published ${publishParams.name} ${fileName}`, publishResults);
|
logger.verbose(`Successfully published ${publishParams.name} ${fileName}`, publishResults);
|
||||||
const outpoint = `${publishResults.output.txid}:${publishResults.output.nout}`;
|
const outpoint = `${publishResultsOutput.txid}:${publishResultsOutput.nout}`;
|
||||||
// get the channel information
|
// get the channel information
|
||||||
if (publishParams.channel_name) {
|
// if (publishParams.channel_name) {
|
||||||
logger.debug(`this claim was published in channel: ${publishParams.channel_name}`);
|
// logger.debug(`this claim was published in channel: ${publishParams.channel_name}`);
|
||||||
channel = await db.Channel.findOne({
|
// channel = await db.Channel.findOne({
|
||||||
where: {
|
// where: {
|
||||||
channelName: publishParams.channel_name,
|
// channelName: publishParams.channel_name,
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
} else {
|
// } else {
|
||||||
channel = null;
|
// channel = null;
|
||||||
}
|
// }
|
||||||
const certificateId = channel ? channel.channelClaimId : null;
|
|
||||||
const channelName = channel ? channel.channelName : null;
|
const certificateId = publishResultsOutput.signing_channel
|
||||||
|
? publishResultsOutput.signing_channel.claim_id
|
||||||
|
: null;
|
||||||
|
const channelName = publishResultsOutput.signing_channel
|
||||||
|
? publishResultsOutput.signing_channel.name
|
||||||
|
: null;
|
||||||
|
|
||||||
const claimRecord = await createClaimRecordDataAfterPublish(
|
const claimRecord = await createClaimRecordDataAfterPublish(
|
||||||
certificateId,
|
certificateId,
|
||||||
|
@ -37,7 +45,7 @@ const publish = async (publishParams, fileName, fileType) => {
|
||||||
fileName,
|
fileName,
|
||||||
fileType,
|
fileType,
|
||||||
publishParams,
|
publishParams,
|
||||||
publishResults
|
publishResultsOutput
|
||||||
);
|
);
|
||||||
const { claimId } = claimRecord;
|
const { claimId } = claimRecord;
|
||||||
const upsertCriteria = { name: publishParams.name, claimId };
|
const upsertCriteria = { name: publishParams.name, claimId };
|
||||||
|
@ -48,7 +56,7 @@ const publish = async (publishParams, fileName, fileType) => {
|
||||||
fileName,
|
fileName,
|
||||||
fileType,
|
fileType,
|
||||||
publishParams,
|
publishParams,
|
||||||
publishResults
|
publishResultsOutput
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
fileRecord = await db.File.findOne({ where: { claimId } }).then(result => result.dataValues);
|
fileRecord = await db.File.findOne({ where: { claimId } }).then(result => result.dataValues);
|
||||||
|
|
|
@ -138,7 +138,7 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res)
|
||||||
nsfw: claimRecord.nsfw,
|
nsfw: claimRecord.nsfw,
|
||||||
license: claimRecord.license,
|
license: claimRecord.license,
|
||||||
licenseUrl: claimRecord.license_url,
|
licenseUrl: claimRecord.license_url,
|
||||||
language: 'en',
|
languages: ['en'],
|
||||||
author: details.title,
|
author: details.title,
|
||||||
},
|
},
|
||||||
updateMetadata({ title, description, nsfw, license, licenseUrl })
|
updateMetadata({ title, description, nsfw, license, licenseUrl })
|
||||||
|
@ -149,9 +149,19 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res)
|
||||||
claim_address: primaryClaimAddress,
|
claim_address: primaryClaimAddress,
|
||||||
channel_name: channelName,
|
channel_name: channelName,
|
||||||
channel_id: channelId,
|
channel_id: channelId,
|
||||||
metadata,
|
title,
|
||||||
|
description,
|
||||||
|
author: details.title,
|
||||||
|
languages: ['en'],
|
||||||
|
license: license || '',
|
||||||
|
license_url: licenseUrl || '',
|
||||||
|
tags: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (nsfw) {
|
||||||
|
publishParams.tags = ['mature'];
|
||||||
|
}
|
||||||
|
|
||||||
if (files.file) {
|
if (files.file) {
|
||||||
if (thumbnailUpdate) {
|
if (thumbnailUpdate) {
|
||||||
// publish new thumbnail
|
// publish new thumbnail
|
||||||
|
@ -185,14 +195,14 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res)
|
||||||
|
|
||||||
if (channelName) {
|
if (channelName) {
|
||||||
return chainquery.claim.queries.getShortClaimIdFromLongClaimId(
|
return chainquery.claim.queries.getShortClaimIdFromLongClaimId(
|
||||||
result.certificateId,
|
publishResult.certificateId,
|
||||||
channelName
|
channelName
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return chainquery.claim.queries
|
return chainquery.claim.queries
|
||||||
.getShortClaimIdFromLongClaimId(result.claimId, name, result)
|
.getShortClaimIdFromLongClaimId(publishResult.claimId, name, publishResult)
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
return result.claimId.slice(0, 1);
|
return publishResult.claimId.slice(0, 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -14,7 +14,7 @@ const chainquery = require('chainquery').default;
|
||||||
const fileAvailability = ({ ip, originalUrl, params }, res) => {
|
const fileAvailability = ({ ip, originalUrl, params }, res) => {
|
||||||
const name = params.name;
|
const name = params.name;
|
||||||
const claimId = params.claimId;
|
const claimId = params.claimId;
|
||||||
logger.debug(`fileAvailability params: name:${name} claimId:${claimId}`);
|
logger.verbose(`fileAvailability params: name:${name} claimId:${claimId}`);
|
||||||
// TODO: we probably eventually want to check the publishCache for the claimId too,
|
// TODO: we probably eventually want to check the publishCache for the claimId too,
|
||||||
// and shop the outpoint to file_list.
|
// and shop the outpoint to file_list.
|
||||||
return chainquery.claim.queries
|
return chainquery.claim.queries
|
||||||
|
|
|
@ -172,10 +172,10 @@ module.exports = {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios
|
axios
|
||||||
.post(lbrynetUri, {
|
.post(lbrynetUri, {
|
||||||
method: 'channel_new',
|
method: 'channel_create',
|
||||||
params: {
|
params: {
|
||||||
channel_name: name,
|
name: name,
|
||||||
amount: publishing.channelClaimBidAmount,
|
bid: publishing.channelClaimBidAmount,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
const db = require('../index.js');
|
const db = require('../index.js');
|
||||||
|
|
||||||
const createClaimRecordDataAfterPublish = (certificateId, channelName, fileName, fileType, publishParams, publishResults) => {
|
const createClaimRecordDataAfterPublish = (
|
||||||
|
certificateId,
|
||||||
|
channelName,
|
||||||
|
fileName,
|
||||||
|
fileType,
|
||||||
|
publishParams,
|
||||||
|
publishResultsOutput
|
||||||
|
) => {
|
||||||
const {
|
const {
|
||||||
name,
|
name,
|
||||||
metadata: {
|
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
nsfw,
|
nsfw,
|
||||||
},
|
|
||||||
claim_address: address,
|
claim_address: address,
|
||||||
bid: amount,
|
bid: amount,
|
||||||
} = publishParams;
|
} = publishParams;
|
||||||
|
|
||||||
const {
|
const { claim_id: claimId, txid, nout } = publishResultsOutput;
|
||||||
claim_id: claimId,
|
|
||||||
txid,
|
|
||||||
nout,
|
|
||||||
} = publishResults;
|
|
||||||
|
|
||||||
return db.Claim.getCurrentHeight()
|
return db.Claim.getCurrentHeight().then(height => {
|
||||||
.then(height => {
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
claimId,
|
claimId,
|
||||||
|
@ -28,7 +28,7 @@ const createClaimRecordDataAfterPublish = (certificateId, channelName, fileName,
|
||||||
description,
|
description,
|
||||||
address,
|
address,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
outpoint : `${txid}:${nout}`,
|
outpoint: `${txid}:${nout}`,
|
||||||
height,
|
height,
|
||||||
contentType: fileType,
|
contentType: fileType,
|
||||||
nsfw,
|
nsfw,
|
||||||
|
|
|
@ -1,22 +1,11 @@
|
||||||
const getMediaDimensions = require('../../utils/getMediaDimensions.js');
|
const getMediaDimensions = require('../../utils/getMediaDimensions.js');
|
||||||
|
|
||||||
async function createFileRecordDataAfterGet (resolveResult, getResult) {
|
async function createFileRecordDataAfterGet(resolveResult, getResult) {
|
||||||
const {
|
const { name, claimId, outpoint, contentType: fileType } = resolveResult;
|
||||||
name,
|
|
||||||
claimId,
|
|
||||||
outpoint,
|
|
||||||
contentType: fileType,
|
|
||||||
} = resolveResult;
|
|
||||||
|
|
||||||
const {
|
const { file_name: fileName, download_path: filePath } = getResult;
|
||||||
file_name: fileName,
|
|
||||||
download_path: filePath,
|
|
||||||
} = getResult;
|
|
||||||
|
|
||||||
const {
|
const { height: fileHeight, width: fileWidth } = await getMediaDimensions(fileType, filePath);
|
||||||
height: fileHeight,
|
|
||||||
width: fileWidth,
|
|
||||||
} = await getMediaDimensions(fileType, filePath);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
|
@ -30,22 +19,17 @@ async function createFileRecordDataAfterGet (resolveResult, getResult) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createFileRecordDataAfterPublish (fileName, fileType, publishParams, publishResults) {
|
async function createFileRecordDataAfterPublish(
|
||||||
const {
|
fileName,
|
||||||
name,
|
fileType,
|
||||||
file_path: filePath,
|
publishParams,
|
||||||
} = publishParams;
|
publishResultsOutput
|
||||||
|
) {
|
||||||
|
const { name, file_path: filePath } = publishParams;
|
||||||
|
|
||||||
const {
|
const { claim_id: claimId, txid, nout } = publishResultsOutput;
|
||||||
claim_id: claimId,
|
|
||||||
txid,
|
|
||||||
nout,
|
|
||||||
} = publishResults;
|
|
||||||
|
|
||||||
const {
|
const { height: fileHeight, width: fileWidth } = await getMediaDimensions(fileType, filePath);
|
||||||
height: fileHeight,
|
|
||||||
width: fileWidth,
|
|
||||||
} = await getMediaDimensions(fileType, filePath);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
|
|
|
@ -2,7 +2,9 @@ const PassportLocalStrategy = require('passport-local').Strategy;
|
||||||
const { createChannel } = require('../../lbrynet');
|
const { createChannel } = require('../../lbrynet');
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const db = require('../../models');
|
const db = require('../../models');
|
||||||
const { publishing: { closedRegistration } } = require('@config/siteConfig');
|
const {
|
||||||
|
publishing: { closedRegistration },
|
||||||
|
} = require('@config/siteConfig');
|
||||||
|
|
||||||
module.exports = new PassportLocalStrategy(
|
module.exports = new PassportLocalStrategy(
|
||||||
{
|
{
|
||||||
|
@ -28,19 +30,23 @@ module.exports = new PassportLocalStrategy(
|
||||||
logger.verbose('userData >', userData);
|
logger.verbose('userData >', userData);
|
||||||
// create user record
|
// create user record
|
||||||
const channelData = {
|
const channelData = {
|
||||||
channelName : `@${username}`,
|
channelName: `@${username}`,
|
||||||
channelClaimId: tx.claim_id,
|
channelClaimId: tx.outputs[0].claim_id,
|
||||||
};
|
};
|
||||||
logger.verbose('channelData >', channelData);
|
logger.verbose('channelData >', channelData);
|
||||||
// create certificate record
|
// create certificate record
|
||||||
const certificateData = {
|
const certificateData = {
|
||||||
claimId: tx.claim_id,
|
claimId: tx.outputs[0].claim_id,
|
||||||
name : `@${username}`,
|
name: `@${username}`,
|
||||||
// address,
|
// address,
|
||||||
};
|
};
|
||||||
logger.verbose('certificateData >', certificateData);
|
logger.verbose('certificateData >', certificateData);
|
||||||
// save user and certificate to db
|
// save user and certificate to db
|
||||||
return Promise.all([db.User.create(userData), db.Channel.create(channelData), db.Certificate.create(certificateData)]);
|
return Promise.all([
|
||||||
|
db.User.create(userData),
|
||||||
|
db.Channel.create(channelData),
|
||||||
|
db.Certificate.create(certificateData),
|
||||||
|
]);
|
||||||
})
|
})
|
||||||
.then(([newUser, newChannel, newCertificate]) => {
|
.then(([newUser, newChannel, newCertificate]) => {
|
||||||
logger.verbose('user and certificate successfully created');
|
logger.verbose('user and certificate successfully created');
|
||||||
|
@ -54,7 +60,10 @@ module.exports = new PassportLocalStrategy(
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
logger.verbose('user and certificate successfully associated');
|
logger.verbose('user and certificate successfully associated');
|
||||||
return db.Certificate.getShortChannelIdFromLongChannelId(userInfo.channelClaimId, userInfo.channelName);
|
return db.Certificate.getShortChannelIdFromLongChannelId(
|
||||||
|
userInfo.channelClaimId,
|
||||||
|
userInfo.channelName
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.then(shortChannelId => {
|
.then(shortChannelId => {
|
||||||
userInfo['shortChannelId'] = shortChannelId;
|
userInfo['shortChannelId'] = shortChannelId;
|
||||||
|
|
Loading…
Reference in a new issue