From 1b069ba2a1c5e2a0c83fa2b19f621439b4a9e578 Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 24 May 2019 13:09:07 -0400 Subject: [PATCH 1/3] 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 --- cli/configure.js | 9 +-- .../src/containers/PublishTitleInput/index.js | 9 ++- client/src/reducers/publish.js | 2 +- client/src/sagas/publish.js | 34 ++++++++--- client/src/utils/publish.js | 1 + package-lock.json | 26 +++------ .../api/claim/publish/createPublishParams.js | 24 ++++---- .../publish/createThumbnailPublishParams.js | 15 ++--- .../controllers/api/claim/publish/publish.js | 2 +- server/controllers/api/claim/update/index.js | 2 +- server/lbrynet/index.js | 6 +- server/models/utils/createClaimRecordData.js | 57 +++++++++---------- 12 files changed, 95 insertions(+), 92 deletions(-) diff --git a/cli/configure.js b/cli/configure.js index b34ec760..9beef6af 100644 --- a/cli/configure.js +++ b/cli/configure.js @@ -188,8 +188,8 @@ inquirer .post('http://localhost:5279', { method: 'channel_new', params: { - channel_name: thumbnailChannelDefault, - amount: channelBid, + name: thumbnailChannelDefault, + bid: channelBid, }, }) .then(response => { @@ -197,7 +197,6 @@ inquirer if (response.data.error) { throw new Error(response.data.error.message); } - thumbnailChannel = thumbnailChannelDefault; thumbnailChannelId = response.data.result.claim_id; 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.' ); - 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( 'If you want to change any settings, you can edit the files in the "/site" folder.' ); diff --git a/client/src/containers/PublishTitleInput/index.js b/client/src/containers/PublishTitleInput/index.js index 2433555b..ee340617 100644 --- a/client/src/containers/PublishTitleInput/index.js +++ b/client/src/containers/PublishTitleInput/index.js @@ -1,5 +1,5 @@ -import {connect} from 'react-redux'; -import {updateMetadata} from '../../actions/publish'; +import { connect } from 'react-redux'; +import { updateMetadata } from '../../actions/publish'; import View from './view'; const mapStateToProps = ({ publish }) => { @@ -16,4 +16,7 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect(mapStateToProps, mapDispatchToProps)(View); +export default connect( + mapStateToProps, + mapDispatchToProps +)(View); diff --git a/client/src/reducers/publish.js b/client/src/reducers/publish.js index 58a37aa4..14166be5 100644 --- a/client/src/reducers/publish.js +++ b/client/src/reducers/publish.js @@ -40,7 +40,7 @@ const initialState = { description: '', license: '', licenseUrl: '', - nsfw: false, + tags: [], }, isUpdate: false, hasChanged: false, diff --git a/client/src/sagas/publish.js b/client/src/sagas/publish.js index 7e61cda7..cd945209 100644 --- a/client/src/sagas/publish.js +++ b/client/src/sagas/publish.js @@ -9,11 +9,22 @@ import { selectShowState, selectAsset } from '../selectors/show'; import { validateChannelSelection, validateNoPublishErrors } from '../utils/validate'; import { createPublishMetadata, createPublishFormData, createThumbnailUrl } from '../utils/publish'; import { makePublishRequestChannel } from '../channels/publish'; - -function * publishFile (action) { +// yep +function* publishFile(action) { const { history } = action.data; 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 { host } = yield select(selectSiteState); @@ -39,7 +50,7 @@ function * publishFile (action) { // create metadata publishMetadata = createPublishMetadata( isUpdate ? asset.name : claim, - isUpdate ? {type: asset.claimData.contentType} : file, + isUpdate ? { type: asset.claimData.contentType } : file, metadata, publishInChannel, selectedChannel @@ -49,7 +60,12 @@ function * publishFile (action) { } if (thumbnail) { // 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 publishFormData = createPublishFormData(file, thumbnail, publishMetadata); @@ -57,7 +73,7 @@ function * publishFile (action) { publishChannel = yield call(makePublishRequestChannel, publishFormData, isUpdate); while (true) { - const {loadStart, progress, load, success, error: publishError} = yield take(publishChannel); + const { loadStart, progress, load, success, error: publishError } = yield take(publishChannel); if (publishError) { return yield put(updatePublishStatus(publishStates.FAILED, publishError.message)); } @@ -67,7 +83,7 @@ function * publishFile (action) { yield put({ type: 'ASSET_UPDATE_CLAIMDATA', data: { - id : `a#${success.data.name}#${success.data.claimId}`, + id: `a#${success.data.name}#${success.data.claimId}`, claimData: success.data.claimData, }, }); @@ -91,6 +107,6 @@ function * publishFile (action) { } } -export function * watchPublishStart () { +export function* watchPublishStart() { yield takeLatest(actions.PUBLISH_START, publishFile); -}; +} diff --git a/client/src/utils/publish.js b/client/src/utils/publish.js index 4de574cf..3fb5e500 100644 --- a/client/src/utils/publish.js +++ b/client/src/utils/publish.js @@ -5,6 +5,7 @@ export const createPublishMetadata = ( publishInChannel, selectedChannel ) => { + // this metadata stuff needs to be removed... let metadata = { name: claim, title, diff --git a/package-lock.json b/package-lock.json index 06ed5ecc..a466dc3c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2617,7 +2617,6 @@ "resolved": "http://registry.npmjs.org/bl/-/bl-1.2.2.tgz", "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", "dev": true, - "optional": true, "requires": { "readable-stream": "^2.3.5", "safe-buffer": "^5.1.1" @@ -3959,7 +3958,6 @@ "resolved": "https://registry.npmjs.org/decompress-tar/-/decompress-tar-4.1.1.tgz", "integrity": "sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ==", "dev": true, - "optional": true, "requires": { "file-type": "^5.2.0", "is-stream": "^1.1.0", @@ -3994,7 +3992,6 @@ "resolved": "https://registry.npmjs.org/decompress-targz/-/decompress-targz-4.1.1.tgz", "integrity": "sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==", "dev": true, - "optional": true, "requires": { "decompress-tar": "^4.1.1", "file-type": "^5.2.0", @@ -5385,8 +5382,7 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", "integrity": "sha1-LdvqfHP/42No365J3DOMBYwritY=", - "dev": true, - "optional": true + "dev": true }, "fill-range": { "version": "4.0.0", @@ -5584,8 +5580,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", - "dev": true, - "optional": true + "dev": true }, "fs-extra": { "version": "5.0.0", @@ -5641,8 +5636,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -6057,8 +6051,7 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -6114,7 +6107,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -6158,14 +6150,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -15171,7 +15161,6 @@ "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz", "integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==", "dev": true, - "optional": true, "requires": { "bl": "^1.0.0", "buffer-alloc": "^1.2.0", @@ -15434,8 +15423,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==", - "dev": true, - "optional": true + "dev": true }, "to-fast-properties": { "version": "2.0.0", diff --git a/server/controllers/api/claim/publish/createPublishParams.js b/server/controllers/api/claim/publish/createPublishParams.js index 0a51cba8..bf482cfa 100644 --- a/server/controllers/api/claim/publish/createPublishParams.js +++ b/server/controllers/api/claim/publish/createPublishParams.js @@ -33,24 +33,24 @@ const createPublishParams = ( name, file_path: filePath, bid: publishing.fileClaimBidAmount, - metadata: { - description, - title, - author: details.title, - language: 'en', - license, - licenseUrl, - nsfw, - }, + 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['metadata']['thumbnail'] = thumbnail; + publishParams['thumbnail_url'] = thumbnail; + } + if (nsfw) { + publishParams.tags.push = 'mature'; } // add channel details if publishing to a channel - if (channelName && channelClaimId) { - publishParams['channel_name'] = channelName; + if (channelClaimId) { publishParams['channel_id'] = channelClaimId; } // log params diff --git a/server/controllers/api/claim/publish/createThumbnailPublishParams.js b/server/controllers/api/claim/publish/createThumbnailPublishParams.js index a848aab5..66934511 100644 --- a/server/controllers/api/claim/publish/createThumbnailPublishParams.js +++ b/server/controllers/api/claim/publish/createThumbnailPublishParams.js @@ -11,15 +11,12 @@ const createThumbnailPublishParams = (thumbnailFilePath, claimName, license, lic name: `${claimName}-thumb`, file_path: thumbnailFilePath, bid: publishing.fileClaimBidAmount, - metadata: { - title: `${claimName} thumbnail`, - description: `a thumbnail for ${claimName}`, - author: details.title, - language: 'en', - license, - licenseUrl, - nsfw, - }, + title: `${claimName} thumbnail`, + description: `a thumbnail for ${claimName}`, + author: details.title, + languages: ['en'], + license, + license_url: licenseUrl, claim_address: publishing.primaryClaimAddress, channel_name: publishing.thumbnailChannel, channel_id: publishing.thumbnailChannelId, diff --git a/server/controllers/api/claim/publish/publish.js b/server/controllers/api/claim/publish/publish.js index 630c9735..425644e0 100644 --- a/server/controllers/api/claim/publish/publish.js +++ b/server/controllers/api/claim/publish/publish.js @@ -16,7 +16,7 @@ const publish = async (publishParams, fileName, fileType) => { try { publishResults = await publishClaim(publishParams); logger.verbose(`Successfully published ${publishParams.name} ${fileName}`, publishResults); - const outpoint = `${publishResults.output.txid}:${publishResults.output.nout}`; + const outpoint = `${publishResults.outputs[0].txid}:${publishResults.outputs[0].nout}`; // get the channel information if (publishParams.channel_name) { logger.debug(`this claim was published in channel: ${publishParams.channel_name}`); diff --git a/server/controllers/api/claim/update/index.js b/server/controllers/api/claim/update/index.js index f3c1983f..68107e05 100644 --- a/server/controllers/api/claim/update/index.js +++ b/server/controllers/api/claim/update/index.js @@ -138,7 +138,7 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res) nsfw: claimRecord.nsfw, license: claimRecord.license, licenseUrl: claimRecord.license_url, - language: 'en', + languages: ['en'], author: details.title, }, updateMetadata({ title, description, nsfw, license, licenseUrl }) diff --git a/server/lbrynet/index.js b/server/lbrynet/index.js index caecb74a..1beea877 100644 --- a/server/lbrynet/index.js +++ b/server/lbrynet/index.js @@ -172,10 +172,10 @@ module.exports = { return new Promise((resolve, reject) => { axios .post(lbrynetUri, { - method: 'channel_new', + method: 'channel_create', params: { - channel_name: name, - amount: publishing.channelClaimBidAmount, + name: name, + bid: publishing.channelClaimBidAmount, }, }) .then(response => { diff --git a/server/models/utils/createClaimRecordData.js b/server/models/utils/createClaimRecordData.js index 547b6158..d4c8bbec 100644 --- a/server/models/utils/createClaimRecordData.js +++ b/server/models/utils/createClaimRecordData.js @@ -1,42 +1,39 @@ const db = require('../index.js'); -const createClaimRecordDataAfterPublish = (certificateId, channelName, fileName, fileType, publishParams, publishResults) => { +const createClaimRecordDataAfterPublish = ( + certificateId, + channelName, + fileName, + fileType, + publishParams, + publishResults +) => { const { name, - metadata: { - title, - description, - thumbnail, - nsfw, - }, + metadata: { title, description, thumbnail, nsfw }, claim_address: address, bid: amount, } = publishParams; - const { - claim_id: claimId, - txid, - nout, - } = publishResults; + const { claim_id: claimId, txid, nout } = publishResults; - return db.Claim.getCurrentHeight() - .then(height => { - return { - name, - claimId, - title, - description, - address, - thumbnail, - outpoint : `${txid}:${nout}`, - height, - contentType: fileType, - nsfw, - amount, - certificateId, - channelName, - }; - }); + return db.Claim.getCurrentHeight().then(height => { + return { + name, + claimId, + title, + description, + address, + thumbnail, + outpoint: `${txid}:${nout}`, + height, + contentType: fileType, + nsfw, + amount, + certificateId, + channelName, + }; + }); }; module.exports = { -- 2.45.2 From adbafa4194838ade477d86d992839cab119ef3be Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 24 May 2019 16:39:46 -0400 Subject: [PATCH 2/3] further fixes! --- .../api/claim/publish/createPublishParams.js | 5 ++- .../publish/createThumbnailPublishParams.js | 9 ++++ .../controllers/api/claim/publish/publish.js | 38 ++++++++++------- .../api/file/availability/index.js | 2 +- server/models/utils/createClaimRecordData.js | 9 ++-- server/models/utils/createFileRecordData.js | 42 ++++++------------- server/speechPassport/utils/local-signup.js | 23 ++++++---- 7 files changed, 71 insertions(+), 57 deletions(-) diff --git a/server/controllers/api/claim/publish/createPublishParams.js b/server/controllers/api/claim/publish/createPublishParams.js index bf482cfa..44330277 100644 --- a/server/controllers/api/claim/publish/createPublishParams.js +++ b/server/controllers/api/claim/publish/createPublishParams.js @@ -47,11 +47,12 @@ const createPublishParams = ( publishParams['thumbnail_url'] = thumbnail; } if (nsfw) { - publishParams.tags.push = 'mature'; + publishParams.tags = 'mature'; } // add channel details if publishing to a channel - if (channelClaimId) { + if (channelName && channelClaimId) { publishParams['channel_id'] = channelClaimId; + publishParams['channel_name'] = channelName; } // log params logger.debug('publish params:', publishParams); diff --git a/server/controllers/api/claim/publish/createThumbnailPublishParams.js b/server/controllers/api/claim/publish/createThumbnailPublishParams.js index 66934511..ffe08051 100644 --- a/server/controllers/api/claim/publish/createThumbnailPublishParams.js +++ b/server/controllers/api/claim/publish/createThumbnailPublishParams.js @@ -7,6 +7,15 @@ const createThumbnailPublishParams = (thumbnailFilePath, claimName, license, lic } logger.debug(`Creating Thumbnail Publish Parameters`); // 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 { name: `${claimName}-thumb`, file_path: thumbnailFilePath, diff --git a/server/controllers/api/claim/publish/publish.js b/server/controllers/api/claim/publish/publish.js index 425644e0..e8743ca7 100644 --- a/server/controllers/api/claim/publish/publish.js +++ b/server/controllers/api/claim/publish/publish.js @@ -12,24 +12,32 @@ const publish = async (publishParams, fileName, fileType) => { let channel; let fileRecord; let newFile = Boolean(publishParams.file_path); + let publishResultsOutput; try { publishResults = await publishClaim(publishParams); + publishResultsOutput = publishResults && publishResults.outputs && publishResults.outputs[0]; + logger.verbose(`Successfully published ${publishParams.name} ${fileName}`, publishResults); - const outpoint = `${publishResults.outputs[0].txid}:${publishResults.outputs[0].nout}`; + const outpoint = `${publishResultsOutput.txid}:${publishResultsOutput.nout}`; // get the channel information - if (publishParams.channel_name) { - logger.debug(`this claim was published in channel: ${publishParams.channel_name}`); - channel = await db.Channel.findOne({ - where: { - channelName: publishParams.channel_name, - }, - }); - } else { - channel = null; - } - const certificateId = channel ? channel.channelClaimId : null; - const channelName = channel ? channel.channelName : null; + // if (publishParams.channel_name) { + // logger.debug(`this claim was published in channel: ${publishParams.channel_name}`); + // channel = await db.Channel.findOne({ + // where: { + // channelName: publishParams.channel_name, + // }, + // }); + // } else { + // channel = 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( certificateId, @@ -37,7 +45,7 @@ const publish = async (publishParams, fileName, fileType) => { fileName, fileType, publishParams, - publishResults + publishResultsOutput ); const { claimId } = claimRecord; const upsertCriteria = { name: publishParams.name, claimId }; @@ -48,7 +56,7 @@ const publish = async (publishParams, fileName, fileType) => { fileName, fileType, publishParams, - publishResults + publishResultsOutput ); } else { fileRecord = await db.File.findOne({ where: { claimId } }).then(result => result.dataValues); diff --git a/server/controllers/api/file/availability/index.js b/server/controllers/api/file/availability/index.js index 04c4c7d2..52b98408 100644 --- a/server/controllers/api/file/availability/index.js +++ b/server/controllers/api/file/availability/index.js @@ -14,7 +14,7 @@ const chainquery = require('chainquery').default; const fileAvailability = ({ ip, originalUrl, params }, res) => { const name = params.name; 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, // and shop the outpoint to file_list. return chainquery.claim.queries diff --git a/server/models/utils/createClaimRecordData.js b/server/models/utils/createClaimRecordData.js index d4c8bbec..55b9c853 100644 --- a/server/models/utils/createClaimRecordData.js +++ b/server/models/utils/createClaimRecordData.js @@ -6,16 +6,19 @@ const createClaimRecordDataAfterPublish = ( fileName, fileType, publishParams, - publishResults + publishResultsOutput ) => { const { name, - metadata: { title, description, thumbnail, nsfw }, + title, + description, + thumbnail, + nsfw, claim_address: address, bid: amount, } = publishParams; - const { claim_id: claimId, txid, nout } = publishResults; + const { claim_id: claimId, txid, nout } = publishResultsOutput; return db.Claim.getCurrentHeight().then(height => { return { diff --git a/server/models/utils/createFileRecordData.js b/server/models/utils/createFileRecordData.js index fdcb9ce0..97833c7c 100644 --- a/server/models/utils/createFileRecordData.js +++ b/server/models/utils/createFileRecordData.js @@ -1,22 +1,11 @@ const getMediaDimensions = require('../../utils/getMediaDimensions.js'); -async function createFileRecordDataAfterGet (resolveResult, getResult) { - const { - name, - claimId, - outpoint, - contentType: fileType, - } = resolveResult; +async function createFileRecordDataAfterGet(resolveResult, getResult) { + const { name, claimId, outpoint, contentType: fileType } = resolveResult; - const { - file_name: fileName, - download_path: filePath, - } = getResult; + const { file_name: fileName, download_path: filePath } = getResult; - const { - height: fileHeight, - width: fileWidth, - } = await getMediaDimensions(fileType, filePath); + const { height: fileHeight, width: fileWidth } = await getMediaDimensions(fileType, filePath); return { name, @@ -30,22 +19,17 @@ async function createFileRecordDataAfterGet (resolveResult, getResult) { }; } -async function createFileRecordDataAfterPublish (fileName, fileType, publishParams, publishResults) { - const { - name, - file_path: filePath, - } = publishParams; +async function createFileRecordDataAfterPublish( + fileName, + fileType, + publishParams, + publishResultsOutput +) { + const { name, file_path: filePath } = publishParams; - const { - claim_id: claimId, - txid, - nout, - } = publishResults; + const { claim_id: claimId, txid, nout } = publishResultsOutput; - const { - height: fileHeight, - width: fileWidth, - } = await getMediaDimensions(fileType, filePath); + const { height: fileHeight, width: fileWidth } = await getMediaDimensions(fileType, filePath); return { name, diff --git a/server/speechPassport/utils/local-signup.js b/server/speechPassport/utils/local-signup.js index 2662b721..3a3f98b6 100644 --- a/server/speechPassport/utils/local-signup.js +++ b/server/speechPassport/utils/local-signup.js @@ -2,7 +2,9 @@ const PassportLocalStrategy = require('passport-local').Strategy; const { createChannel } = require('../../lbrynet'); const logger = require('winston'); const db = require('../../models'); -const { publishing: { closedRegistration } } = require('@config/siteConfig'); +const { + publishing: { closedRegistration }, +} = require('@config/siteConfig'); module.exports = new PassportLocalStrategy( { @@ -28,19 +30,23 @@ module.exports = new PassportLocalStrategy( logger.verbose('userData >', userData); // create user record const channelData = { - channelName : `@${username}`, - channelClaimId: tx.claim_id, + channelName: `@${username}`, + channelClaimId: tx.outputs[0].claim_id, }; logger.verbose('channelData >', channelData); // create certificate record const certificateData = { - claimId: tx.claim_id, - name : `@${username}`, + claimId: tx.outputs[0].claim_id, + name: `@${username}`, // address, }; logger.verbose('certificateData >', certificateData); // 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]) => { logger.verbose('user and certificate successfully created'); @@ -54,7 +60,10 @@ module.exports = new PassportLocalStrategy( }) .then(() => { 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 => { userInfo['shortChannelId'] = shortChannelId; -- 2.45.2 From b98fffc386f40ea1bc9a49ff8119bfd0d6ab4e65 Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 25 May 2019 18:00:20 -0400 Subject: [PATCH 3/3] fix: updates! --- .../api/claim/publish/createPublishParams.js | 2 +- server/controllers/api/claim/update/index.js | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/server/controllers/api/claim/publish/createPublishParams.js b/server/controllers/api/claim/publish/createPublishParams.js index 44330277..897b7e53 100644 --- a/server/controllers/api/claim/publish/createPublishParams.js +++ b/server/controllers/api/claim/publish/createPublishParams.js @@ -47,7 +47,7 @@ const createPublishParams = ( publishParams['thumbnail_url'] = thumbnail; } if (nsfw) { - publishParams.tags = 'mature'; + publishParams.tags = ['mature']; } // add channel details if publishing to a channel if (channelName && channelClaimId) { diff --git a/server/controllers/api/claim/update/index.js b/server/controllers/api/claim/update/index.js index 68107e05..204b91f7 100644 --- a/server/controllers/api/claim/update/index.js +++ b/server/controllers/api/claim/update/index.js @@ -149,9 +149,19 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res) claim_address: primaryClaimAddress, channel_name: channelName, 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 (thumbnailUpdate) { // publish new thumbnail @@ -185,14 +195,14 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res) if (channelName) { return chainquery.claim.queries.getShortClaimIdFromLongClaimId( - result.certificateId, + publishResult.certificateId, channelName ); } else { return chainquery.claim.queries - .getShortClaimIdFromLongClaimId(result.claimId, name, result) + .getShortClaimIdFromLongClaimId(publishResult.claimId, name, publishResult) .catch(() => { - return result.claimId.slice(0, 1); + return publishResult.claimId.slice(0, 1); }); } }) -- 2.45.2