Merge pull request #490 from lbryio/publishing-configs-check

Publishing configs route
This commit is contained in:
Bill Bittner 2018-06-25 12:09:34 -07:00 committed by GitHub
commit 47a096eb26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 71 additions and 6 deletions

View file

@ -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)));
}
}]);

View file

@ -40,6 +40,7 @@
@import 'containers/_dropzone';
@import 'containers/_publish-url-input';
@import 'containers/_publish-status';
@import 'containers/_publish-disabled-message';
@import '_media-queries';

View file

@ -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;
}
}

View file

@ -4,10 +4,12 @@ class PublishDisabledMessage extends React.Component {
render () {
const message = this.props.message;
return (
<div>
<div className={'publish-disabled-message'}>
<div className={'message'}>
<p className={'text--secondary'}>Publishing is currently disabled.</p>
<p className={'text--secondary'}>{message}</p>
</div>
</div>
);
}
}

View file

@ -1,4 +1,6 @@
const { details: { host } } = require('@config/siteConfig');
const logger = require('winston');
const { details: { host }, publishing: { disabled, disabledMessage } } = require('@config/siteConfig');
const { sendGATimingEvent } = require('../../../../utils/googleAnalytics.js');
@ -20,6 +22,19 @@ const authenticateUser = require('./authentication.js');
*/
const claimPublish = ({ body, files, headers, ip, originalUrl, user }, res) => {
// logging
logger.info('PUBLISH REQUEST:', {
ip,
headers,
body,
});
// check for disabled publishing
if (disabled) {
return res.status(503).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

View file

@ -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;

View file

@ -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);
};