From 9e1c7afa55d2a9f37ba5108ec0bf0b4adf11dcee Mon Sep 17 00:00:00 2001 From: bill bittner Date: Sat, 23 Jun 2018 10:57:04 -0700 Subject: [PATCH 1/5] added publish request info logging --- server/controllers/api/claim/publish/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/controllers/api/claim/publish/index.js b/server/controllers/api/claim/publish/index.js index 15e48ee9..c7d5686d 100644 --- a/server/controllers/api/claim/publish/index.js +++ b/server/controllers/api/claim/publish/index.js @@ -1,3 +1,5 @@ +const logger = require('winston'); + const { details: { host } } = require('@config/siteConfig'); const { sendGATimingEvent } = require('../../../../utils/googleAnalytics.js'); @@ -20,6 +22,12 @@ const authenticateUser = require('./authentication.js'); */ const claimPublish = ({ body, files, headers, ip, originalUrl, user }, res) => { + // logging + logger.info('PUBLISH REQUEST:', { + headers, + ip, + body, + }); // define variables let channelName, channelId, channelPassword, description, fileName, filePath, fileType, gaStartTime, license, name, nsfw, thumbnail, thumbnailFileName, thumbnailFilePath, thumbnailFileType, title; // record the start time of the request From f9db87109ca83fd2da2aa04770e8570c30317c6c Mon Sep 17 00:00:00 2001 From: bill bittner Date: Sat, 23 Jun 2018 13:19:58 -0700 Subject: [PATCH 2/5] added a check on api/claim/publish for disabled publishing --- server/controllers/api/claim/publish/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/controllers/api/claim/publish/index.js b/server/controllers/api/claim/publish/index.js index c7d5686d..bb3890e1 100644 --- a/server/controllers/api/claim/publish/index.js +++ b/server/controllers/api/claim/publish/index.js @@ -1,6 +1,6 @@ const logger = require('winston'); -const { details: { host } } = require('@config/siteConfig'); +const { details: { host }, publishing: { disabled, disabledMessage } } = require('@config/siteConfig'); const { sendGATimingEvent } = require('../../../../utils/googleAnalytics.js'); @@ -28,6 +28,13 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user }, res) => { ip, body, }); + // check for disabled publishing + if (disabled) { + return res.status(400).json({ + success: false, + message: disabledMessage + }); + } // define variables let channelName, channelId, channelPassword, description, fileName, filePath, fileType, gaStartTime, license, name, nsfw, thumbnail, thumbnailFileName, thumbnailFilePath, thumbnailFileType, title; // record the start time of the request From 391592f1b8b9434143fe85c741b5f56bf4bcadf3 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Sat, 23 Jun 2018 13:53:35 -0700 Subject: [PATCH 3/5] updated response code to 503 for disabled publishing --- server/controllers/api/claim/publish/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/controllers/api/claim/publish/index.js b/server/controllers/api/claim/publish/index.js index bb3890e1..7d42106a 100644 --- a/server/controllers/api/claim/publish/index.js +++ b/server/controllers/api/claim/publish/index.js @@ -24,13 +24,13 @@ const authenticateUser = require('./authentication.js'); const claimPublish = ({ body, files, headers, ip, originalUrl, user }, res) => { // logging logger.info('PUBLISH REQUEST:', { - headers, ip, + headers, body, }); // check for disabled publishing if (disabled) { - return res.status(400).json({ + return res.status(503).json({ success: false, message: disabledMessage }); From 5db0d3f6b884169f008a5a59c6deab2401f3d5b0 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Sat, 23 Jun 2018 14:12:50 -0700 Subject: [PATCH 4/5] added a route to return publishing configs --- .../api/config/site/publishing/index.js | 29 +++++++++++++++++++ server/routes/api/index.js | 3 ++ 2 files changed, 32 insertions(+) create mode 100644 server/controllers/api/config/site/publishing/index.js diff --git a/server/controllers/api/config/site/publishing/index.js b/server/controllers/api/config/site/publishing/index.js new file mode 100644 index 00000000..08e60bf3 --- /dev/null +++ b/server/controllers/api/config/site/publishing/index.js @@ -0,0 +1,29 @@ +const { publishing: { + primaryClaimAddress, + uploadDirectory, + thumbnailChannel, + thumbnailChannelId, + additionalClaimAddresses, + disabled, + disabledMessage +} } = require('@config/siteConfig'); + +/* + + route to see if publishing is enabled + +*/ + +const publishingConfig = (req, res) => { + return res.status(200).json({ + primaryClaimAddress, + uploadDirectory, + thumbnailChannel, + thumbnailChannelId, + additionalClaimAddresses, + disabled, + disabledMessage + }); +}; + +module.exports = publishingConfig; diff --git a/server/routes/api/index.js b/server/routes/api/index.js index 0aabd472..05c4973c 100644 --- a/server/routes/api/index.js +++ b/server/routes/api/index.js @@ -13,6 +13,7 @@ const claimResolve = require('../../controllers/api/claim/resolve'); const claimShortId = require('../../controllers/api/claim/shortId'); const fileAvailability = require('../../controllers/api/file/availability'); const userPassword = require('../../controllers/api/user/password'); +const publishingConfig = require('../../controllers/api/config/site/publishing'); const multipartMiddleware = require('../utils/multipartMiddleware'); @@ -36,4 +37,6 @@ module.exports = (app) => { app.get('/api/file/availability/:name/:claimId', fileAvailability); // user routes app.put('/api/user/password/', userPassword); + // configs + app.get('/api/config/site/publishing', publishingConfig); }; From 35f16031d5c07c4b79c957d8ee9bf7c9eb5ca53c Mon Sep 17 00:00:00 2001 From: bill bittner Date: Sat, 23 Jun 2018 19:52:19 -0700 Subject: [PATCH 5/5] centered publish-disabled message --- .../build/containers/PublishDisabledMessage/view.js | 8 ++++++-- client/scss/all.scss | 1 + client/scss/containers/_publish-disabled-message.scss | 11 +++++++++++ client/src/containers/PublishDisabledMessage/view.jsx | 8 +++++--- 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 client/scss/containers/_publish-disabled-message.scss diff --git a/client/build/containers/PublishDisabledMessage/view.js b/client/build/containers/PublishDisabledMessage/view.js index 24487939..7ef8f198 100644 --- a/client/build/containers/PublishDisabledMessage/view.js +++ b/client/build/containers/PublishDisabledMessage/view.js @@ -40,11 +40,15 @@ function (_React$Component) { key: "render", value: function render() { var message = this.props.message; - return _react.default.createElement("div", null, _react.default.createElement("p", { + return _react.default.createElement("div", { + className: 'publish-disabled-message' + }, _react.default.createElement("div", { + className: 'message' + }, _react.default.createElement("p", { className: 'text--secondary' }, "Publishing is currently disabled."), _react.default.createElement("p", { className: 'text--secondary' - }, message)); + }, message))); } }]); diff --git a/client/scss/all.scss b/client/scss/all.scss index 6675e5c5..e2da3336 100644 --- a/client/scss/all.scss +++ b/client/scss/all.scss @@ -40,6 +40,7 @@ @import 'containers/_dropzone'; @import 'containers/_publish-url-input'; @import 'containers/_publish-status'; +@import 'containers/_publish-disabled-message'; @import '_media-queries'; diff --git a/client/scss/containers/_publish-disabled-message.scss b/client/scss/containers/_publish-disabled-message.scss new file mode 100644 index 00000000..66bdba7c --- /dev/null +++ b/client/scss/containers/_publish-disabled-message.scss @@ -0,0 +1,11 @@ +.publish-disabled-message { + // fill the parent flex container + flex: 1 0 auto; + // be a flex container for children + display: flex; + flex-direction: column; + justify-content: center; + .message { + text-align: center; + } +} diff --git a/client/src/containers/PublishDisabledMessage/view.jsx b/client/src/containers/PublishDisabledMessage/view.jsx index b48271de..355ce75d 100644 --- a/client/src/containers/PublishDisabledMessage/view.jsx +++ b/client/src/containers/PublishDisabledMessage/view.jsx @@ -4,9 +4,11 @@ class PublishDisabledMessage extends React.Component { render () { const message = this.props.message; return ( -
-

Publishing is currently disabled.

-

{message}

+
+
+

Publishing is currently disabled.

+

{message}

+
); }