'use strict'
const miscValidators = {
- exists: exists,
- isArray: isArray
+ exists,
+ isArray
}
function exists (value) {
const miscValidators = require('./misc')
const podsValidators = {
- isEachUniqueUrlValid: isEachUniqueUrlValid
+ isEachUniqueUrlValid
}
function isEachUniqueUrlValid (urls) {
const USERS_CONSTRAINTS_FIELDS = constants.CONSTRAINTS_FIELDS.USERS
const usersValidators = {
- isUserPasswordValid: isUserPasswordValid,
- isUserRoleValid: isUserRoleValid,
- isUserUsernameValid: isUserUsernameValid
+ isUserPasswordValid,
+ isUserRoleValid,
+ isUserUsernameValid
}
function isUserPasswordValid (value) {
const VIDEOS_CONSTRAINTS_FIELDS = constants.CONSTRAINTS_FIELDS.VIDEOS
const videosValidators = {
- isEachRemoteVideosValid: isEachRemoteVideosValid,
- isVideoAuthorValid: isVideoAuthorValid,
- isVideoDateValid: isVideoDateValid,
- isVideoDescriptionValid: isVideoDescriptionValid,
- isVideoDurationValid: isVideoDurationValid,
- isVideoMagnetUriValid: isVideoMagnetUriValid,
- isVideoNameValid: isVideoNameValid,
- isVideoPodUrlValid: isVideoPodUrlValid,
- isVideoTagsValid: isVideoTagsValid,
- isVideoThumbnailValid: isVideoThumbnailValid,
- isVideoThumbnail64Valid: isVideoThumbnail64Valid
+ isEachRemoteVideosValid,
+ isVideoAuthorValid,
+ isVideoDateValid,
+ isVideoDescriptionValid,
+ isVideoDurationValid,
+ isVideoMagnetUriValid,
+ isVideoNameValid,
+ isVideoPodUrlValid,
+ isVideoTagsValid,
+ isVideoThumbnailValid,
+ isVideoThumbnail64Valid
}
function isEachRemoteVideosValid (requests) {
const algorithm = 'aes-256-ctr'
const peertubeCrypto = {
- checkSignature: checkSignature,
- comparePassword: comparePassword,
- createCertsIfNotExist: createCertsIfNotExist,
- cryptPassword: cryptPassword,
- decrypt: decrypt,
- encrypt: encrypt,
- sign: sign
+ checkSignature,
+ comparePassword,
+ createCertsIfNotExist,
+ cryptPassword,
+ decrypt,
+ encrypt,
+ sign
}
function checkSignature (publicKey, rawData, hexSignature) {
const peertubeCrypto = require('./peertube-crypto')
const requests = {
- makeRetryRequest: makeRetryRequest,
- makeSecureRequest: makeSecureRequest
+ makeRetryRequest,
+ makeSecureRequest
}
function makeRetryRequest (params, callback) {
const logger = require('./logger')
const utils = {
- cleanForExit: cleanForExit,
- generateRandomString: generateRandomString
+ cleanForExit,
+ generateRandomString
}
function generateRandomString (size, callback) {
const User = mongoose.model('User')
const checker = {
- checkConfig: checkConfig,
- clientsExist: clientsExist,
- usersExist: usersExist
+ checkConfig,
+ clientsExist,
+ usersExist
}
// Check the config files
const User = mongoose.model('User')
const installer = {
- installApplication: installApplication
+ installApplication
}
function installApplication (callback) {
}
const user = new User({
- username: username,
- password: password,
- role: role
+ username,
+ password,
+ role
})
user.save(function (err, createdUser) {
const Video = mongoose.model('Video')
const friends = {
- addVideoToFriends: addVideoToFriends,
- hasFriends: hasFriends,
- getMyCertificate: getMyCertificate,
- makeFriends: makeFriends,
- quitFriends: quitFriends,
- removeVideoToFriends: removeVideoToFriends,
- sendOwnedVideosToPod: sendOwnedVideosToPod
+ addVideoToFriends,
+ hasFriends,
+ getMyCertificate,
+ makeFriends,
+ quitFriends,
+ removeVideoToFriends,
+ sendOwnedVideosToPod
}
function addVideoToFriends (video) {
// See https://github.com/oauthjs/node-oauth2-server/wiki/Model-specification for the model specifications
const OAuthModel = {
- getAccessToken: getAccessToken,
- getClient: getClient,
- getRefreshToken: getRefreshToken,
- getUser: getUser,
- revokeToken: revokeToken,
- saveToken: saveToken
+ getAccessToken,
+ getClient,
+ getRefreshToken,
+ getUser,
+ revokeToken,
+ saveToken
}
// ---------------------------------------------------------------------------
const logger = require('../helpers/logger')
const adminMiddleware = {
- ensureIsAdmin: ensureIsAdmin
+ ensureIsAdmin
}
function ensureIsAdmin (req, res, next) {
})
const oAuth = {
- authenticate: authenticate,
- token: token
+ authenticate,
+ token
}
function authenticate (req, res, next) {
const constants = require('../initializers/constants')
const paginationMiddleware = {
- setPagination: setPagination
+ setPagination
}
function setPagination (req, res, next) {
const logger = require('../helpers/logger')
const podsMiddleware = {
- setBodyUrlsPort: setBodyUrlsPort,
- setBodyUrlPort: setBodyUrlPort
+ setBodyUrlsPort,
+ setBodyUrlPort
}
function setBodyUrlsPort (req, res, next) {
'use strict'
const searchMiddleware = {
- setVideosSearch: setVideosSearch
+ setVideosSearch
}
function setVideosSearch (req, res, next) {
const Pod = mongoose.model('Pod')
const secureMiddleware = {
- checkSignature: checkSignature,
- decryptBody: decryptBody
+ checkSignature,
+ decryptBody
}
function checkSignature (req, res, next) {
'use strict'
const sortMiddleware = {
- setUsersSort: setUsersSort,
- setVideosSort: setVideosSort
+ setUsersSort,
+ setVideosSort
}
function setUsersSort (req, res, next) {
const logger = require('../../helpers/logger')
const validatorsPagination = {
- pagination: pagination
+ pagination
}
function pagination (req, res, next) {
const logger = require('../../helpers/logger')
const validatorsPod = {
- makeFriends: makeFriends,
- podsAdd: podsAdd
+ makeFriends,
+ podsAdd
}
function makeFriends (req, res, next) {
const logger = require('../../helpers/logger')
const validatorsRemote = {
- dataToDecrypt: dataToDecrypt,
- remoteVideos: remoteVideos,
- signature: signature
+ dataToDecrypt,
+ remoteVideos,
+ signature
}
function dataToDecrypt (req, res, next) {
const logger = require('../../helpers/logger')
const validatorsSort = {
- usersSort: usersSort,
- videosSort: videosSort
+ usersSort,
+ videosSort
}
function usersSort (req, res, next) {
const User = mongoose.model('User')
const validatorsUsers = {
- usersAdd: usersAdd,
- usersRemove: usersRemove,
- usersUpdate: usersUpdate
+ usersAdd,
+ usersRemove,
+ usersUpdate
}
function usersAdd (req, res, next) {
const logger = require('../../helpers/logger')
const validatorsUtils = {
- checkErrors: checkErrors
+ checkErrors
}
function checkErrors (req, res, next, statusCode) {
const Video = mongoose.model('Video')
const validatorsVideos = {
- videosAdd: videosAdd,
- videosGet: videosGet,
- videosRemove: videosRemove,
- videosSearch: videosSearch
+ videosAdd,
+ videosGet,
+ videosRemove,
+ videosSearch
}
function videosAdd (req, res, next) {
})
ApplicationSchema.statics = {
- loadMongoSchemaVersion: loadMongoSchemaVersion,
- updateMongoSchemaVersion: updateMongoSchemaVersion
+ loadMongoSchemaVersion,
+ updateMongoSchemaVersion
}
mongoose.model('Application', ApplicationSchema)
OAuthClientSchema.path('clientSecret').required(true)
OAuthClientSchema.statics = {
- getByIdAndSecret: getByIdAndSecret,
- list: list,
- loadFirstClient: loadFirstClient
+ getByIdAndSecret,
+ list,
+ loadFirstClient
}
mongoose.model('OAuthClient', OAuthClientSchema)
OAuthTokenSchema.path('user').required(true)
OAuthTokenSchema.statics = {
- getByRefreshTokenAndPopulateClient: getByRefreshTokenAndPopulateClient,
- getByTokenAndPopulateUser: getByTokenAndPopulateUser,
- getByRefreshToken: getByRefreshToken,
- removeByUserId: removeByUserId
+ getByRefreshTokenAndPopulateClient,
+ getByTokenAndPopulateUser,
+ getByRefreshToken,
+ removeByUserId
}
mongoose.model('OAuthToken', OAuthTokenSchema)
PodSchema.path('score').validate(function (value) { return !isNaN(value) })
PodSchema.methods = {
- toFormatedJSON: toFormatedJSON
+ toFormatedJSON
}
PodSchema.statics = {
- countAll: countAll,
- incrementScores: incrementScores,
- list: list,
- listAllIds: listAllIds,
- listBadPods: listBadPods,
- load: load,
- loadByUrl: loadByUrl,
- removeAll: removeAll
+ countAll,
+ incrementScores,
+ list,
+ listAllIds,
+ listBadPods,
+ load,
+ loadByUrl,
+ removeAll
}
PodSchema.pre('save', function (next) {
UserSchema.path('role').validate(customUsersValidators.isUserRoleValid)
UserSchema.methods = {
- isPasswordMatch: isPasswordMatch,
- toFormatedJSON: toFormatedJSON
+ isPasswordMatch,
+ toFormatedJSON
}
UserSchema.statics = {
- countTotal: countTotal,
- getByUsername: getByUsername,
- list: list,
- listForApi: listForApi,
- loadById: loadById,
- loadByUsername: loadByUsername
+ countTotal,
+ getByUsername,
+ list,
+ listForApi,
+ loadById,
+ loadByUsername
}
UserSchema.pre('save', function (next) {
const parallel = require('async/parallel')
const utils = {
- listForApiWithCount: listForApiWithCount
+ listForApiWithCount
}
function listForApiWithCount (query, start, count, sort, callback) {
VideoSchema.path('tags').validate(customVideosValidators.isVideoTagsValid)
VideoSchema.methods = {
- isOwned: isOwned,
- toFormatedJSON: toFormatedJSON,
- toRemoteJSON: toRemoteJSON
+ isOwned,
+ toFormatedJSON,
+ toRemoteJSON
}
VideoSchema.statics = {
- getDurationFromFile: getDurationFromFile,
- listForApi: listForApi,
- listByUrlAndMagnet: listByUrlAndMagnet,
- listByUrls: listByUrls,
- listOwned: listOwned,
- listOwnedByAuthor: listOwnedByAuthor,
- listRemotes: listRemotes,
- load: load,
- search: search,
- seedAllExisting: seedAllExisting
+ getDurationFromFile,
+ listForApi,
+ listByUrlAndMagnet,
+ listByUrls,
+ listOwned,
+ listOwnedByAuthor,
+ listRemotes,
+ load,
+ search,
+ seedAllExisting
}
VideoSchema.pre('remove', function (next) {
const request = require('supertest')
const loginUtils = {
- login: login,
- loginAndGetAccessToken: loginAndGetAccessToken
+ login,
+ loginAndGetAccessToken
}
// ---------------------- Export functions --------------------
'use strict'
const miscsUtils = {
- dateIsValid: dateIsValid
+ dateIsValid
}
// ---------------------- Export functions --------------------
const request = require('supertest')
const podsUtils = {
- getFriendsList: getFriendsList,
- makeFriends: makeFriends,
- quitFriends: quitFriends
+ getFriendsList,
+ makeFriends,
+ quitFriends
}
// ---------------------- Export functions --------------------
const request = require('supertest')
const requestsUtils = {
- makePostUploadRequest: makePostUploadRequest,
- makePostBodyRequest: makePostBodyRequest,
- makePutBodyRequest: makePutBodyRequest
+ makePostUploadRequest,
+ makePostBodyRequest,
+ makePutBodyRequest
}
// ---------------------- Export functions --------------------
const pathUtils = require('path')
const serversUtils = {
- flushAndRunMultipleServers: flushAndRunMultipleServers,
- flushTests: flushTests,
- runServer: runServer
+ flushAndRunMultipleServers,
+ flushTests,
+ runServer
}
// ---------------------- Export functions --------------------
const request = require('supertest')
const usersUtils = {
- createUser: createUser,
- getUserInformation: getUserInformation,
- getUsersList: getUsersList,
- getUsersListPaginationAndSort: getUsersListPaginationAndSort,
- removeUser: removeUser,
- updateUser: updateUser
+ createUser,
+ getUserInformation,
+ getUsersList,
+ getUsersListPaginationAndSort,
+ removeUser,
+ updateUser
}
// ---------------------- Export functions --------------------
const request = require('supertest')
const videosUtils = {
- getAllVideosListBy: getAllVideosListBy,
- getVideo: getVideo,
- getVideosList: getVideosList,
- getVideosListPagination: getVideosListPagination,
- getVideosListSort: getVideosListSort,
- removeVideo: removeVideo,
- searchVideo: searchVideo,
- searchVideoWithPagination: searchVideoWithPagination,
- searchVideoWithSort: searchVideoWithSort,
- testVideoImage: testVideoImage,
- uploadVideo: uploadVideo
+ getAllVideosListBy,
+ getVideo,
+ getVideosList,
+ getVideosListPagination,
+ getVideosListSort,
+ removeVideo,
+ searchVideo,
+ searchVideoWithPagination,
+ searchVideoWithSort,
+ testVideoImage,
+ uploadVideo
}
// ---------------------- Export functions --------------------