412 blocked content #428
|
@ -1,4 +1,4 @@
|
||||||
const db = require('../../models');
|
const db = require('../../../../models');
|
||||||
|
|
||||||
const checkChannelAvailability = (name) => {
|
const checkChannelAvailability = (name) => {
|
||||||
return db.Channel
|
return db.Channel
|
|
@ -1,6 +1,6 @@
|
||||||
const checkChannelAvailability = require('../utils/checkChannelAvailability.js');
|
const checkChannelAvailability = require('./checkChannelAvailability.js');
|
||||||
const { sendGATimingEvent } = require('../../utils/googleAnalytics.js');
|
const { sendGATimingEvent } = require('../../../../utils/googleAnalytics.js');
|
||||||
const { handleErrorResponse } = require('../utils/errorHandlers.js');
|
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
31
server/controllers/api/channel/claims/getChannelClaims.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
const db = require('../../../../models');
|
||||||
|
const { returnPaginatedChannelClaims } = require('./channelPagination.js');
|
||||||
|
const NO_CHANNEL = 'NO_CHANNEL';
|
||||||
|
|
||||||
|
const getChannelClaims = (channelName, channelClaimId, page) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
// 1. get the long channel Id (make sure channel exists)
|
||||||
|
db.Certificate.getLongChannelId(channelName, channelClaimId)
|
||||||
|
.then(longChannelClaimId => {
|
||||||
|
if (!longChannelClaimId) {
|
||||||
|
return [null, null, null];
|
||||||
|
}
|
||||||
|
// 2. get the short ID and all claims for that channel
|
||||||
|
return Promise.all([longChannelClaimId, db.Claim.getAllChannelClaims(longChannelClaimId)]);
|
||||||
|
})
|
||||||
|
.then(([longChannelClaimId, channelClaimsArray]) => {
|
||||||
|
if (!longChannelClaimId) {
|
||||||
|
return resolve(NO_CHANNEL);
|
||||||
|
}
|
||||||
|
// 3. format the data for the view, including pagination
|
||||||
|
let paginatedChannelViewData = returnPaginatedChannelClaims(channelName, longChannelClaimId, channelClaimsArray, page);
|
||||||
|
// 4. return all the channel information and contents
|
||||||
|
resolve(paginatedChannelViewData);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = getChannelClaims;
|
|
@ -1,5 +1,5 @@
|
||||||
const { getChannelClaims } = require('../utils/serveHelpers.js');
|
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
|
||||||
const { handleErrorResponse } = require('../utils/errorHandlers.js');
|
const getChannelClaims = require('./getChannelClaims.js');
|
||||||
|
|
||||||
const NO_CHANNEL = 'NO_CHANNEL';
|
const NO_CHANNEL = 'NO_CHANNEL';
|
||||||
|
|
32
server/controllers/api/channel/data/getChannelData.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
const db = require('../../../../models');
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
const NO_CHANNEL = 'NO_CHANNEL';
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
const getChannelData = (channelName, channelClaimId, page) => {
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
return new Promise((resolve, reject) => {
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
// 1. get the long channel Id (make sure channel exists)
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
db.Certificate.getLongChannelId(channelName, channelClaimId)
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
.then(longChannelClaimId => {
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
if (!longChannelClaimId) {
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
return [null, null, null];
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
}
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
// 2. get the short ID and all claims for that channel
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
return Promise.all([longChannelClaimId, db.Certificate.getShortChannelIdFromLongChannelId(longChannelClaimId, channelName)]);
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
})
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
.then(([longChannelClaimId, shortChannelClaimId]) => {
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
if (!longChannelClaimId) {
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
return resolve(NO_CHANNEL);
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
}
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
// 3. return all the channel information
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
resolve({
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
channelName,
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
longChannelClaimId,
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
shortChannelClaimId,
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
});
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
})
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
.catch(error => {
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
reject(error);
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
});
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
});
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
};
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|||||||
|
module.exports = getChannelData;
|
||||||
You could just return an empty array, unless you specifically need You could just return an empty array, unless you specifically need `xxx[3] === null`
good catch. I updated so any specific errors will get thrown (like good catch. I updated so any specific errors will get thrown (like `NO_CHANNEL`), like I did with the claims controllers. That streamlines this chain a lot better.
|
|
@ -1,5 +1,5 @@
|
||||||
const { getChannelData } = require('../utils/serveHelpers.js');
|
const { getChannelData } = require('../../../utils/serveHelpers.js');
|
||||||
const { handleErrorResponse } = require('../utils/errorHandlers.js');
|
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
|
||||||
|
|
||||||
const NO_CHANNEL = 'NO_CHANNEL';
|
const NO_CHANNEL = 'NO_CHANNEL';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { handleErrorResponse } = require('../utils/errorHandlers.js');
|
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
|
||||||
const db = require('../../models/index');
|
const db = require('../../../../models');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const checkClaimAvailability = require('../utils/checkClaimAvailability.js');
|
const checkClaimAvailability = require('../utils/checkClaimAvailability.js');
|
||||||
const { sendGATimingEvent } = require('../../utils/googleAnalytics.js');
|
const { sendGATimingEvent } = require('../../../../utils/googleAnalytics.js');
|
||||||
const { handleErrorResponse } = require('../utils/errorHandlers.js');
|
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { handleErrorResponse } = require('../utils/errorHandlers.js');
|
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
|
||||||
const db = require('../../models/index');
|
const db = require('../../../../models');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const { getClaim } = require('../../lbrynet');
|
const { getClaim } = require('../../../../lbrynet');
|
||||||
const { addGetResultsToFileData, createFileData } = require('../utils/file.js');
|
const { addGetResultsToFileData, createFileData } = require('../../../utils/file.js');
|
||||||
const { handleErrorResponse } = require('../utils/errorHandlers.js');
|
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
|
||||||
const db = require('../../models');
|
const db = require('../../../../models');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { getClaimList } = require('../../lbrynet/index');
|
const { getClaimList } = require('../../../../lbrynet');
|
||||||
const { handleErrorResponse } = require('../utils/errorHandlers.js');
|
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { getClaimId } = require('../utils/serveHelpers.js');
|
const { getClaimId } = require('../../../utils/serveHelpers.js');
|
||||||
const { handleErrorResponse } = require('../utils/errorHandlers.js');
|
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
|
||||||
|
|
||||||
const NO_CHANNEL = 'NO_CHANNEL';
|
const NO_CHANNEL = 'NO_CHANNEL';
|
||||||
const NO_CLAIM = 'NO_CLAIM';
|
const NO_CLAIM = 'NO_CLAIM';
|
|
@ -0,0 +1,40 @@
|
||||||
|
const logger = require('winston');
|
||||||
|
const { details, publishing } = require('../../../../../config/siteConfig.js');
|
||||||
|
|
||||||
|
const createBasicPublishParams = (filePath, name, title, description, license, nsfw, thumbnail) => {
|
||||||
|
logger.debug(`Creating Publish Parameters`);
|
||||||
|
// provide defaults for title
|
||||||
|
if (title === null || title.trim() === '') {
|
||||||
|
title = name;
|
||||||
|
}
|
||||||
|
// provide default for description
|
||||||
|
if (description === null || description.trim() === '') {
|
||||||
|
description = '';
|
||||||
|
}
|
||||||
|
// provide default for license
|
||||||
|
if (license === null || license.trim() === '') {
|
||||||
|
license = ' '; // default to empty string
|
||||||
|
}
|
||||||
|
// create the publish params
|
||||||
|
const publishParams = {
|
||||||
|
name,
|
||||||
|
file_path: filePath,
|
||||||
|
bid : 0.01,
|
||||||
|
metadata : {
|
||||||
|
description,
|
||||||
|
title,
|
||||||
|
author : details.title,
|
||||||
|
language: 'en',
|
||||||
|
license,
|
||||||
|
nsfw,
|
||||||
|
},
|
||||||
|
claim_address: publishing.primaryClaimAddress,
|
||||||
|
};
|
||||||
|
// add thumbnail to channel if video
|
||||||
|
if (thumbnail) {
|
||||||
|
publishParams['metadata']['thumbnail'] = thumbnail;
|
||||||
|
}
|
||||||
|
return publishParams;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = createBasicPublishParams;
|
|
@ -0,0 +1,28 @@
|
||||||
|
const logger = require('winston');
|
||||||
|
const { details, publishing } = require('../../../../../config/siteConfig.js');
|
||||||
|
|
||||||
|
const createThumbnailPublishParams = (thumbnailFilePath, claimName, license, nsfw) => {
|
||||||
|
if (!thumbnailFilePath) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
logger.debug(`Creating Thumbnail Publish Parameters`);
|
||||||
|
// create the publish params
|
||||||
|
return {
|
||||||
|
name : `${claimName}-thumb`,
|
||||||
|
file_path: thumbnailFilePath,
|
||||||
|
bid : 0.01,
|
||||||
|
metadata : {
|
||||||
|
title : `${claimName} thumbnail`,
|
||||||
|
description: `a thumbnail for ${claimName}`,
|
||||||
|
author : details.title,
|
||||||
|
language : 'en',
|
||||||
|
license,
|
||||||
|
nsfw,
|
||||||
|
},
|
||||||
|
claim_address: publishing.primaryClaimAddress,
|
||||||
|
channel_name : publishing.thumbnailChannel,
|
||||||
|
channel_id : publishing.thumbnailChannelId,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = createThumbnailPublishParams;
|
|
@ -1,15 +1,13 @@
|
||||||
const { details: { host } } = require('../../../config/siteConfig.js');
|
const { details: { host } } = require('../../../../../config/siteConfig.js');
|
||||||
const { authenticateUser } = require('../../auth/authentication.js');
|
const { authenticateUser } = require('../../../../auth/authentication.js');
|
||||||
const { sendGATimingEvent } = require('../../utils/googleAnalytics.js');
|
const { sendGATimingEvent } = require('../../../../utils/googleAnalytics.js');
|
||||||
const { handleErrorResponse } = require('../utils/errorHandlers.js');
|
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
|
||||||
const checkClaimAvailability = require('../utils/checkClaimAvailability');
|
const publish = require('./publish.js');
|
||||||
const publish = require('../utils/publish.js');
|
const createBasicPublishParams = require('./createBasicPublishParams.js');
|
||||||
const {
|
const createThumbnailPublishParams = require('./createThumbnailPublishParams.js');
|
||||||
createBasicPublishParams,
|
const parsePublishApiRequestBody = require('./parsePublishApiRequestBody.js');
|
||||||
createThumbnailPublishParams,
|
const parsePublishApiRequestFiles = require('./parsePublishApiRequestFiles.js');
|
||||||
parsePublishApiRequestBody,
|
const checkClaimAvailability = require('../utils/checkClaimAvailability.js');
|
||||||
parsePublishApiRequestFiles,
|
|
||||||
} = require('../utils/publishHelpers.js');
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
const parsePublishApiRequestBody = ({name, nsfw, license, title, description, thumbnail}) => {
|
||||||
|
// validate name
|
||||||
|
if (!name) {
|
||||||
|
throw new Error('no name field found in request');
|
||||||
|
}
|
||||||
|
const invalidNameCharacters = /[^A-Za-z0-9,-]/.exec(name);
|
||||||
|
if (invalidNameCharacters) {
|
||||||
|
throw new Error('The claim name you provided is not allowed. Only the following characters are allowed: A-Z, a-z, 0-9, and "-"');
|
||||||
|
}
|
||||||
|
// optional parameters
|
||||||
|
nsfw = (nsfw === 'true');
|
||||||
|
license = license || null;
|
||||||
|
title = title || null;
|
||||||
|
description = description || null;
|
||||||
|
thumbnail = thumbnail || null;
|
||||||
|
// return results
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
nsfw,
|
||||||
|
license,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
thumbnail,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = parsePublishApiRequestBody;
|
|
@ -0,0 +1,34 @@
|
||||||
|
const validateFileTypeAndSize = require('./validateFileTypeAndSize.js');
|
||||||
|
|
||||||
|
const parsePublishApiRequestFiles = ({file, thumbnail}) => {
|
||||||
|
// make sure a file was provided
|
||||||
|
if (!file) {
|
||||||
|
throw new Error('no file with key of [file] found in request');
|
||||||
|
}
|
||||||
|
if (!file.path) {
|
||||||
|
throw new Error('no file path found');
|
||||||
|
}
|
||||||
|
if (!file.type) {
|
||||||
|
throw new Error('no file type found');
|
||||||
|
}
|
||||||
|
if (!file.size) {
|
||||||
|
throw new Error('no file type found');
|
||||||
|
}
|
||||||
|
// validate the file name
|
||||||
|
if (/'/.test(file.name)) {
|
||||||
|
throw new Error('apostrophes are not allowed in the file name');
|
||||||
|
}
|
||||||
|
// validate the file
|
||||||
|
validateFileTypeAndSize(file);
|
||||||
|
// return results
|
||||||
|
return {
|
||||||
|
fileName : file.name,
|
||||||
|
filePath : file.path,
|
||||||
|
fileType : file.type,
|
||||||
|
thumbnailFileName: (thumbnail ? thumbnail.name : null),
|
||||||
|
thumbnailFilePath: (thumbnail ? thumbnail.path : null),
|
||||||
|
thumbnailFileType: (thumbnail ? thumbnail.type : null),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = parsePublishApiRequestFiles;
|
|
@ -1,6 +1,6 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const db = require('../../models');
|
const db = require('../../../../models');
|
||||||
const { publishClaim } = require('../../lbrynet');
|
const { publishClaim } = require('../../../../lbrynet');
|
||||||
const deleteFile = require('./deleteFile.js');
|
const deleteFile = require('./deleteFile.js');
|
||||||
|
|
||||||
const publish = (publishParams, fileName, fileType) => {
|
const publish = (publishParams, fileName, fileType) => {
|
|
@ -0,0 +1,33 @@
|
||||||
|
const logger = require('winston');
|
||||||
|
|
||||||
|
const validateFileTypeAndSize = (file) => {
|
||||||
|
// check file type and size
|
||||||
|
switch (file.type) {
|
||||||
|
case 'image/jpeg':
|
||||||
|
case 'image/jpg':
|
||||||
|
case 'image/png':
|
||||||
|
if (file.size > 10000000) {
|
||||||
|
logger.debug('publish > file validation > .jpeg/.jpg/.png was too big');
|
||||||
|
throw new Error('Sorry, images are limited to 10 megabytes.');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'image/gif':
|
||||||
|
if (file.size > 50000000) {
|
||||||
|
logger.debug('publish > file validation > .gif was too big');
|
||||||
|
throw new Error('Sorry, .gifs are limited to 50 megabytes.');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'video/mp4':
|
||||||
|
if (file.size > 50000000) {
|
||||||
|
logger.debug('publish > file validation > .mp4 was too big');
|
||||||
|
throw new Error('Sorry, videos are limited to 50 megabytes.');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
logger.debug('publish > file validation > unrecognized file type');
|
||||||
|
throw new Error('The ' + file.type + ' content type is not supported. Only, .jpeg, .png, .gif, and .mp4 files are currently supported.');
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = validateFileTypeAndSize;
|
|
@ -1,5 +1,5 @@
|
||||||
const { resolveUri } = require('../../lbrynet/index');
|
const { resolveUri } = require('../../../../lbrynet/index');
|
||||||
const { handleErrorResponse } = require('../utils/errorHandlers.js');
|
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { handleErrorResponse } = require('../utils/errorHandlers.js');
|
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
|
||||||
const db = require('../../models/index');
|
const db = require('../../../../models');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const db = require('../../models/index');
|
const db = require('../../../../models');
|
||||||
const { publishing: { primaryClaimAddress, additionalClaimAddresses } } = require('../../../config/siteConfig.js');
|
const { publishing: { primaryClaimAddress, additionalClaimAddresses } } = require('../../../../../config/siteConfig.js');
|
||||||
const Sequelize = require('sequelize');
|
const Sequelize = require('sequelize');
|
||||||
const Op = Sequelize.Op;
|
const Op = Sequelize.Op;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { handleErrorResponse } = require('../utils/errorHandlers.js');
|
const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
|
||||||
const db = require('../../models/index');
|
const db = require('../../../../models');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
const { sendGAServeEvent } = require('../../utils/googleAnalytics');
|
const { sendGAServeEvent } = require('../../../utils/googleAnalytics');
|
||||||
const {
|
const {
|
||||||
determineResponseType,
|
determineResponseType,
|
||||||
logRequestData,
|
logRequestData,
|
||||||
getClaimIdAndServeAsset,
|
getClaimIdAndServeAsset,
|
||||||
} = require('../utils/serve.js');
|
} = require('../../utils/serve.js');
|
||||||
const lbryUri = require('../utils/lbryUri.js');
|
const lbryUri = require('../../utils/lbryUri.js');
|
||||||
const handleShowRender = require('../../render/build/handleShowRender.js');
|
const handleShowRender = require('../../../render/build/handleShowRender.js');
|
||||||
const SERVE = 'SERVE';
|
const SERVE = 'SERVE';
|
||||||
|
|
||||||
/*
|
/*
|
|
@ -1,12 +1,12 @@
|
||||||
const { sendGAServeEvent } = require('../../utils/googleAnalytics');
|
const { sendGAServeEvent } = require('../../../utils/googleAnalytics');
|
||||||
const {
|
const {
|
||||||
determineResponseType,
|
determineResponseType,
|
||||||
flipClaimNameAndIdForBackwardsCompatibility,
|
flipClaimNameAndIdForBackwardsCompatibility,
|
||||||
logRequestData,
|
logRequestData,
|
||||||
getClaimIdAndServeAsset,
|
getClaimIdAndServeAsset,
|
||||||
} = require('../utils/serve.js');
|
} = require('../../utils/serve.js');
|
||||||
const lbryUri = require('../utils/lbryUri.js');
|
const lbryUri = require('../../utils/lbryUri.js');
|
||||||
const handleShowRender = require('../../render/build/handleShowRender.js');
|
const handleShowRender = require('../../../render/build/handleShowRender.js');
|
||||||
|
|
||||||
const SERVE = 'SERVE';
|
const SERVE = 'SERVE';
|
||||||
|
|
|
@ -1,165 +0,0 @@
|
||||||
const logger = require('winston');
|
|
||||||
const { details, publishing } = require('../../../config/siteConfig.js');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
parsePublishApiRequestBody ({name, nsfw, license, title, description, thumbnail}) {
|
|
||||||
// validate name
|
|
||||||
if (!name) {
|
|
||||||
throw new Error('no name field found in request');
|
|
||||||
}
|
|
||||||
const invalidNameCharacters = /[^A-Za-z0-9,-]/.exec(name);
|
|
||||||
if (invalidNameCharacters) {
|
|
||||||
throw new Error('The claim name you provided is not allowed. Only the following characters are allowed: A-Z, a-z, 0-9, and "-"');
|
|
||||||
}
|
|
||||||
// optional parameters
|
|
||||||
nsfw = (nsfw === 'true');
|
|
||||||
license = license || null;
|
|
||||||
title = title || null;
|
|
||||||
description = description || null;
|
|
||||||
thumbnail = thumbnail || null;
|
|
||||||
// return results
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
nsfw,
|
|
||||||
license,
|
|
||||||
title,
|
|
||||||
description,
|
|
||||||
thumbnail,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
parsePublishApiRequestFiles ({file, thumbnail}) {
|
|
||||||
// make sure a file was provided
|
|
||||||
if (!file) {
|
|
||||||
throw new Error('no file with key of [file] found in request');
|
|
||||||
}
|
|
||||||
if (!file.path) {
|
|
||||||
throw new Error('no file path found');
|
|
||||||
}
|
|
||||||
if (!file.type) {
|
|
||||||
throw new Error('no file type found');
|
|
||||||
}
|
|
||||||
if (!file.size) {
|
|
||||||
throw new Error('no file type found');
|
|
||||||
}
|
|
||||||
// validate the file name
|
|
||||||
if (/'/.test(file.name)) {
|
|
||||||
throw new Error('apostrophes are not allowed in the file name');
|
|
||||||
}
|
|
||||||
// validate the file
|
|
||||||
module.exports.validateFileTypeAndSize(file);
|
|
||||||
// return results
|
|
||||||
return {
|
|
||||||
fileName : file.name,
|
|
||||||
filePath : file.path,
|
|
||||||
fileType : file.type,
|
|
||||||
thumbnailFileName: (thumbnail ? thumbnail.name : null),
|
|
||||||
thumbnailFilePath: (thumbnail ? thumbnail.path : null),
|
|
||||||
thumbnailFileType: (thumbnail ? thumbnail.type : null),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
validateFileTypeAndSize (file) {
|
|
||||||
// check file type and size
|
|
||||||
switch (file.type) {
|
|
||||||
case 'image/jpeg':
|
|
||||||
case 'image/jpg':
|
|
||||||
case 'image/png':
|
|
||||||
if (file.size > 10000000) {
|
|
||||||
logger.debug('publish > file validation > .jpeg/.jpg/.png was too big');
|
|
||||||
throw new Error('Sorry, images are limited to 10 megabytes.');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'image/gif':
|
|
||||||
if (file.size > 50000000) {
|
|
||||||
logger.debug('publish > file validation > .gif was too big');
|
|
||||||
throw new Error('Sorry, .gifs are limited to 50 megabytes.');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'video/mp4':
|
|
||||||
if (file.size > 50000000) {
|
|
||||||
logger.debug('publish > file validation > .mp4 was too big');
|
|
||||||
throw new Error('Sorry, videos are limited to 50 megabytes.');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
logger.debug('publish > file validation > unrecognized file type');
|
|
||||||
throw new Error('The ' + file.type + ' content type is not supported. Only, .jpeg, .png, .gif, and .mp4 files are currently supported.');
|
|
||||||
}
|
|
||||||
return file;
|
|
||||||
},
|
|
||||||
createBasicPublishParams (filePath, name, title, description, license, nsfw, thumbnail) {
|
|
||||||
logger.debug(`Creating Publish Parameters`);
|
|
||||||
// provide defaults for title
|
|
||||||
if (title === null || title.trim() === '') {
|
|
||||||
title = name;
|
|
||||||
}
|
|
||||||
// provide default for description
|
|
||||||
if (description === null || description.trim() === '') {
|
|
||||||
description = '';
|
|
||||||
}
|
|
||||||
// provide default for license
|
|
||||||
if (license === null || license.trim() === '') {
|
|
||||||
license = ' '; // default to empty string
|
|
||||||
}
|
|
||||||
// create the publish params
|
|
||||||
const publishParams = {
|
|
||||||
name,
|
|
||||||
file_path: filePath,
|
|
||||||
bid : 0.01,
|
|
||||||
metadata : {
|
|
||||||
description,
|
|
||||||
title,
|
|
||||||
author : details.title,
|
|
||||||
language: 'en',
|
|
||||||
license,
|
|
||||||
nsfw,
|
|
||||||
},
|
|
||||||
claim_address: publishing.primaryClaimAddress,
|
|
||||||
};
|
|
||||||
// add thumbnail to channel if video
|
|
||||||
if (thumbnail) {
|
|
||||||
publishParams['metadata']['thumbnail'] = thumbnail;
|
|
||||||
}
|
|
||||||
return publishParams;
|
|
||||||
},
|
|
||||||
createThumbnailPublishParams (thumbnailFilePath, claimName, license, nsfw) {
|
|
||||||
if (!thumbnailFilePath) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
logger.debug(`Creating Thumbnail Publish Parameters`);
|
|
||||||
// create the publish params
|
|
||||||
return {
|
|
||||||
name : `${claimName}-thumb`,
|
|
||||||
file_path: thumbnailFilePath,
|
|
||||||
bid : 0.01,
|
|
||||||
metadata : {
|
|
||||||
title : `${claimName} thumbnail`,
|
|
||||||
description: `a thumbnail for ${claimName}`,
|
|
||||||
author : details.title,
|
|
||||||
language : 'en',
|
|
||||||
license,
|
|
||||||
nsfw,
|
|
||||||
},
|
|
||||||
claim_address: publishing.primaryClaimAddress,
|
|
||||||
channel_name : publishing.thumbnailChannel,
|
|
||||||
channel_id : publishing.thumbnailChannelId,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
addGetResultsToFileData (fileInfo, getResult) {
|
|
||||||
fileInfo.fileName = getResult.file_name;
|
|
||||||
fileInfo.filePath = getResult.download_path;
|
|
||||||
return fileInfo;
|
|
||||||
},
|
|
||||||
createFileData ({ name, claimId, outpoint, height, address, nsfw, contentType }) {
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
claimId,
|
|
||||||
outpoint,
|
|
||||||
height,
|
|
||||||
address,
|
|
||||||
fileName: '',
|
|
||||||
filePath: '',
|
|
||||||
fileType: contentType,
|
|
||||||
nsfw,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,6 +1,5 @@
|
||||||
const db = require('../../models/index');
|
const db = require('../../models');
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const { returnPaginatedChannelClaims } = require('./channelPagination.js');
|
|
||||||
|
|
||||||
const NO_CHANNEL = 'NO_CHANNEL';
|
const NO_CHANNEL = 'NO_CHANNEL';
|
||||||
const NO_CLAIM = 'NO_CLAIM';
|
const NO_CLAIM = 'NO_CLAIM';
|
||||||
|
@ -53,58 +52,6 @@ module.exports = {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getChannelData (channelName, channelClaimId, page) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
// 1. get the long channel Id (make sure channel exists)
|
|
||||||
db.Certificate.getLongChannelId(channelName, channelClaimId)
|
|
||||||
.then(longChannelClaimId => {
|
|
||||||
if (!longChannelClaimId) {
|
|
||||||
return [null, null, null];
|
|
||||||
}
|
|
||||||
// 2. get the short ID and all claims for that channel
|
|
||||||
return Promise.all([longChannelClaimId, db.Certificate.getShortChannelIdFromLongChannelId(longChannelClaimId, channelName)]);
|
|
||||||
})
|
|
||||||
.then(([longChannelClaimId, shortChannelClaimId]) => {
|
|
||||||
if (!longChannelClaimId) {
|
|
||||||
return resolve(NO_CHANNEL);
|
|
||||||
}
|
|
||||||
// 3. return all the channel information
|
|
||||||
resolve({
|
|
||||||
channelName,
|
|
||||||
longChannelClaimId,
|
|
||||||
shortChannelClaimId,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
getChannelClaims (channelName, channelClaimId, page) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
// 1. get the long channel Id (make sure channel exists)
|
|
||||||
db.Certificate.getLongChannelId(channelName, channelClaimId)
|
|
||||||
.then(longChannelClaimId => {
|
|
||||||
if (!longChannelClaimId) {
|
|
||||||
return [null, null, null];
|
|
||||||
}
|
|
||||||
// 2. get the short ID and all claims for that channel
|
|
||||||
return Promise.all([longChannelClaimId, db.Claim.getAllChannelClaims(longChannelClaimId)]);
|
|
||||||
})
|
|
||||||
.then(([longChannelClaimId, channelClaimsArray]) => {
|
|
||||||
if (!longChannelClaimId) {
|
|
||||||
return resolve(NO_CHANNEL);
|
|
||||||
}
|
|
||||||
// 3. format the data for the view, including pagination
|
|
||||||
let paginatedChannelViewData = returnPaginatedChannelClaims(channelName, longChannelClaimId, channelClaimsArray, page);
|
|
||||||
// 4. return all the channel information and contents
|
|
||||||
resolve(paginatedChannelViewData);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
getLocalFileRecord (claimId, name) {
|
getLocalFileRecord (claimId, name) {
|
||||||
return db.File.findOne({where: {claimId, name}})
|
return db.File.findOne({where: {claimId, name}})
|
||||||
.then(file => {
|
.then(file => {
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
const channelAvailability = require('../../controllers/api/channelAvailability');
|
const channelAvailability = require('../../controllers/api/channel/availability');
|
||||||
const channelClaims = require('../../controllers/api/channelClaims');
|
const channelClaims = require('../../controllers/api/channel/claims');
|
||||||
const channelData = require('../../controllers/api/channelData');
|
const channelData = require('../../controllers/api/channel/data');
|
||||||
const channelShortId = require('../../controllers/api/channelShortId');
|
const channelShortId = require('../../controllers/api/channel/shortId');
|
||||||
const claimAvailability = require('../../controllers/api/claimAvailability');
|
const claimAvailability = require('../../controllers/api/claim/availability');
|
||||||
const claimData = require('../../controllers/api/claimData');
|
const claimData = require('../../controllers/api/claim/data/');
|
||||||
const claimGet = require('../../controllers/api/claimGet');
|
const claimGet = require('../../controllers/api/claim/get');
|
||||||
const claimLongId = require('../../controllers/api/claimLongId');
|
const claimLongId = require('../../controllers/api/claim/longId');
|
||||||
const claimPublish = require('../../controllers/api/claimPublish');
|
const claimPublish = require('../../controllers/api/claim/publish');
|
||||||
const claimResolve = require('../../controllers/api/claimResolve');
|
const claimResolve = require('../../controllers/api/claim/resolve');
|
||||||
const claimShortId = require('../../controllers/api/claimShortId');
|
const claimShortId = require('../../controllers/api/claim/shortId');
|
||||||
const claimList = require('../../controllers/api/claimList');
|
const claimList = require('../../controllers/api/claim/list');
|
||||||
const fileAvailability = require('../../controllers/api/fileAvailability');
|
const fileAvailability = require('../../controllers/api/file/availability');
|
||||||
|
|
||||||
const multipartMiddleware = require('../utils/multipartMiddleware');
|
const multipartMiddleware = require('../utils/multipartMiddleware');
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const serveAssetByClaim = require('../../controllers/assets/serveAssetByClaim');
|
const serveAssetByClaim = require('../../controllers/assets/serveByClaim');
|
||||||
const serveAssetByIdentifierAndClaim = require('../../controllers/assets/serveAssetByIdentifierAndClaim');
|
const serveAssetByIdentifierAndClaim = require('../../controllers/assets/serveByIdentifierAndClaim');
|
||||||
|
|
||||||
module.exports = (app, db) => {
|
module.exports = (app, db) => {
|
||||||
app.get('/:identifier/:claim', serveAssetByIdentifierAndClaim);
|
app.get('/:identifier/:claim', serveAssetByIdentifierAndClaim);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const PassportLocalStrategy = require('passport-local').Strategy;
|
const PassportLocalStrategy = require('passport-local').Strategy;
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const db = require('../../models/index');
|
const db = require('../../models');
|
||||||
|
|
||||||
const returnUserAndChannelInfo = (userInstance) => {
|
const returnUserAndChannelInfo = (userInstance) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
|
@ -1,27 +1,34 @@
|
||||||
const chai = require('chai');
|
const chai = require('chai');
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
|
|
||||||
describe('publishHelpers.js', function () {
|
describe('publish utils', function () {
|
||||||
const publishHelpers = require('../../server/controllers/utils/publishHelpers.js');
|
|
||||||
|
|
||||||
describe('#parsePublishApiRequestBody()', function () {
|
describe('#parsePublishApiRequestBody()', function () {
|
||||||
|
const parsePublishApiRequestBody = require('../../../server/controllers/api/claim/publish/parsePublishApiRequestBody.js');
|
||||||
|
|
||||||
it('should throw an error if no body', function () {
|
it('should throw an error if no body', function () {
|
||||||
expect(publishHelpers.parsePublishApiRequestBody.bind(this, null)).to.throw();
|
expect(parsePublishApiRequestBody.bind(this, null)).to.throw();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if no body.name', function () {
|
it('should throw an error if no body.name', function () {
|
||||||
const bodyNoName = {};
|
const bodyNoName = {};
|
||||||
expect(publishHelpers.parsePublishApiRequestBody.bind(this, bodyNoName)).to.throw();
|
expect(parsePublishApiRequestBody.bind(this, bodyNoName)).to.throw();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#parsePublishApiRequestFiles()', function () {
|
describe('#parsePublishApiRequestFiles()', function () {
|
||||||
|
const parsePublishApiRequestFiles = require('../../../server/controllers/api/claim/publish/parsePublishApiRequestFiles.js');
|
||||||
|
|
||||||
it('should throw an error if no files', function () {
|
it('should throw an error if no files', function () {
|
||||||
expect(publishHelpers.parsePublishApiRequestFiles.bind(this, null)).to.throw();
|
expect(parsePublishApiRequestFiles.bind(this, null)).to.throw();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if no files.file', function () {
|
it('should throw an error if no files.file', function () {
|
||||||
const filesNoFile = {};
|
const filesNoFile = {};
|
||||||
expect(publishHelpers.parsePublishApiRequestFiles.bind(this, filesNoFile)).to.throw();
|
expect(parsePublishApiRequestFiles.bind(this, filesNoFile)).to.throw();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if file.size is too large', function () {
|
it('should throw an error if file.size is too large', function () {
|
||||||
const filesTooBig = {
|
const filesTooBig = {
|
||||||
file: {
|
file: {
|
||||||
|
@ -31,8 +38,9 @@ describe('publishHelpers.js', function () {
|
||||||
size: 10000001,
|
size: 10000001,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
expect(publishHelpers.parsePublishApiRequestFiles.bind(this, filesTooBig)).to.throw();
|
expect(parsePublishApiRequestFiles.bind(this, filesTooBig)).to.throw();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw error if not an accepted file type', function () {
|
it('should throw error if not an accepted file type', function () {
|
||||||
const filesWrongType = {
|
const filesWrongType = {
|
||||||
file: {
|
file: {
|
||||||
|
@ -42,8 +50,9 @@ describe('publishHelpers.js', function () {
|
||||||
size: 10000000,
|
size: 10000000,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
expect(publishHelpers.parsePublishApiRequestFiles.bind(this, filesWrongType)).to.throw();
|
expect(parsePublishApiRequestFiles.bind(this, filesWrongType)).to.throw();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw NO error if no problems', function () {
|
it('should throw NO error if no problems', function () {
|
||||||
const filesNoProblems = {
|
const filesNoProblems = {
|
||||||
file: {
|
file: {
|
||||||
|
@ -53,7 +62,7 @@ describe('publishHelpers.js', function () {
|
||||||
size: 10000000,
|
size: 10000000,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
expect(publishHelpers.parsePublishApiRequestFiles.bind(this, filesNoProblems)).to.not.throw();
|
expect(parsePublishApiRequestFiles.bind(this, filesNoProblems)).to.not.throw();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
You could just return an empty array, unless you specifically need
xxx[3] === null