aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/+admin/friends/friend-list/friend-list.component.ts2
-rw-r--r--client/src/app/+admin/friends/shared/friend.model.ts7
-rw-r--r--client/src/app/+admin/friends/shared/friend.service.ts1
-rw-r--r--client/src/app/+admin/requests/request-stats/request-stats.component.ts11
-rw-r--r--client/src/app/+admin/requests/shared/index.ts2
-rw-r--r--client/src/app/+admin/requests/shared/request-stats-attributes.model.ts (renamed from client/src/app/+admin/requests/shared/request-stats.model.ts)4
-rw-r--r--client/src/app/+admin/requests/shared/request.service.ts9
-rw-r--r--client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts3
-rw-r--r--client/src/app/core/auth/auth.service.ts5
-rw-r--r--client/src/app/core/config/config.service.ts7
-rw-r--r--client/src/app/shared/video-abuse/video-abuse.model.ts8
-rw-r--r--client/src/app/shared/video-abuse/video-abuse.service.ts2
-rw-r--r--client/src/app/videos/shared/rate-type.type.ts1
-rw-r--r--client/src/app/videos/shared/video.service.ts6
-rw-r--r--client/src/app/videos/video-watch/video-watch.component.ts10
-rw-r--r--server/controllers/api/clients.ts6
-rw-r--r--server/controllers/api/config.ts6
-rw-r--r--server/controllers/api/users.ts6
-rw-r--r--server/helpers/utils.ts8
-rw-r--r--server/models/user/user-interface.ts4
-rw-r--r--server/models/user/user-video-rate.ts1
-rw-r--r--server/models/video/video-abuse-interface.ts4
-rw-r--r--server/models/video/video-abuse.ts5
-rw-r--r--server/models/video/video-blacklist-interface.ts2
-rw-r--r--server/models/video/video-interface.ts11
-rw-r--r--shared/models/client-local.model.ts4
-rw-r--r--shared/models/index.ts2
-rw-r--r--shared/models/server-config.model.ts5
-rw-r--r--shared/models/user-video-rate.model.ts6
-rw-r--r--shared/models/video-abuse.model.ts2
30 files changed, 89 insertions, 61 deletions
diff --git a/client/src/app/+admin/friends/friend-list/friend-list.component.ts b/client/src/app/+admin/friends/friend-list/friend-list.component.ts
index 7bf9d2c6b..9f0256d7f 100644
--- a/client/src/app/+admin/friends/friend-list/friend-list.component.ts
+++ b/client/src/app/+admin/friends/friend-list/friend-list.component.ts
@@ -5,7 +5,7 @@ import { ServerDataSource } from 'ng2-smart-table'
5 5
6import { ConfirmService } from '../../../core' 6import { ConfirmService } from '../../../core'
7import { Utils } from '../../../shared' 7import { Utils } from '../../../shared'
8import { Friend, FriendService } from '../shared' 8import { FriendService } from '../shared'
9 9
10@Component({ 10@Component({
11 selector: 'my-friend-list', 11 selector: 'my-friend-list',
diff --git a/client/src/app/+admin/friends/shared/friend.model.ts b/client/src/app/+admin/friends/shared/friend.model.ts
deleted file mode 100644
index 6950405b9..000000000
--- a/client/src/app/+admin/friends/shared/friend.model.ts
+++ /dev/null
@@ -1,7 +0,0 @@
1export interface Friend {
2 id: string
3 host: string
4 score: number
5 email: string
6 createdAt: Date
7}
diff --git a/client/src/app/+admin/friends/shared/friend.service.ts b/client/src/app/+admin/friends/shared/friend.service.ts
index f4ecd36ad..79de4470e 100644
--- a/client/src/app/+admin/friends/shared/friend.service.ts
+++ b/client/src/app/+admin/friends/shared/friend.service.ts
@@ -5,7 +5,6 @@ import 'rxjs/add/operator/map'
5 5
6import { ServerDataSource } from 'ng2-smart-table' 6import { ServerDataSource } from 'ng2-smart-table'
7 7
8import { Friend } from './friend.model'
9import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared' 8import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared'
10 9
11@Injectable() 10@Injectable()
diff --git a/client/src/app/+admin/requests/request-stats/request-stats.component.ts b/client/src/app/+admin/requests/request-stats/request-stats.component.ts
index cca4926cf..140aaf47e 100644
--- a/client/src/app/+admin/requests/request-stats/request-stats.component.ts
+++ b/client/src/app/+admin/requests/request-stats/request-stats.component.ts
@@ -2,7 +2,8 @@ import { Component, OnInit, OnDestroy } from '@angular/core'
2 2
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4 4
5import { RequestService, RequestStats } from '../shared' 5import { RequestService, RequestSchedulerStatsAttributes } from '../shared'
6import { RequestScheduler } from '../../../../../../shared'
6 7
7@Component({ 8@Component({
8 selector: 'my-request-stats', 9 selector: 'my-request-stats',
@@ -16,11 +17,7 @@ export class RequestStatsComponent implements OnInit, OnDestroy {
16 requestVideoQaduScheduler: 'Quick and dirty video updates request scheduler' 17 requestVideoQaduScheduler: 'Quick and dirty video updates request scheduler'
17 } 18 }
18 19
19 stats: { [ id: string ]: RequestStats } = { 20 stats: RequestScheduler
20 requestScheduler: null,
21 requestVideoEventScheduler: null,
22 requestVideoQaduScheduler: null
23 }
24 21
25 private intervals: { [ id: string ]: number } = { 22 private intervals: { [ id: string ]: number } = {
26 requestScheduler: null, 23 requestScheduler: null,
@@ -67,7 +64,7 @@ export class RequestStatsComponent implements OnInit, OnDestroy {
67 private runIntervals () { 64 private runIntervals () {
68 Object.keys(this.intervals).forEach(requestSchedulerName => { 65 Object.keys(this.intervals).forEach(requestSchedulerName => {
69 this.intervals[requestSchedulerName] = window.setInterval(() => { 66 this.intervals[requestSchedulerName] = window.setInterval(() => {
70 const stats = this.stats[requestSchedulerName] 67 const stats: RequestSchedulerStatsAttributes = this.stats[requestSchedulerName]
71 68
72 stats.remainingMilliSeconds -= 1000 69 stats.remainingMilliSeconds -= 1000
73 70
diff --git a/client/src/app/+admin/requests/shared/index.ts b/client/src/app/+admin/requests/shared/index.ts
index 2442e810a..857fe9d29 100644
--- a/client/src/app/+admin/requests/shared/index.ts
+++ b/client/src/app/+admin/requests/shared/index.ts
@@ -1,2 +1,2 @@
1export * from './request-stats.model' 1export * from './request-stats-attributes.model'
2export * from './request.service' 2export * from './request.service'
diff --git a/client/src/app/+admin/requests/shared/request-stats.model.ts b/client/src/app/+admin/requests/shared/request-stats-attributes.model.ts
index 31550b5c0..394acc73d 100644
--- a/client/src/app/+admin/requests/shared/request-stats.model.ts
+++ b/client/src/app/+admin/requests/shared/request-stats-attributes.model.ts
@@ -1,9 +1,11 @@
1import { RequestSchedulerAttributes as FormatedRequestSchedulerAttributes } from '../../../../../../shared'
2
1export interface Request { 3export interface Request {
2 request: any 4 request: any
3 to: any 5 to: any
4} 6}
5 7
6export class RequestStats { 8export class RequestSchedulerStatsAttributes implements FormatedRequestSchedulerAttributes {
7 requestsLimitPods: number 9 requestsLimitPods: number
8 requestsLimitPerPod: number 10 requestsLimitPerPod: number
9 milliSecondsInterval: number 11 milliSecondsInterval: number
diff --git a/client/src/app/+admin/requests/shared/request.service.ts b/client/src/app/+admin/requests/shared/request.service.ts
index faa6b9383..53682b111 100644
--- a/client/src/app/+admin/requests/shared/request.service.ts
+++ b/client/src/app/+admin/requests/shared/request.service.ts
@@ -3,8 +3,9 @@ import { Observable } from 'rxjs/Observable'
3import 'rxjs/add/operator/catch' 3import 'rxjs/add/operator/catch'
4import 'rxjs/add/operator/map' 4import 'rxjs/add/operator/map'
5 5
6import { RequestStats } from './request-stats.model' 6import { RequestScheduler } from '../../../../../../shared'
7import { AuthHttp, RestExtractor } from '../../../shared' 7import { AuthHttp, RestExtractor } from '../../../shared'
8import { RequestSchedulerStatsAttributes } from './request-stats-attributes.model'
8 9
9@Injectable() 10@Injectable()
10export class RequestService { 11export class RequestService {
@@ -15,18 +16,18 @@ export class RequestService {
15 private restExtractor: RestExtractor 16 private restExtractor: RestExtractor
16 ) {} 17 ) {}
17 18
18 getStats (): Observable<{ [ id: string ]: RequestStats }> { 19 getStats (): Observable<RequestScheduler> {
19 return this.authHttp.get(RequestService.BASE_REQUEST_URL + 'stats') 20 return this.authHttp.get(RequestService.BASE_REQUEST_URL + 'stats')
20 .map(this.restExtractor.extractDataGet) 21 .map(this.restExtractor.extractDataGet)
21 .map(this.buildRequestObjects) 22 .map(this.buildRequestObjects)
22 .catch((res) => this.restExtractor.handleError(res)) 23 .catch((res) => this.restExtractor.handleError(res))
23 } 24 }
24 25
25 private buildRequestObjects (data: any) { 26 private buildRequestObjects (data: RequestScheduler) {
26 const requestSchedulers = {} 27 const requestSchedulers = {}
27 28
28 Object.keys(data).forEach(requestSchedulerName => { 29 Object.keys(data).forEach(requestSchedulerName => {
29 requestSchedulers[requestSchedulerName] = new RequestStats(data[requestSchedulerName]) 30 requestSchedulers[requestSchedulerName] = new RequestSchedulerStatsAttributes(data[requestSchedulerName])
30 }) 31 })
31 32
32 return requestSchedulers 33 return requestSchedulers
diff --git a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts
index 60eaebb44..7c838fbf0 100644
--- a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts
+++ b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts
@@ -2,7 +2,8 @@ import { Component } from '@angular/core'
2 2
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4 4
5import { Utils, VideoAbuseService, VideoAbuse } from '../../../shared' 5import { Utils, VideoAbuseService } from '../../../shared'
6import { VideoAbuse } from '../../../../../shared'
6 7
7@Component({ 8@Component({
8 selector: 'my-video-abuse-list', 9 selector: 'my-video-abuse-list',
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index 32f7a5503..fcc6b9bb6 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -11,6 +11,7 @@ import { NotificationsService } from 'angular2-notifications'
11 11
12import { AuthStatus } from './auth-status.model' 12import { AuthStatus } from './auth-status.model'
13import { AuthUser } from './auth-user.model' 13import { AuthUser } from './auth-user.model'
14import { ClientLocal } from '../../../../../shared'
14// Do not use the barrel (dependency loop) 15// Do not use the barrel (dependency loop)
15import { RestExtractor } from '../../shared/rest' 16import { RestExtractor } from '../../shared/rest'
16 17
@@ -40,9 +41,9 @@ export class AuthService {
40 // FIXME: save in local storage? 41 // FIXME: save in local storage?
41 this.http.get(AuthService.BASE_CLIENT_URL) 42 this.http.get(AuthService.BASE_CLIENT_URL)
42 .map(this.restExtractor.extractDataGet) 43 .map(this.restExtractor.extractDataGet)
43 .catch((res) => this.restExtractor.handleError(res)) 44 .catch(res => this.restExtractor.handleError(res))
44 .subscribe( 45 .subscribe(
45 result => { 46 (result: ClientLocal) => {
46 this.clientId = result.client_id 47 this.clientId = result.client_id
47 this.clientSecret = result.client_secret 48 this.clientSecret = result.client_secret
48 console.log('Client credentials loaded.') 49 console.log('Client credentials loaded.')
diff --git a/client/src/app/core/config/config.service.ts b/client/src/app/core/config/config.service.ts
index a83ec61d2..b8cb15e84 100644
--- a/client/src/app/core/config/config.service.ts
+++ b/client/src/app/core/config/config.service.ts
@@ -2,16 +2,13 @@ import { Injectable } from '@angular/core'
2import { Http } from '@angular/http' 2import { Http } from '@angular/http'
3 3
4import { RestExtractor } from '../../shared/rest' 4import { RestExtractor } from '../../shared/rest'
5import { ServerConfig } from '../../../../../shared'
5 6
6@Injectable() 7@Injectable()
7export class ConfigService { 8export class ConfigService {
8 private static BASE_CONFIG_URL = API_URL + '/api/v1/config/' 9 private static BASE_CONFIG_URL = API_URL + '/api/v1/config/'
9 10
10 private config: { 11 private config: ServerConfig = {
11 signup: {
12 enabled: boolean
13 }
14 } = {
15 signup: { 12 signup: {
16 enabled: false 13 enabled: false
17 } 14 }
diff --git a/client/src/app/shared/video-abuse/video-abuse.model.ts b/client/src/app/shared/video-abuse/video-abuse.model.ts
deleted file mode 100644
index 49c87d6b8..000000000
--- a/client/src/app/shared/video-abuse/video-abuse.model.ts
+++ /dev/null
@@ -1,8 +0,0 @@
1export interface VideoAbuse {
2 id: string
3 reason: string
4 reporterPodHost: string
5 reporterUsername: string
6 videoId: string
7 createdAt: Date
8}
diff --git a/client/src/app/shared/video-abuse/video-abuse.service.ts b/client/src/app/shared/video-abuse/video-abuse.service.ts
index 4317f9353..32f13b430 100644
--- a/client/src/app/shared/video-abuse/video-abuse.service.ts
+++ b/client/src/app/shared/video-abuse/video-abuse.service.ts
@@ -7,7 +7,7 @@ import 'rxjs/add/operator/map'
7import { AuthService } from '../core' 7import { AuthService } from '../core'
8import { AuthHttp } from '../auth' 8import { AuthHttp } from '../auth'
9import { RestDataSource, RestExtractor, ResultList } from '../rest' 9import { RestDataSource, RestExtractor, ResultList } from '../rest'
10import { VideoAbuse } from './video-abuse.model' 10import { VideoAbuse } from '../../../../../shared'
11 11
12@Injectable() 12@Injectable()
13export class VideoAbuseService { 13export class VideoAbuseService {
diff --git a/client/src/app/videos/shared/rate-type.type.ts b/client/src/app/videos/shared/rate-type.type.ts
deleted file mode 100644
index 20eea3ae5..000000000
--- a/client/src/app/videos/shared/rate-type.type.ts
+++ /dev/null
@@ -1 +0,0 @@
1export type RateType = 'like' | 'dislike'
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts
index a4e3d16df..977b82118 100644
--- a/client/src/app/videos/shared/video.service.ts
+++ b/client/src/app/videos/shared/video.service.ts
@@ -6,7 +6,6 @@ import 'rxjs/add/operator/map'
6 6
7import { Search } from '../../shared' 7import { Search } from '../../shared'
8import { SortField } from './sort-field.type' 8import { SortField } from './sort-field.type'
9import { RateType } from './rate-type.type'
10import { AuthService } from '../../core' 9import { AuthService } from '../../core'
11import { 10import {
12 AuthHttp, 11 AuthHttp,
@@ -17,6 +16,7 @@ import {
17 UserService 16 UserService
18} from '../../shared' 17} from '../../shared'
19import { Video } from './video.model' 18import { Video } from './video.model'
19import { VideoRateType } from '../../../../../shared'
20 20
21@Injectable() 21@Injectable()
22export class VideoService { 22export class VideoService {
@@ -145,7 +145,7 @@ export class VideoService {
145 return this.setVideoRate(id, 'dislike') 145 return this.setVideoRate(id, 'dislike')
146 } 146 }
147 147
148 getUserVideoRating (id: string) { 148 getUserVideoRating (id: string): Observable<VideoRateType> {
149 const url = UserService.BASE_USERS_URL + '/me/videos/' + id + '/rating' 149 const url = UserService.BASE_USERS_URL + '/me/videos/' + id + '/rating'
150 150
151 return this.authHttp.get(url) 151 return this.authHttp.get(url)
@@ -159,7 +159,7 @@ export class VideoService {
159 .catch((res) => this.restExtractor.handleError(res)) 159 .catch((res) => this.restExtractor.handleError(res))
160 } 160 }
161 161
162 private setVideoRate (id: string, rateType: RateType) { 162 private setVideoRate (id: string, rateType: VideoRateType) {
163 const url = VideoService.BASE_VIDEO_URL + id + '/rate' 163 const url = VideoService.BASE_VIDEO_URL + id + '/rate'
164 const body = { 164 const body = {
165 rating: rateType 165 rating: rateType
diff --git a/client/src/app/videos/video-watch/video-watch.component.ts b/client/src/app/videos/video-watch/video-watch.component.ts
index 4a547f7e4..808e0eda9 100644
--- a/client/src/app/videos/video-watch/video-watch.component.ts
+++ b/client/src/app/videos/video-watch/video-watch.component.ts
@@ -11,15 +11,15 @@ import { AuthService, ConfirmService } from '../../core'
11import { VideoMagnetComponent } from './video-magnet.component' 11import { VideoMagnetComponent } from './video-magnet.component'
12import { VideoShareComponent } from './video-share.component' 12import { VideoShareComponent } from './video-share.component'
13import { VideoReportComponent } from './video-report.component' 13import { VideoReportComponent } from './video-report.component'
14import { RateType, Video, VideoService } from '../shared' 14import { Video, VideoService } from '../shared'
15import { WebTorrentService } from './webtorrent.service' 15import { WebTorrentService } from './webtorrent.service'
16import { UserVideoRateType, VideoRateType, UserVideoRate } from '../../../../../shared'
16 17
17@Component({ 18@Component({
18 selector: 'my-video-watch', 19 selector: 'my-video-watch',
19 templateUrl: './video-watch.component.html', 20 templateUrl: './video-watch.component.html',
20 styleUrls: [ './video-watch.component.scss' ] 21 styleUrls: [ './video-watch.component.scss' ]
21}) 22})
22
23export class VideoWatchComponent implements OnInit, OnDestroy { 23export class VideoWatchComponent implements OnInit, OnDestroy {
24 private static LOADTIME_TOO_LONG = 20000 24 private static LOADTIME_TOO_LONG = 20000
25 25
@@ -34,7 +34,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
34 player: videojs.Player 34 player: videojs.Player
35 playerElement: Element 35 playerElement: Element
36 uploadSpeed: number 36 uploadSpeed: number
37 userRating: RateType = null 37 userRating: UserVideoRateType = null
38 video: Video = null 38 video: Video = null
39 videoNotFound = false 39 videoNotFound = false
40 40
@@ -249,7 +249,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
249 249
250 this.videoService.getUserVideoRating(this.video.id) 250 this.videoService.getUserVideoRating(this.video.id)
251 .subscribe( 251 .subscribe(
252 ratingObject => { 252 (ratingObject: UserVideoRate) => {
253 if (ratingObject) { 253 if (ratingObject) {
254 this.userRating = ratingObject.rating 254 this.userRating = ratingObject.rating
255 } 255 }
@@ -282,7 +282,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
282 ) 282 )
283 } 283 }
284 284
285 private updateVideoRating (oldRating: RateType, newRating: RateType) { 285 private updateVideoRating (oldRating: UserVideoRateType, newRating: VideoRateType) {
286 let likesToIncrement = 0 286 let likesToIncrement = 0
287 let dislikesToIncrement = 0 287 let dislikesToIncrement = 0
288 288
diff --git a/server/controllers/api/clients.ts b/server/controllers/api/clients.ts
index 8c460096b..96490d04a 100644
--- a/server/controllers/api/clients.ts
+++ b/server/controllers/api/clients.ts
@@ -3,6 +3,7 @@ import * as express from 'express'
3import { CONFIG } from '../../initializers' 3import { CONFIG } from '../../initializers'
4import { logger } from '../../helpers' 4import { logger } from '../../helpers'
5import { database as db } from '../../initializers/database' 5import { database as db } from '../../initializers/database'
6import { ClientLocal } from '../../../shared'
6 7
7const clientsRouter = express.Router() 8const clientsRouter = express.Router()
8 9
@@ -27,10 +28,11 @@ function getLocalClient (req: express.Request, res: express.Response, next: expr
27 if (err) return next(err) 28 if (err) return next(err)
28 if (!client) return next(new Error('No client available.')) 29 if (!client) return next(new Error('No client available.'))
29 30
30 res.json({ 31 const json: ClientLocal = {
31 client_id: client.clientId, 32 client_id: client.clientId,
32 client_secret: client.clientSecret 33 client_secret: client.clientSecret
33 }) 34 }
35 res.json(json)
34 }) 36 })
35} 37}
36 38
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index c63981797..3e9aa77a5 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -1,6 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2 2
3import { CONFIG } from '../../initializers' 3import { CONFIG } from '../../initializers'
4import { ServerConfig } from '../../../shared'
4 5
5const configRouter = express.Router() 6const configRouter = express.Router()
6 7
@@ -8,11 +9,12 @@ configRouter.get('/', getConfig)
8 9
9// Get the client credentials for the PeerTube front end 10// Get the client credentials for the PeerTube front end
10function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) { 11function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
11 res.json({ 12 const json: ServerConfig = {
12 signup: { 13 signup: {
13 enabled: CONFIG.SIGNUP.ENABLED 14 enabled: CONFIG.SIGNUP.ENABLED
14 } 15 }
15 }) 16 }
17 res.json(json)
16} 18}
17 19
18// --------------------------------------------------------------------------- 20// ---------------------------------------------------------------------------
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts
index ffe5881e5..1e9e65689 100644
--- a/server/controllers/api/users.ts
+++ b/server/controllers/api/users.ts
@@ -17,6 +17,7 @@ import {
17 setUsersSort, 17 setUsersSort,
18 token 18 token
19} from '../../middlewares' 19} from '../../middlewares'
20import { UserVideoRate as FormatedUserVideoRate } from '../../../shared'
20 21
21const usersRouter = express.Router() 22const usersRouter = express.Router()
22 23
@@ -119,10 +120,11 @@ function getUserVideoRating (req: express.Request, res: express.Response, next:
119 120
120 const rating = ratingObj ? ratingObj.type : 'none' 121 const rating = ratingObj ? ratingObj.type : 'none'
121 122
122 res.json({ 123 const json: FormatedUserVideoRate = {
123 videoId, 124 videoId,
124 rating 125 rating
125 }) 126 }
127 res.json(json)
126 }) 128 })
127} 129}
128 130
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts
index 07c1b3f51..5b8d21f70 100644
--- a/server/helpers/utils.ts
+++ b/server/helpers/utils.ts
@@ -22,8 +22,12 @@ function createEmptyCallback () {
22 } 22 }
23} 23}
24 24
25function getFormatedObjects (objects: any[], objectsTotal: number) { 25interface FormatableToJSON {
26 const formatedObjects = [] 26 toFormatedJSON()
27}
28
29function getFormatedObjects<U, T extends FormatableToJSON> (objects: T[], objectsTotal: number) {
30 const formatedObjects: U[] = []
27 31
28 objects.forEach(function (object) { 32 objects.forEach(function (object) {
29 formatedObjects.push(object.toFormatedJSON()) 33 formatedObjects.push(object.toFormatedJSON())
diff --git a/server/models/user/user-interface.ts b/server/models/user/user-interface.ts
index fd98a042e..48c67678b 100644
--- a/server/models/user/user-interface.ts
+++ b/server/models/user/user-interface.ts
@@ -58,6 +58,10 @@ export interface UserInstance extends UserClass, UserAttributes, Sequelize.Insta
58 id: number 58 id: number
59 createdAt: Date 59 createdAt: Date
60 updatedAt: Date 60 updatedAt: Date
61
62 isPasswordMatch: UserMethods.IsPasswordMatch
63 toFormatedJSON: UserMethods.ToFormatedJSON
64 isAdmin: UserMethods.IsAdmin
61} 65}
62 66
63export interface UserModel extends UserClass, Sequelize.Model<UserInstance, UserAttributes> {} 67export interface UserModel extends UserClass, Sequelize.Model<UserInstance, UserAttributes> {}
diff --git a/server/models/user/user-video-rate.ts b/server/models/user/user-video-rate.ts
index 1094eb281..4bdd35bc9 100644
--- a/server/models/user/user-video-rate.ts
+++ b/server/models/user/user-video-rate.ts
@@ -1,6 +1,5 @@
1/* 1/*
2 User rates per video. 2 User rates per video.
3
4*/ 3*/
5import { values } from 'lodash' 4import { values } from 'lodash'
6import * as Sequelize from 'sequelize' 5import * as Sequelize from 'sequelize'
diff --git a/server/models/video/video-abuse-interface.ts b/server/models/video/video-abuse-interface.ts
index f3e32f79c..c85d09091 100644
--- a/server/models/video/video-abuse-interface.ts
+++ b/server/models/video/video-abuse-interface.ts
@@ -6,7 +6,7 @@ import { PodInstance } from '../pod'
6import { VideoAbuse as FormatedVideoAbuse } from '../../../shared/models/video-abuse.model' 6import { VideoAbuse as FormatedVideoAbuse } from '../../../shared/models/video-abuse.model'
7 7
8export namespace VideoAbuseMethods { 8export namespace VideoAbuseMethods {
9 export type toFormatedJSON = () => FormatedVideoAbuse 9 export type ToFormatedJSON = (this: VideoAbuseInstance) => FormatedVideoAbuse
10 10
11 export type ListForApiCallback = (err: Error, videoAbuseInstances?: VideoAbuseInstance[], total?: number) => void 11 export type ListForApiCallback = (err: Error, videoAbuseInstances?: VideoAbuseInstance[], total?: number) => void
12 export type ListForApi = (start: number, count: number, sort: string, callback: ListForApiCallback) => void 12 export type ListForApi = (start: number, count: number, sort: string, callback: ListForApiCallback) => void
@@ -28,6 +28,8 @@ export interface VideoAbuseInstance extends VideoAbuseClass, VideoAbuseAttribute
28 updatedAt: Date 28 updatedAt: Date
29 29
30 Pod: PodInstance 30 Pod: PodInstance
31
32 toFormatedJSON: VideoAbuseMethods.ToFormatedJSON
31} 33}
32 34
33export interface VideoAbuseModel extends VideoAbuseClass, Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> {} 35export interface VideoAbuseModel extends VideoAbuseClass, Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> {}
diff --git a/server/models/video/video-abuse.ts b/server/models/video/video-abuse.ts
index f5b4debe6..bc5f01e21 100644
--- a/server/models/video/video-abuse.ts
+++ b/server/models/video/video-abuse.ts
@@ -13,6 +13,7 @@ import {
13} from './video-abuse-interface' 13} from './video-abuse-interface'
14 14
15let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> 15let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes>
16let toFormatedJSON: VideoAbuseMethods.ToFormatedJSON
16let listForApi: VideoAbuseMethods.ListForApi 17let listForApi: VideoAbuseMethods.ListForApi
17 18
18export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { 19export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
@@ -66,7 +67,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
66 67
67// ------------------------------ METHODS ------------------------------ 68// ------------------------------ METHODS ------------------------------
68 69
69function toFormatedJSON (this: VideoAbuseInstance) { 70toFormatedJSON = function (this: VideoAbuseInstance) {
70 let reporterPodHost 71 let reporterPodHost
71 72
72 if (this.Pod) { 73 if (this.Pod) {
@@ -108,7 +109,7 @@ function associate (models) {
108 }) 109 })
109} 110}
110 111
111listForApi = function (start, count, sort, callback) { 112listForApi = function (start: number, count: number, sort: string, callback: VideoAbuseMethods.ListForApiCallback) {
112 const query = { 113 const query = {
113 offset: start, 114 offset: start,
114 limit: count, 115 limit: count,
diff --git a/server/models/video/video-blacklist-interface.ts b/server/models/video/video-blacklist-interface.ts
index c34e7fb09..d4d6528d1 100644
--- a/server/models/video/video-blacklist-interface.ts
+++ b/server/models/video/video-blacklist-interface.ts
@@ -39,6 +39,8 @@ export interface BlacklistedVideoInstance extends BlacklistedVideoClass, Blackli
39 id: number 39 id: number
40 createdAt: Date 40 createdAt: Date
41 updatedAt: Date 41 updatedAt: Date
42
43 toFormatedJSON: BlacklistedVideoMethods.ToFormatedJSON
42} 44}
43 45
44export interface BlacklistedVideoModel extends BlacklistedVideoClass, Sequelize.Model<BlacklistedVideoInstance, BlacklistedVideoAttributes> {} 46export interface BlacklistedVideoModel extends BlacklistedVideoClass, Sequelize.Model<BlacklistedVideoInstance, BlacklistedVideoAttributes> {}
diff --git a/server/models/video/video-interface.ts b/server/models/video/video-interface.ts
index 5fefc2bb1..4b591b9e7 100644
--- a/server/models/video/video-interface.ts
+++ b/server/models/video/video-interface.ts
@@ -146,6 +146,17 @@ export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.In
146 id: string 146 id: string
147 createdAt: Date 147 createdAt: Date
148 updatedAt: Date 148 updatedAt: Date
149
150 generateMagnetUri: VideoMethods.GenerateMagnetUri
151 getVideoFilename: VideoMethods.GetVideoFilename
152 getThumbnailName: VideoMethods.GetThumbnailName
153 getPreviewName: VideoMethods.GetPreviewName
154 getTorrentName: VideoMethods.GetTorrentName
155 isOwned: VideoMethods.IsOwned
156 toFormatedJSON: VideoMethods.ToFormatedJSON
157 toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
158 toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
159 transcodeVideofile: VideoMethods.TranscodeVideofile
149} 160}
150 161
151export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} 162export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {}
diff --git a/shared/models/client-local.model.ts b/shared/models/client-local.model.ts
new file mode 100644
index 000000000..c27963e88
--- /dev/null
+++ b/shared/models/client-local.model.ts
@@ -0,0 +1,4 @@
1export interface ClientLocal {
2 client_id: string
3 client_secret: string
4}
diff --git a/shared/models/index.ts b/shared/models/index.ts
index 1ddc8545f..fffac795e 100644
--- a/shared/models/index.ts
+++ b/shared/models/index.ts
@@ -1,3 +1,4 @@
1export * from './client-local.model'
1export * from './job.model' 2export * from './job.model'
2export * from './pod.model' 3export * from './pod.model'
3export * from './request-scheduler.model' 4export * from './request-scheduler.model'
@@ -6,3 +7,4 @@ export * from './user.model'
6export * from './video-abuse.model' 7export * from './video-abuse.model'
7export * from './video-blacklist.model' 8export * from './video-blacklist.model'
8export * from './video.model' 9export * from './video.model'
10export * from './server-config.model'
diff --git a/shared/models/server-config.model.ts b/shared/models/server-config.model.ts
new file mode 100644
index 000000000..a39156963
--- /dev/null
+++ b/shared/models/server-config.model.ts
@@ -0,0 +1,5 @@
1export interface ServerConfig {
2 signup: {
3 enabled: boolean
4 }
5}
diff --git a/shared/models/user-video-rate.model.ts b/shared/models/user-video-rate.model.ts
index d48774a4b..b770f4073 100644
--- a/shared/models/user-video-rate.model.ts
+++ b/shared/models/user-video-rate.model.ts
@@ -1 +1,7 @@
1export type VideoRateType = 'like' | 'dislike' 1export type VideoRateType = 'like' | 'dislike'
2export type UserVideoRateType = 'like' | 'dislike' | 'none'
3
4export interface UserVideoRate {
5 videoId: string
6 rating: UserVideoRateType
7}
diff --git a/shared/models/video-abuse.model.ts b/shared/models/video-abuse.model.ts
index e005a1fd5..72e32cbc7 100644
--- a/shared/models/video-abuse.model.ts
+++ b/shared/models/video-abuse.model.ts
@@ -3,6 +3,6 @@ export interface VideoAbuse {
3 reporterPodHost: string 3 reporterPodHost: string
4 reason: string 4 reason: string
5 reporterUsername: string 5 reporterUsername: string
6 videoId: number 6 videoId: string
7 createdAt: Date 7 createdAt: Date
8} 8}