tested basic client scenarios
This commit is contained in:
parent
592fbb79d8
commit
9a93b3cc8d
3 changed files with 13 additions and 13 deletions
|
@ -58,19 +58,15 @@ module.exports = {
|
|||
},
|
||||
parsePublishApiChannel ({channelName, channelPassword}, user) {
|
||||
logger.debug('publish api parser input:', {channelName, channelPassword, user});
|
||||
// if no channel name provided, publish will be anonymous
|
||||
// if anonymous or '' provided, publish will be anonymous (even if client is logged in)
|
||||
if (channelName === 'anonymous' || channelName === '') {
|
||||
channelName = null;
|
||||
}
|
||||
// if a channel name is provided...
|
||||
if (channelName) {
|
||||
// make sure a password was provided
|
||||
if (!channelPassword) {
|
||||
throw new Error('Channel name provided without password');
|
||||
// make sure a password was provided if no user token is provided
|
||||
if (!user && !channelPassword) {
|
||||
throw new Error('Unauthenticated channel name provided without password');
|
||||
}
|
||||
// if request comes from the client and is logged in
|
||||
// ensure it is the same channel and get the password
|
||||
// if request comes from the client with a token
|
||||
// ensure this publish uses that channel name
|
||||
if (user) {
|
||||
channelName = user.channelName;
|
||||
} ;
|
||||
|
|
|
@ -78,17 +78,20 @@ const publishFileFunctions = {
|
|||
const licenseInput = document.getElementById('publish-license');
|
||||
const nsfwInput = document.getElementById('publish-nsfw');
|
||||
const thumbnailInput = document.getElementById('claim-thumbnail-input');
|
||||
|
||||
return {
|
||||
const channelName = this.returnNullOrChannel();
|
||||
let metadata = {
|
||||
name: nameInput.value.trim(),
|
||||
channelName: this.returnNullOrChannel(),
|
||||
title: titleInput.value.trim(),
|
||||
description: descriptionInput.value.trim(),
|
||||
license: licenseInput.value.trim(),
|
||||
nsfw: nsfwInput.checked,
|
||||
type: stagedFiles[0].type,
|
||||
thumbnail: thumbnailInput.value.trim(),
|
||||
};
|
||||
if (channelName) {
|
||||
metadata['channelName'] = channelName;
|
||||
}
|
||||
return metadata;
|
||||
},
|
||||
appendDataToFormData: function (file, metadata) {
|
||||
var fd = new FormData();
|
||||
|
@ -143,7 +146,7 @@ const publishFileFunctions = {
|
|||
publishStagedFile: function (event) {
|
||||
event.preventDefault(); // prevent default so this script can handle submission
|
||||
const metadata = this.createMetadata();
|
||||
const that = this; // note: necessary ?
|
||||
const that = this;
|
||||
const fileSelectionInputError = document.getElementById('input-error-file-selection');
|
||||
const claimNameError = document.getElementById('input-error-claim-name');
|
||||
const channelSelectError = document.getElementById('input-error-channel-select');
|
||||
|
|
|
@ -125,6 +125,7 @@ module.exports = (app) => {
|
|||
});
|
||||
// route to run a publish request on the daemon
|
||||
app.post('/api/claim-publish', multipartMiddleware, ({ body, files, ip, originalUrl, user }, res) => {
|
||||
logger.debug('api/claim-publish body:', body);
|
||||
let name, fileName, filePath, fileType, nsfw, license, title, description, thumbnail, channelName, channelPassword;
|
||||
// validate the body and files of the request
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue