'use strict'
+const constants = require('../../../initializers/constants')
const videosValidators = require('../videos')
const miscValidators = require('../misc')
+const ENDPOINT_ACTIONS = constants.REQUEST_ENDPOINT_ACTIONS[constants.REQUEST_ENDPOINTS.VIDEOS]
+
const remoteVideosValidators = {
isEachRemoteRequestVideosValid
}
const video = request.data
return (
isRequestTypeAddValid(request.type) &&
+ isCommonVideoAttrbiutesValid(video) &&
videosValidators.isVideoAuthorValid(video.author) &&
- videosValidators.isVideoDateValid(video.createdAt) &&
- videosValidators.isVideoDateValid(video.updatedAt) &&
- videosValidators.isVideoDescriptionValid(video.description) &&
- videosValidators.isVideoDurationValid(video.duration) &&
- videosValidators.isVideoInfoHashValid(video.infoHash) &&
- videosValidators.isVideoNameValid(video.name) &&
- videosValidators.isVideoTagsValid(video.tags) &&
- videosValidators.isVideoThumbnailDataValid(video.thumbnailData) &&
- videosValidators.isVideoRemoteIdValid(video.remoteId) &&
- videosValidators.isVideoExtnameValid(video.extname)
+ videosValidators.isVideoThumbnailDataValid(video.thumbnailData)
) ||
(
isRequestTypeUpdateValid(request.type) &&
- videosValidators.isVideoDateValid(video.createdAt) &&
- videosValidators.isVideoDateValid(video.updatedAt) &&
- videosValidators.isVideoDescriptionValid(video.description) &&
- videosValidators.isVideoDurationValid(video.duration) &&
- videosValidators.isVideoInfoHashValid(video.infoHash) &&
- videosValidators.isVideoNameValid(video.name) &&
- videosValidators.isVideoTagsValid(video.tags) &&
- videosValidators.isVideoRemoteIdValid(video.remoteId) &&
- videosValidators.isVideoExtnameValid(video.extname)
+ isCommonVideoAttrbiutesValid(video)
) ||
(
isRequestTypeRemoveValid(request.type) &&
// ---------------------------------------------------------------------------
+function isCommonVideoAttrbiutesValid (video) {
+ return videosValidators.isVideoDateValid(video.createdAt) &&
+ videosValidators.isVideoDateValid(video.updatedAt) &&
+ videosValidators.isVideoDescriptionValid(video.description) &&
+ videosValidators.isVideoDurationValid(video.duration) &&
+ videosValidators.isVideoInfoHashValid(video.infoHash) &&
+ videosValidators.isVideoNameValid(video.name) &&
+ videosValidators.isVideoTagsValid(video.tags) &&
+ videosValidators.isVideoRemoteIdValid(video.remoteId) &&
+ videosValidators.isVideoExtnameValid(video.extname)
+}
+
function isRequestTypeAddValid (value) {
- return value === 'add'
+ return value === ENDPOINT_ACTIONS.ADD
}
function isRequestTypeUpdateValid (value) {
- return value === 'update'
+ return value === ENDPOINT_ACTIONS.UPDATE
}
function isRequestTypeRemoveValid (value) {
- return value === 'remove'
+ return value === ENDPOINT_ACTIONS.REMOVE
}
function isRequestTypeReportAbuseValid (value) {
- return value === 'report-abuse'
+ return value === ENDPOINT_ACTIONS.REPORT_ABUSE
}
const logger = require('../helpers/logger')
const requests = require('../helpers/requests')
+const ENDPOINT_ACTIONS = constants.REQUEST_ENDPOINT_ACTIONS[constants.REQUEST_ENDPOINTS.VIDEOS]
+
const friends = {
addVideoToFriends,
updateVideoToFriends,
function addVideoToFriends (videoData, transaction, callback) {
const options = {
- type: 'add',
+ type: ENDPOINT_ACTIONS.ADD,
endpoint: constants.REQUEST_ENDPOINTS.VIDEOS,
data: videoData,
transaction
function updateVideoToFriends (videoData, transaction, callback) {
const options = {
- type: 'update',
+ type: ENDPOINT_ACTIONS.UPDATE,
endpoint: constants.REQUEST_ENDPOINTS.VIDEOS,
data: videoData,
transaction
function removeVideoToFriends (videoParams) {
const options = {
- type: 'remove',
+ type: ENDPOINT_ACTIONS.REMOVE,
endpoint: constants.REQUEST_ENDPOINTS.VIDEOS,
data: videoParams
}
function reportAbuseVideoToFriend (reportData, video) {
const options = {
- type: 'report-abuse',
+ type: ENDPOINT_ACTIONS.REPORT_ABUSE,
endpoint: constants.REQUEST_ENDPOINTS.VIDEOS,
data: reportData,
toIds: [ video.Author.podId ]