Formated -> Formatted
This commit is contained in:
parent
93e1258c7c
commit
0aef76c479
|
@ -1,11 +1,11 @@
|
||||||
import { RequestSchedulerStatsAttributes as FormatedRequestSchedulerStatsAttributes } from '../../../../../../shared'
|
import { RequestSchedulerStatsAttributes as FormattedRequestSchedulerStatsAttributes } from '../../../../../../shared'
|
||||||
|
|
||||||
export interface Request {
|
export interface Request {
|
||||||
request: any
|
request: any
|
||||||
to: any
|
to: any
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RequestSchedulerStatsAttributes implements FormatedRequestSchedulerStatsAttributes {
|
export class RequestSchedulerStatsAttributes implements FormattedRequestSchedulerStatsAttributes {
|
||||||
requestsLimitPods: number
|
requestsLimitPods: number
|
||||||
requestsLimitPerPod: number
|
requestsLimitPerPod: number
|
||||||
milliSecondsInterval: number
|
milliSecondsInterval: number
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { CONFIG } from '../../initializers'
|
||||||
import {
|
import {
|
||||||
logger,
|
logger,
|
||||||
getMyPublicCert,
|
getMyPublicCert,
|
||||||
getFormatedObjects
|
getFormattedObjects
|
||||||
} from '../../helpers'
|
} from '../../helpers'
|
||||||
import {
|
import {
|
||||||
sendOwnedVideosToPod,
|
sendOwnedVideosToPod,
|
||||||
|
@ -25,7 +25,7 @@ import {
|
||||||
import {
|
import {
|
||||||
PodInstance
|
PodInstance
|
||||||
} from '../../models'
|
} from '../../models'
|
||||||
import { Pod as FormatedPod } from '../../../shared'
|
import { Pod as FormattedPod } from '../../../shared'
|
||||||
|
|
||||||
const podsRouter = express.Router()
|
const podsRouter = express.Router()
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ function addPods (req: express.Request, res: express.Response, next: express.Nex
|
||||||
|
|
||||||
function listPods (req: express.Request, res: express.Response, next: express.NextFunction) {
|
function listPods (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||||
db.Pod.list()
|
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))
|
.catch(err => next(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as express from 'express'
|
||||||
|
|
||||||
import { database as db } from '../../initializers/database'
|
import { database as db } from '../../initializers/database'
|
||||||
import { USER_ROLES } from '../../initializers'
|
import { USER_ROLES } from '../../initializers'
|
||||||
import { logger, getFormatedObjects } from '../../helpers'
|
import { logger, getFormattedObjects } from '../../helpers'
|
||||||
import {
|
import {
|
||||||
authenticate,
|
authenticate,
|
||||||
ensureIsAdmin,
|
ensureIsAdmin,
|
||||||
|
@ -17,7 +17,7 @@ import {
|
||||||
setUsersSort,
|
setUsersSort,
|
||||||
token
|
token
|
||||||
} from '../../middlewares'
|
} from '../../middlewares'
|
||||||
import { UserVideoRate as FormatedUserVideoRate, UserCreate, UserUpdate } from '../../../shared'
|
import { UserVideoRate as FormattedUserVideoRate, UserCreate, UserUpdate } from '../../../shared'
|
||||||
|
|
||||||
const usersRouter = express.Router()
|
const usersRouter = express.Router()
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ function createUser (req: express.Request, res: express.Response, next: express.
|
||||||
|
|
||||||
function getUserInformation (req: express.Request, res: express.Response, next: express.NextFunction) {
|
function getUserInformation (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||||
db.User.loadByUsername(res.locals.oauth.token.user.username)
|
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))
|
.catch(err => next(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ function getUserVideoRating (req: express.Request, res: express.Response, next:
|
||||||
db.UserVideoRate.load(userId, videoId, null)
|
db.UserVideoRate.load(userId, videoId, null)
|
||||||
.then(ratingObj => {
|
.then(ratingObj => {
|
||||||
const rating = ratingObj ? ratingObj.type : 'none'
|
const rating = ratingObj ? ratingObj.type : 'none'
|
||||||
const json: FormatedUserVideoRate = {
|
const json: FormattedUserVideoRate = {
|
||||||
videoId,
|
videoId,
|
||||||
rating
|
rating
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ function getUserVideoRating (req: express.Request, res: express.Response, next:
|
||||||
function listUsers (req: express.Request, res: express.Response, next: express.NextFunction) {
|
function listUsers (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||||
db.User.listForApi(req.query.start, req.query.count, req.query.sort)
|
db.User.listForApi(req.query.start, req.query.count, req.query.sort)
|
||||||
.then(resultList => {
|
.then(resultList => {
|
||||||
res.json(getFormatedObjects(resultList.data, resultList.total))
|
res.json(getFormattedObjects(resultList.data, resultList.total))
|
||||||
})
|
})
|
||||||
.catch(err => next(err))
|
.catch(err => next(err))
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { database as db } from '../../../initializers/database'
|
||||||
import * as friends from '../../../lib/friends'
|
import * as friends from '../../../lib/friends'
|
||||||
import {
|
import {
|
||||||
logger,
|
logger,
|
||||||
getFormatedObjects,
|
getFormattedObjects,
|
||||||
retryTransactionWrapper
|
retryTransactionWrapper
|
||||||
} from '../../../helpers'
|
} from '../../../helpers'
|
||||||
import {
|
import {
|
||||||
|
@ -46,7 +46,7 @@ export {
|
||||||
|
|
||||||
function listVideoAbuses (req: express.Request, res: express.Response, next: express.NextFunction) {
|
function listVideoAbuses (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||||
db.VideoAbuse.listForApi(req.query.start, req.query.count, req.query.sort)
|
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))
|
.catch(err => next(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ import {
|
||||||
logger,
|
logger,
|
||||||
retryTransactionWrapper,
|
retryTransactionWrapper,
|
||||||
generateRandomString,
|
generateRandomString,
|
||||||
getFormatedObjects,
|
getFormattedObjects,
|
||||||
renamePromise
|
renamePromise
|
||||||
} from '../../../helpers'
|
} from '../../../helpers'
|
||||||
import { TagInstance } from '../../../models'
|
import { TagInstance } from '../../../models'
|
||||||
|
@ -386,12 +386,12 @@ function getVideo (req: express.Request, res: express.Response, next: express.Ne
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not wait the view system
|
// 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) {
|
function listVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||||
db.Video.listForApi(req.query.start, req.query.count, req.query.sort)
|
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))
|
.catch(err => next(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,6 +408,6 @@ function removeVideo (req: express.Request, res: express.Response, next: express
|
||||||
|
|
||||||
function searchVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
|
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)
|
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))
|
.catch(err => next(err))
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,19 +14,19 @@ function generateRandomString (size: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FormatableToJSON {
|
interface FormatableToJSON {
|
||||||
toFormatedJSON ()
|
toFormattedJSON ()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFormatedObjects<U, T extends FormatableToJSON> (objects: T[], objectsTotal: number) {
|
function getFormattedObjects<U, T extends FormatableToJSON> (objects: T[], objectsTotal: number) {
|
||||||
const formatedObjects: U[] = []
|
const formattedObjects: U[] = []
|
||||||
|
|
||||||
objects.forEach(object => {
|
objects.forEach(object => {
|
||||||
formatedObjects.push(object.toFormatedJSON())
|
formattedObjects.push(object.toFormattedJSON())
|
||||||
})
|
})
|
||||||
|
|
||||||
const res: ResultList<U> = {
|
const res: ResultList<U> = {
|
||||||
total: objectsTotal,
|
total: objectsTotal,
|
||||||
data: formatedObjects
|
data: formattedObjects
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
@ -52,6 +52,6 @@ function isSignupAllowed () {
|
||||||
export {
|
export {
|
||||||
badRequest,
|
badRequest,
|
||||||
generateRandomString,
|
generateRandomString,
|
||||||
getFormatedObjects,
|
getFormattedObjects,
|
||||||
isSignupAllowed
|
isSignupAllowed
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ import {
|
||||||
RemoteVideoRemoveData,
|
RemoteVideoRemoveData,
|
||||||
RemoteVideoReportAbuseData,
|
RemoteVideoReportAbuseData,
|
||||||
ResultList,
|
ResultList,
|
||||||
Pod as FormatedPod
|
Pod as FormattedPod
|
||||||
} from '../../shared'
|
} from '../../shared'
|
||||||
|
|
||||||
type QaduParam = { videoId: number, type: RequestVideoQaduType }
|
type QaduParam = { videoId: number, type: RequestVideoQaduType }
|
||||||
|
@ -332,7 +332,7 @@ function computeWinningPods (hosts: string[], podsScore: { [ host: string ]: num
|
||||||
}
|
}
|
||||||
|
|
||||||
function getForeignPodsList (host: string) {
|
function getForeignPodsList (host: string) {
|
||||||
return new Promise< ResultList<FormatedPod> >((res, rej) => {
|
return new Promise< ResultList<FormattedPod> >((res, rej) => {
|
||||||
const path = '/api/' + API_VERSION + '/pods'
|
const path = '/api/' + API_VERSION + '/pods'
|
||||||
|
|
||||||
request.get(REMOTE_SCHEME.HTTP + '://' + host + path, (err, response, body) => {
|
request.get(REMOTE_SCHEME.HTTP + '://' + host + path, (err, response, body) => {
|
||||||
|
|
|
@ -2,10 +2,10 @@ import * as Sequelize from 'sequelize'
|
||||||
import * as Promise from 'bluebird'
|
import * as Promise from 'bluebird'
|
||||||
|
|
||||||
// Don't use barrel, import just what we need
|
// 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 namespace PodMethods {
|
||||||
export type ToFormatedJSON = (this: PodInstance) => FormatedPod
|
export type ToFormattedJSON = (this: PodInstance) => FormattedPod
|
||||||
|
|
||||||
export type CountAll = () => Promise<number>
|
export type CountAll = () => Promise<number>
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ export interface PodInstance extends PodClass, PodAttributes, Sequelize.Instance
|
||||||
createdAt: Date
|
createdAt: Date
|
||||||
updatedAt: Date
|
updatedAt: Date
|
||||||
|
|
||||||
toFormatedJSON: PodMethods.ToFormatedJSON,
|
toFormattedJSON: PodMethods.ToFormattedJSON,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PodModel extends PodClass, Sequelize.Model<PodInstance, PodAttributes> {}
|
export interface PodModel extends PodClass, Sequelize.Model<PodInstance, PodAttributes> {}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
} from './pod-interface'
|
} from './pod-interface'
|
||||||
|
|
||||||
let Pod: Sequelize.Model<PodInstance, PodAttributes>
|
let Pod: Sequelize.Model<PodInstance, PodAttributes>
|
||||||
let toFormatedJSON: PodMethods.ToFormatedJSON
|
let toFormattedJSON: PodMethods.ToFormattedJSON
|
||||||
let countAll: PodMethods.CountAll
|
let countAll: PodMethods.CountAll
|
||||||
let incrementScores: PodMethods.IncrementScores
|
let incrementScores: PodMethods.IncrementScores
|
||||||
let list: PodMethods.List
|
let list: PodMethods.List
|
||||||
|
@ -86,7 +86,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
|
||||||
updatePodsScore,
|
updatePodsScore,
|
||||||
removeAll
|
removeAll
|
||||||
]
|
]
|
||||||
const instanceMethods = [ toFormatedJSON ]
|
const instanceMethods = [ toFormattedJSON ]
|
||||||
addMethodsToModel(Pod, classMethods, instanceMethods)
|
addMethodsToModel(Pod, classMethods, instanceMethods)
|
||||||
|
|
||||||
return Pod
|
return Pod
|
||||||
|
@ -94,7 +94,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
|
||||||
|
|
||||||
// ------------------------------ METHODS ------------------------------
|
// ------------------------------ METHODS ------------------------------
|
||||||
|
|
||||||
toFormatedJSON = function (this: PodInstance) {
|
toFormattedJSON = function (this: PodInstance) {
|
||||||
const json = {
|
const json = {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
host: this.host,
|
host: this.host,
|
||||||
|
|
|
@ -2,14 +2,14 @@ import * as Sequelize from 'sequelize'
|
||||||
import * as Promise from 'bluebird'
|
import * as Promise from 'bluebird'
|
||||||
|
|
||||||
// Don't use barrel, import just what we need
|
// 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 { UserRole } from '../../../shared/models/users/user-role.type'
|
||||||
import { ResultList } from '../../../shared/models/result-list.model'
|
import { ResultList } from '../../../shared/models/result-list.model'
|
||||||
|
|
||||||
export namespace UserMethods {
|
export namespace UserMethods {
|
||||||
export type IsPasswordMatch = (this: UserInstance, password: string) => Promise<boolean>
|
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 IsAdmin = (this: UserInstance) => boolean
|
||||||
|
|
||||||
export type CountTotal = () => Promise<number>
|
export type CountTotal = () => Promise<number>
|
||||||
|
@ -29,7 +29,7 @@ export namespace UserMethods {
|
||||||
|
|
||||||
export interface UserClass {
|
export interface UserClass {
|
||||||
isPasswordMatch: UserMethods.IsPasswordMatch,
|
isPasswordMatch: UserMethods.IsPasswordMatch,
|
||||||
toFormatedJSON: UserMethods.ToFormatedJSON,
|
toFormattedJSON: UserMethods.ToFormattedJSON,
|
||||||
isAdmin: UserMethods.IsAdmin,
|
isAdmin: UserMethods.IsAdmin,
|
||||||
|
|
||||||
countTotal: UserMethods.CountTotal,
|
countTotal: UserMethods.CountTotal,
|
||||||
|
@ -55,7 +55,7 @@ export interface UserInstance extends UserClass, UserAttributes, Sequelize.Insta
|
||||||
updatedAt: Date
|
updatedAt: Date
|
||||||
|
|
||||||
isPasswordMatch: UserMethods.IsPasswordMatch
|
isPasswordMatch: UserMethods.IsPasswordMatch
|
||||||
toFormatedJSON: UserMethods.ToFormatedJSON
|
toFormattedJSON: UserMethods.ToFormattedJSON
|
||||||
isAdmin: UserMethods.IsAdmin
|
isAdmin: UserMethods.IsAdmin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {
|
||||||
|
|
||||||
let User: Sequelize.Model<UserInstance, UserAttributes>
|
let User: Sequelize.Model<UserInstance, UserAttributes>
|
||||||
let isPasswordMatch: UserMethods.IsPasswordMatch
|
let isPasswordMatch: UserMethods.IsPasswordMatch
|
||||||
let toFormatedJSON: UserMethods.ToFormatedJSON
|
let toFormattedJSON: UserMethods.ToFormattedJSON
|
||||||
let isAdmin: UserMethods.IsAdmin
|
let isAdmin: UserMethods.IsAdmin
|
||||||
let countTotal: UserMethods.CountTotal
|
let countTotal: UserMethods.CountTotal
|
||||||
let getByUsername: UserMethods.GetByUsername
|
let getByUsername: UserMethods.GetByUsername
|
||||||
|
@ -108,7 +108,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
|
||||||
]
|
]
|
||||||
const instanceMethods = [
|
const instanceMethods = [
|
||||||
isPasswordMatch,
|
isPasswordMatch,
|
||||||
toFormatedJSON,
|
toFormattedJSON,
|
||||||
isAdmin
|
isAdmin
|
||||||
]
|
]
|
||||||
addMethodsToModel(User, classMethods, instanceMethods)
|
addMethodsToModel(User, classMethods, instanceMethods)
|
||||||
|
@ -129,7 +129,7 @@ isPasswordMatch = function (this: UserInstance, password: string) {
|
||||||
return comparePassword(password, this.password)
|
return comparePassword(password, this.password)
|
||||||
}
|
}
|
||||||
|
|
||||||
toFormatedJSON = function (this: UserInstance) {
|
toFormattedJSON = function (this: UserInstance) {
|
||||||
return {
|
return {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
username: this.username,
|
username: this.username,
|
||||||
|
|
|
@ -5,10 +5,10 @@ import { PodInstance } from '../pod'
|
||||||
import { ResultList } from '../../../shared'
|
import { ResultList } from '../../../shared'
|
||||||
|
|
||||||
// Don't use barrel, import just what we need
|
// 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 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> >
|
export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoAbuseInstance> >
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ export interface VideoAbuseInstance extends VideoAbuseClass, VideoAbuseAttribute
|
||||||
|
|
||||||
Pod: PodInstance
|
Pod: PodInstance
|
||||||
|
|
||||||
toFormatedJSON: VideoAbuseMethods.ToFormatedJSON
|
toFormattedJSON: VideoAbuseMethods.ToFormattedJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VideoAbuseModel extends VideoAbuseClass, Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> {}
|
export interface VideoAbuseModel extends VideoAbuseClass, Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> {}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
} from './video-abuse-interface'
|
} from './video-abuse-interface'
|
||||||
|
|
||||||
let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes>
|
let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes>
|
||||||
let toFormatedJSON: VideoAbuseMethods.ToFormatedJSON
|
let toFormattedJSON: VideoAbuseMethods.ToFormattedJSON
|
||||||
let listForApi: VideoAbuseMethods.ListForApi
|
let listForApi: VideoAbuseMethods.ListForApi
|
||||||
|
|
||||||
export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
|
export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
|
||||||
|
@ -57,7 +57,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
|
||||||
listForApi
|
listForApi
|
||||||
]
|
]
|
||||||
const instanceMethods = [
|
const instanceMethods = [
|
||||||
toFormatedJSON
|
toFormattedJSON
|
||||||
]
|
]
|
||||||
addMethodsToModel(VideoAbuse, classMethods, instanceMethods)
|
addMethodsToModel(VideoAbuse, classMethods, instanceMethods)
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
|
||||||
|
|
||||||
// ------------------------------ METHODS ------------------------------
|
// ------------------------------ METHODS ------------------------------
|
||||||
|
|
||||||
toFormatedJSON = function (this: VideoAbuseInstance) {
|
toFormattedJSON = function (this: VideoAbuseInstance) {
|
||||||
let reporterPodHost
|
let reporterPodHost
|
||||||
|
|
||||||
if (this.Pod) {
|
if (this.Pod) {
|
||||||
|
|
|
@ -4,10 +4,10 @@ import * as Promise from 'bluebird'
|
||||||
import { ResultList } from '../../../shared'
|
import { ResultList } from '../../../shared'
|
||||||
|
|
||||||
// Don't use barrel, import just what we need
|
// 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 namespace BlacklistedVideoMethods {
|
||||||
export type ToFormatedJSON = (this: BlacklistedVideoInstance) => FormatedBlacklistedVideo
|
export type ToFormattedJSON = (this: BlacklistedVideoInstance) => FormattedBlacklistedVideo
|
||||||
|
|
||||||
export type CountTotal = () => Promise<number>
|
export type CountTotal = () => Promise<number>
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ export namespace BlacklistedVideoMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BlacklistedVideoClass {
|
export interface BlacklistedVideoClass {
|
||||||
toFormatedJSON: BlacklistedVideoMethods.ToFormatedJSON
|
toFormattedJSON: BlacklistedVideoMethods.ToFormattedJSON
|
||||||
countTotal: BlacklistedVideoMethods.CountTotal
|
countTotal: BlacklistedVideoMethods.CountTotal
|
||||||
list: BlacklistedVideoMethods.List
|
list: BlacklistedVideoMethods.List
|
||||||
listForApi: BlacklistedVideoMethods.ListForApi
|
listForApi: BlacklistedVideoMethods.ListForApi
|
||||||
|
@ -39,7 +39,7 @@ export interface BlacklistedVideoInstance
|
||||||
createdAt: Date
|
createdAt: Date
|
||||||
updatedAt: Date
|
updatedAt: Date
|
||||||
|
|
||||||
toFormatedJSON: BlacklistedVideoMethods.ToFormatedJSON
|
toFormattedJSON: BlacklistedVideoMethods.ToFormattedJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BlacklistedVideoModel
|
export interface BlacklistedVideoModel
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
} from './video-blacklist-interface'
|
} from './video-blacklist-interface'
|
||||||
|
|
||||||
let BlacklistedVideo: Sequelize.Model<BlacklistedVideoInstance, BlacklistedVideoAttributes>
|
let BlacklistedVideo: Sequelize.Model<BlacklistedVideoInstance, BlacklistedVideoAttributes>
|
||||||
let toFormatedJSON: BlacklistedVideoMethods.ToFormatedJSON
|
let toFormattedJSON: BlacklistedVideoMethods.ToFormattedJSON
|
||||||
let countTotal: BlacklistedVideoMethods.CountTotal
|
let countTotal: BlacklistedVideoMethods.CountTotal
|
||||||
let list: BlacklistedVideoMethods.List
|
let list: BlacklistedVideoMethods.List
|
||||||
let listForApi: BlacklistedVideoMethods.ListForApi
|
let listForApi: BlacklistedVideoMethods.ListForApi
|
||||||
|
@ -39,7 +39,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
|
||||||
loadByVideoId
|
loadByVideoId
|
||||||
]
|
]
|
||||||
const instanceMethods = [
|
const instanceMethods = [
|
||||||
toFormatedJSON
|
toFormattedJSON
|
||||||
]
|
]
|
||||||
addMethodsToModel(BlacklistedVideo, classMethods, instanceMethods)
|
addMethodsToModel(BlacklistedVideo, classMethods, instanceMethods)
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
|
||||||
|
|
||||||
// ------------------------------ METHODS ------------------------------
|
// ------------------------------ METHODS ------------------------------
|
||||||
|
|
||||||
toFormatedJSON = function (this: BlacklistedVideoInstance) {
|
toFormattedJSON = function (this: BlacklistedVideoInstance) {
|
||||||
return {
|
return {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
videoId: this.videoId,
|
videoId: this.videoId,
|
||||||
|
|
|
@ -6,17 +6,17 @@ import { TagAttributes, TagInstance } from './tag-interface'
|
||||||
import { VideoFileAttributes, VideoFileInstance } from './video-file-interface'
|
import { VideoFileAttributes, VideoFileInstance } from './video-file-interface'
|
||||||
|
|
||||||
// Don't use barrel, import just what we need
|
// 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'
|
import { ResultList } from '../../../shared/models/result-list.model'
|
||||||
|
|
||||||
export type FormatedRemoteVideoFile = {
|
export type FormattedRemoteVideoFile = {
|
||||||
infoHash: string
|
infoHash: string
|
||||||
resolution: number
|
resolution: number
|
||||||
extname: string
|
extname: string
|
||||||
size: number
|
size: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FormatedAddRemoteVideo = {
|
export type FormattedAddRemoteVideo = {
|
||||||
uuid: string
|
uuid: string
|
||||||
name: string
|
name: string
|
||||||
category: number
|
category: number
|
||||||
|
@ -33,10 +33,10 @@ export type FormatedAddRemoteVideo = {
|
||||||
views: number
|
views: number
|
||||||
likes: number
|
likes: number
|
||||||
dislikes: number
|
dislikes: number
|
||||||
files: FormatedRemoteVideoFile[]
|
files: FormattedRemoteVideoFile[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FormatedUpdateRemoteVideo = {
|
export type FormattedUpdateRemoteVideo = {
|
||||||
uuid: string
|
uuid: string
|
||||||
name: string
|
name: string
|
||||||
category: number
|
category: number
|
||||||
|
@ -52,14 +52,14 @@ export type FormatedUpdateRemoteVideo = {
|
||||||
views: number
|
views: number
|
||||||
likes: number
|
likes: number
|
||||||
dislikes: number
|
dislikes: number
|
||||||
files: FormatedRemoteVideoFile[]
|
files: FormattedRemoteVideoFile[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace VideoMethods {
|
export namespace VideoMethods {
|
||||||
export type GetThumbnailName = (this: VideoInstance) => string
|
export type GetThumbnailName = (this: VideoInstance) => string
|
||||||
export type GetPreviewName = (this: VideoInstance) => string
|
export type GetPreviewName = (this: VideoInstance) => string
|
||||||
export type IsOwned = (this: VideoInstance) => boolean
|
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 GenerateMagnetUri = (this: VideoInstance, videoFile: VideoFileInstance) => string
|
||||||
export type GetTorrentFileName = (this: VideoInstance, videoFile: VideoFileInstance) => string
|
export type GetTorrentFileName = (this: VideoInstance, videoFile: VideoFileInstance) => string
|
||||||
|
@ -69,8 +69,8 @@ export namespace VideoMethods {
|
||||||
export type GetVideoFilePath = (this: VideoInstance, videoFile: VideoFileInstance) => string
|
export type GetVideoFilePath = (this: VideoInstance, videoFile: VideoFileInstance) => string
|
||||||
export type CreateTorrentAndSetInfoHash = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
|
export type CreateTorrentAndSetInfoHash = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
|
||||||
|
|
||||||
export type ToAddRemoteJSON = (this: VideoInstance) => Promise<FormatedAddRemoteVideo>
|
export type ToAddRemoteJSON = (this: VideoInstance) => Promise<FormattedAddRemoteVideo>
|
||||||
export type ToUpdateRemoteJSON = (this: VideoInstance) => FormatedUpdateRemoteVideo
|
export type ToUpdateRemoteJSON = (this: VideoInstance) => FormattedUpdateRemoteVideo
|
||||||
|
|
||||||
export type TranscodeVideofile = (this: VideoInstance, inputVideoFile: VideoFileInstance) => Promise<void>
|
export type TranscodeVideofile = (this: VideoInstance, inputVideoFile: VideoFileInstance) => Promise<void>
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.In
|
||||||
removeThumbnail: VideoMethods.RemoveThumbnail
|
removeThumbnail: VideoMethods.RemoveThumbnail
|
||||||
removeTorrent: VideoMethods.RemoveTorrent
|
removeTorrent: VideoMethods.RemoveTorrent
|
||||||
toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
|
toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
|
||||||
toFormatedJSON: VideoMethods.ToFormatedJSON
|
toFormattedJSON: VideoMethods.ToFormattedJSON
|
||||||
toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
|
toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
|
||||||
transcodeVideofile: VideoMethods.TranscodeVideofile
|
transcodeVideofile: VideoMethods.TranscodeVideofile
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ let getThumbnailName: VideoMethods.GetThumbnailName
|
||||||
let getPreviewName: VideoMethods.GetPreviewName
|
let getPreviewName: VideoMethods.GetPreviewName
|
||||||
let getTorrentFileName: VideoMethods.GetTorrentFileName
|
let getTorrentFileName: VideoMethods.GetTorrentFileName
|
||||||
let isOwned: VideoMethods.IsOwned
|
let isOwned: VideoMethods.IsOwned
|
||||||
let toFormatedJSON: VideoMethods.ToFormatedJSON
|
let toFormattedJSON: VideoMethods.ToFormattedJSON
|
||||||
let toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
|
let toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
|
||||||
let toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
|
let toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
|
||||||
let transcodeVideofile: VideoMethods.TranscodeVideofile
|
let transcodeVideofile: VideoMethods.TranscodeVideofile
|
||||||
|
@ -257,7 +257,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
|
||||||
removeThumbnail,
|
removeThumbnail,
|
||||||
removeTorrent,
|
removeTorrent,
|
||||||
toAddRemoteJSON,
|
toAddRemoteJSON,
|
||||||
toFormatedJSON,
|
toFormattedJSON,
|
||||||
toUpdateRemoteJSON,
|
toUpdateRemoteJSON,
|
||||||
transcodeVideofile
|
transcodeVideofile
|
||||||
]
|
]
|
||||||
|
@ -414,7 +414,7 @@ generateMagnetUri = function (this: VideoInstance, videoFile: VideoFileInstance)
|
||||||
return magnetUtil.encode(magnetHash)
|
return magnetUtil.encode(magnetHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
toFormatedJSON = function (this: VideoInstance) {
|
toFormattedJSON = function (this: VideoInstance) {
|
||||||
let podHost
|
let podHost
|
||||||
|
|
||||||
if (this.Author.Pod) {
|
if (this.Author.Pod) {
|
||||||
|
|
Loading…
Reference in New Issue