-import { RequestSchedulerStatsAttributes as FormatedRequestSchedulerStatsAttributes } from '../../../../../../shared'
+import { RequestSchedulerStatsAttributes as FormattedRequestSchedulerStatsAttributes } from '../../../../../../shared'
export interface Request {
request: any
to: any
}
-export class RequestSchedulerStatsAttributes implements FormatedRequestSchedulerStatsAttributes {
+export class RequestSchedulerStatsAttributes implements FormattedRequestSchedulerStatsAttributes {
requestsLimitPods: number
requestsLimitPerPod: number
milliSecondsInterval: number
import {
logger,
getMyPublicCert,
- getFormatedObjects
+ getFormattedObjects
} from '../../helpers'
import {
sendOwnedVideosToPod,
import {
PodInstance
} from '../../models'
-import { Pod as FormatedPod } from '../../../shared'
+import { Pod as FormattedPod } from '../../../shared'
const podsRouter = express.Router()
function listPods (req: express.Request, res: express.Response, next: express.NextFunction) {
db.Pod.list()
- .then(podsList => res.json(getFormatedObjects<FormatedPod, PodInstance>(podsList, podsList.length)))
+ .then(podsList => res.json(getFormattedObjects<FormattedPod, PodInstance>(podsList, podsList.length)))
.catch(err => next(err))
}
import { database as db } from '../../initializers/database'
import { USER_ROLES } from '../../initializers'
-import { logger, getFormatedObjects } from '../../helpers'
+import { logger, getFormattedObjects } from '../../helpers'
import {
authenticate,
ensureIsAdmin,
setUsersSort,
token
} from '../../middlewares'
-import { UserVideoRate as FormatedUserVideoRate, UserCreate, UserUpdate } from '../../../shared'
+import { UserVideoRate as FormattedUserVideoRate, UserCreate, UserUpdate } from '../../../shared'
const usersRouter = express.Router()
function getUserInformation (req: express.Request, res: express.Response, next: express.NextFunction) {
db.User.loadByUsername(res.locals.oauth.token.user.username)
- .then(user => res.json(user.toFormatedJSON()))
+ .then(user => res.json(user.toFormattedJSON()))
.catch(err => next(err))
}
db.UserVideoRate.load(userId, videoId, null)
.then(ratingObj => {
const rating = ratingObj ? ratingObj.type : 'none'
- const json: FormatedUserVideoRate = {
+ const json: FormattedUserVideoRate = {
videoId,
rating
}
function listUsers (req: express.Request, res: express.Response, next: express.NextFunction) {
db.User.listForApi(req.query.start, req.query.count, req.query.sort)
.then(resultList => {
- res.json(getFormatedObjects(resultList.data, resultList.total))
+ res.json(getFormattedObjects(resultList.data, resultList.total))
})
.catch(err => next(err))
}
import * as friends from '../../../lib/friends'
import {
logger,
- getFormatedObjects,
+ getFormattedObjects,
retryTransactionWrapper
} from '../../../helpers'
import {
function listVideoAbuses (req: express.Request, res: express.Response, next: express.NextFunction) {
db.VideoAbuse.listForApi(req.query.start, req.query.count, req.query.sort)
- .then(result => res.json(getFormatedObjects(result.data, result.total)))
+ .then(result => res.json(getFormattedObjects(result.data, result.total)))
.catch(err => next(err))
}
logger,
retryTransactionWrapper,
generateRandomString,
- getFormatedObjects,
+ getFormattedObjects,
renamePromise
} from '../../../helpers'
import { TagInstance } from '../../../models'
}
// Do not wait the view system
- res.json(videoInstance.toFormatedJSON())
+ res.json(videoInstance.toFormattedJSON())
}
function listVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
db.Video.listForApi(req.query.start, req.query.count, req.query.sort)
- .then(result => res.json(getFormatedObjects(result.data, result.total)))
+ .then(result => res.json(getFormattedObjects(result.data, result.total)))
.catch(err => next(err))
}
function searchVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
db.Video.searchAndPopulateAuthorAndPodAndTags(req.params.value, req.query.field, req.query.start, req.query.count, req.query.sort)
- .then(result => res.json(getFormatedObjects(result.data, result.total)))
+ .then(result => res.json(getFormattedObjects(result.data, result.total)))
.catch(err => next(err))
}
}
interface FormatableToJSON {
- toFormatedJSON ()
+ toFormattedJSON ()
}
-function getFormatedObjects<U, T extends FormatableToJSON> (objects: T[], objectsTotal: number) {
- const formatedObjects: U[] = []
+function getFormattedObjects<U, T extends FormatableToJSON> (objects: T[], objectsTotal: number) {
+ const formattedObjects: U[] = []
objects.forEach(object => {
- formatedObjects.push(object.toFormatedJSON())
+ formattedObjects.push(object.toFormattedJSON())
})
const res: ResultList<U> = {
total: objectsTotal,
- data: formatedObjects
+ data: formattedObjects
}
return res
export {
badRequest,
generateRandomString,
- getFormatedObjects,
+ getFormattedObjects,
isSignupAllowed
}
RemoteVideoRemoveData,
RemoteVideoReportAbuseData,
ResultList,
- Pod as FormatedPod
+ Pod as FormattedPod
} from '../../shared'
type QaduParam = { videoId: number, type: RequestVideoQaduType }
}
function getForeignPodsList (host: string) {
- return new Promise< ResultList<FormatedPod> >((res, rej) => {
+ return new Promise< ResultList<FormattedPod> >((res, rej) => {
const path = '/api/' + API_VERSION + '/pods'
request.get(REMOTE_SCHEME.HTTP + '://' + host + path, (err, response, body) => {
import * as Promise from 'bluebird'
// Don't use barrel, import just what we need
-import { Pod as FormatedPod } from '../../../shared/models/pods/pod.model'
+import { Pod as FormattedPod } from '../../../shared/models/pods/pod.model'
export namespace PodMethods {
- export type ToFormatedJSON = (this: PodInstance) => FormatedPod
+ export type ToFormattedJSON = (this: PodInstance) => FormattedPod
export type CountAll = () => Promise<number>
createdAt: Date
updatedAt: Date
- toFormatedJSON: PodMethods.ToFormatedJSON,
+ toFormattedJSON: PodMethods.ToFormattedJSON,
}
export interface PodModel extends PodClass, Sequelize.Model<PodInstance, PodAttributes> {}
} from './pod-interface'
let Pod: Sequelize.Model<PodInstance, PodAttributes>
-let toFormatedJSON: PodMethods.ToFormatedJSON
+let toFormattedJSON: PodMethods.ToFormattedJSON
let countAll: PodMethods.CountAll
let incrementScores: PodMethods.IncrementScores
let list: PodMethods.List
updatePodsScore,
removeAll
]
- const instanceMethods = [ toFormatedJSON ]
+ const instanceMethods = [ toFormattedJSON ]
addMethodsToModel(Pod, classMethods, instanceMethods)
return Pod
// ------------------------------ METHODS ------------------------------
-toFormatedJSON = function (this: PodInstance) {
+toFormattedJSON = function (this: PodInstance) {
const json = {
id: this.id,
host: this.host,
import * as Promise from 'bluebird'
// Don't use barrel, import just what we need
-import { User as FormatedUser } from '../../../shared/models/users/user.model'
+import { User as FormattedUser } from '../../../shared/models/users/user.model'
import { UserRole } from '../../../shared/models/users/user-role.type'
import { ResultList } from '../../../shared/models/result-list.model'
export namespace UserMethods {
export type IsPasswordMatch = (this: UserInstance, password: string) => Promise<boolean>
- export type ToFormatedJSON = (this: UserInstance) => FormatedUser
+ export type ToFormattedJSON = (this: UserInstance) => FormattedUser
export type IsAdmin = (this: UserInstance) => boolean
export type CountTotal = () => Promise<number>
export interface UserClass {
isPasswordMatch: UserMethods.IsPasswordMatch,
- toFormatedJSON: UserMethods.ToFormatedJSON,
+ toFormattedJSON: UserMethods.ToFormattedJSON,
isAdmin: UserMethods.IsAdmin,
countTotal: UserMethods.CountTotal,
updatedAt: Date
isPasswordMatch: UserMethods.IsPasswordMatch
- toFormatedJSON: UserMethods.ToFormatedJSON
+ toFormattedJSON: UserMethods.ToFormattedJSON
isAdmin: UserMethods.IsAdmin
}
let User: Sequelize.Model<UserInstance, UserAttributes>
let isPasswordMatch: UserMethods.IsPasswordMatch
-let toFormatedJSON: UserMethods.ToFormatedJSON
+let toFormattedJSON: UserMethods.ToFormattedJSON
let isAdmin: UserMethods.IsAdmin
let countTotal: UserMethods.CountTotal
let getByUsername: UserMethods.GetByUsername
]
const instanceMethods = [
isPasswordMatch,
- toFormatedJSON,
+ toFormattedJSON,
isAdmin
]
addMethodsToModel(User, classMethods, instanceMethods)
return comparePassword(password, this.password)
}
-toFormatedJSON = function (this: UserInstance) {
+toFormattedJSON = function (this: UserInstance) {
return {
id: this.id,
username: this.username,
import { ResultList } from '../../../shared'
// Don't use barrel, import just what we need
-import { VideoAbuse as FormatedVideoAbuse } from '../../../shared/models/videos/video-abuse.model'
+import { VideoAbuse as FormattedVideoAbuse } from '../../../shared/models/videos/video-abuse.model'
export namespace VideoAbuseMethods {
- export type ToFormatedJSON = (this: VideoAbuseInstance) => FormatedVideoAbuse
+ export type ToFormattedJSON = (this: VideoAbuseInstance) => FormattedVideoAbuse
export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoAbuseInstance> >
}
Pod: PodInstance
- toFormatedJSON: VideoAbuseMethods.ToFormatedJSON
+ toFormattedJSON: VideoAbuseMethods.ToFormattedJSON
}
export interface VideoAbuseModel extends VideoAbuseClass, Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> {}
} from './video-abuse-interface'
let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes>
-let toFormatedJSON: VideoAbuseMethods.ToFormatedJSON
+let toFormattedJSON: VideoAbuseMethods.ToFormattedJSON
let listForApi: VideoAbuseMethods.ListForApi
export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
listForApi
]
const instanceMethods = [
- toFormatedJSON
+ toFormattedJSON
]
addMethodsToModel(VideoAbuse, classMethods, instanceMethods)
// ------------------------------ METHODS ------------------------------
-toFormatedJSON = function (this: VideoAbuseInstance) {
+toFormattedJSON = function (this: VideoAbuseInstance) {
let reporterPodHost
if (this.Pod) {
import { ResultList } from '../../../shared'
// Don't use barrel, import just what we need
-import { BlacklistedVideo as FormatedBlacklistedVideo } from '../../../shared/models/videos/video-blacklist.model'
+import { BlacklistedVideo as FormattedBlacklistedVideo } from '../../../shared/models/videos/video-blacklist.model'
export namespace BlacklistedVideoMethods {
- export type ToFormatedJSON = (this: BlacklistedVideoInstance) => FormatedBlacklistedVideo
+ export type ToFormattedJSON = (this: BlacklistedVideoInstance) => FormattedBlacklistedVideo
export type CountTotal = () => Promise<number>
}
export interface BlacklistedVideoClass {
- toFormatedJSON: BlacklistedVideoMethods.ToFormatedJSON
+ toFormattedJSON: BlacklistedVideoMethods.ToFormattedJSON
countTotal: BlacklistedVideoMethods.CountTotal
list: BlacklistedVideoMethods.List
listForApi: BlacklistedVideoMethods.ListForApi
createdAt: Date
updatedAt: Date
- toFormatedJSON: BlacklistedVideoMethods.ToFormatedJSON
+ toFormattedJSON: BlacklistedVideoMethods.ToFormattedJSON
}
export interface BlacklistedVideoModel
} from './video-blacklist-interface'
let BlacklistedVideo: Sequelize.Model<BlacklistedVideoInstance, BlacklistedVideoAttributes>
-let toFormatedJSON: BlacklistedVideoMethods.ToFormatedJSON
+let toFormattedJSON: BlacklistedVideoMethods.ToFormattedJSON
let countTotal: BlacklistedVideoMethods.CountTotal
let list: BlacklistedVideoMethods.List
let listForApi: BlacklistedVideoMethods.ListForApi
loadByVideoId
]
const instanceMethods = [
- toFormatedJSON
+ toFormattedJSON
]
addMethodsToModel(BlacklistedVideo, classMethods, instanceMethods)
// ------------------------------ METHODS ------------------------------
-toFormatedJSON = function (this: BlacklistedVideoInstance) {
+toFormattedJSON = function (this: BlacklistedVideoInstance) {
return {
id: this.id,
videoId: this.videoId,
import { VideoFileAttributes, VideoFileInstance } from './video-file-interface'
// Don't use barrel, import just what we need
-import { Video as FormatedVideo } from '../../../shared/models/videos/video.model'
+import { Video as FormattedVideo } from '../../../shared/models/videos/video.model'
import { ResultList } from '../../../shared/models/result-list.model'
-export type FormatedRemoteVideoFile = {
+export type FormattedRemoteVideoFile = {
infoHash: string
resolution: number
extname: string
size: number
}
-export type FormatedAddRemoteVideo = {
+export type FormattedAddRemoteVideo = {
uuid: string
name: string
category: number
views: number
likes: number
dislikes: number
- files: FormatedRemoteVideoFile[]
+ files: FormattedRemoteVideoFile[]
}
-export type FormatedUpdateRemoteVideo = {
+export type FormattedUpdateRemoteVideo = {
uuid: string
name: string
category: number
views: number
likes: number
dislikes: number
- files: FormatedRemoteVideoFile[]
+ files: FormattedRemoteVideoFile[]
}
export namespace VideoMethods {
export type GetThumbnailName = (this: VideoInstance) => string
export type GetPreviewName = (this: VideoInstance) => string
export type IsOwned = (this: VideoInstance) => boolean
- export type ToFormatedJSON = (this: VideoInstance) => FormatedVideo
+ export type ToFormattedJSON = (this: VideoInstance) => FormattedVideo
export type GenerateMagnetUri = (this: VideoInstance, videoFile: VideoFileInstance) => string
export type GetTorrentFileName = (this: VideoInstance, videoFile: VideoFileInstance) => string
export type GetVideoFilePath = (this: VideoInstance, videoFile: VideoFileInstance) => string
export type CreateTorrentAndSetInfoHash = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
- export type ToAddRemoteJSON = (this: VideoInstance) => Promise<FormatedAddRemoteVideo>
- export type ToUpdateRemoteJSON = (this: VideoInstance) => FormatedUpdateRemoteVideo
+ export type ToAddRemoteJSON = (this: VideoInstance) => Promise<FormattedAddRemoteVideo>
+ export type ToUpdateRemoteJSON = (this: VideoInstance) => FormattedUpdateRemoteVideo
export type TranscodeVideofile = (this: VideoInstance, inputVideoFile: VideoFileInstance) => Promise<void>
removeThumbnail: VideoMethods.RemoveThumbnail
removeTorrent: VideoMethods.RemoveTorrent
toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
- toFormatedJSON: VideoMethods.ToFormatedJSON
+ toFormattedJSON: VideoMethods.ToFormattedJSON
toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
transcodeVideofile: VideoMethods.TranscodeVideofile
let getPreviewName: VideoMethods.GetPreviewName
let getTorrentFileName: VideoMethods.GetTorrentFileName
let isOwned: VideoMethods.IsOwned
-let toFormatedJSON: VideoMethods.ToFormatedJSON
+let toFormattedJSON: VideoMethods.ToFormattedJSON
let toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
let toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
let transcodeVideofile: VideoMethods.TranscodeVideofile
removeThumbnail,
removeTorrent,
toAddRemoteJSON,
- toFormatedJSON,
+ toFormattedJSON,
toUpdateRemoteJSON,
transcodeVideofile
]
return magnetUtil.encode(magnetHash)
}
-toFormatedJSON = function (this: VideoInstance) {
+toFormattedJSON = function (this: VideoInstance) {
let podHost
if (this.Author.Pod) {