From cc3fa3d0676250c2a9951e134a1f01816e51604e Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 5 Mar 2018 15:38:26 -0800 Subject: [PATCH] renamed functions appropriately --- controllers/publishController.js | 2 +- helpers/publishHelpers.js | 2 +- routes/api-routes.js | 12 +++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/controllers/publishController.js b/controllers/publishController.js index 588e888e..18fa640e 100644 --- a/controllers/publishController.js +++ b/controllers/publishController.js @@ -86,7 +86,7 @@ module.exports = { }); }); }, - validateClaimName (name) { + claimNameIsAvailable (name) { // find any records where the name is used return db.File.findAll({ where: { name } }) .then(result => { diff --git a/helpers/publishHelpers.js b/helpers/publishHelpers.js index b21b26a9..982deaa2 100644 --- a/helpers/publishHelpers.js +++ b/helpers/publishHelpers.js @@ -86,7 +86,7 @@ module.exports = { } return file; }, - createPublishParams (filePath, name, title, description, license, nsfw, thumbnail) { + createBasicPublishParams (filePath, name, title, description, license, nsfw, thumbnail) { logger.debug(`Creating Publish Parameters`); // provide defaults for title if (title === null || title.trim() === '') { diff --git a/routes/api-routes.js b/routes/api-routes.js index 6e982c6f..1182ef72 100644 --- a/routes/api-routes.js +++ b/routes/api-routes.js @@ -3,9 +3,9 @@ const multipart = require('connect-multiparty'); const { files, site } = require('../config/speechConfig.js'); const multipartMiddleware = multipart({uploadDir: files.uploadDirectory}); const db = require('../models'); -const { validateClaimName, checkChannelAvailability, publish } = require('../controllers/publishController.js'); +const { claimNameIsAvailable, checkChannelAvailability, publish } = require('../controllers/publishController.js'); const { getClaimList, resolveUri, getClaim } = require('../helpers/lbryApi.js'); -const { createPublishParams, parsePublishApiRequestBody, parsePublishApiRequestFiles, addGetResultsToFileData, createFileData } = require('../helpers/publishHelpers.js'); +const { createBasicPublishParams, parsePublishApiRequestBody, parsePublishApiRequestFiles, addGetResultsToFileData, createFileData } = require('../helpers/publishHelpers.js'); const errorHandlers = require('../helpers/errorHandlers.js'); const { sendGAAnonymousPublishTiming, sendGAChannelPublishTiming } = require('../helpers/googleAnalytics.js'); const { authenticateUser } = require('../auth/authentication.js'); @@ -108,7 +108,7 @@ module.exports = (app) => { }); // route to check whether this site published to a claim app.get('/api/claim/availability/:name', ({ ip, originalUrl, params }, res) => { - validateClaimName(params.name) + claimNameIsAvailable(params.name) .then(result => { res.status(200).json(result); }) @@ -146,8 +146,8 @@ module.exports = (app) => { // check channel authorization Promise.all([ authenticateUser(channelName, channelId, channelPassword, user), - validateClaimName(name), - createPublishParams(filePath, name, title, description, license, nsfw, thumbnail), + claimNameIsAvailable(name), + createBasicPublishParams(filePath, name, title, description, license, nsfw, thumbnail), ]) .then(([{channelName, channelClaimId}, validatedClaimName, publishParams]) => { // add channel details to the publish params @@ -155,8 +155,6 @@ module.exports = (app) => { publishParams['channel_name'] = channelName; publishParams['channel_id'] = channelClaimId; } - logger.debug('validated claim name:', validatedClaimName); - logger.debug('publish params:', publishParams); // publish the asset return publish(publishParams, fileName, fileType); })