diff options
21 files changed, 89 insertions, 29 deletions
diff --git a/server/controllers/api/requests.ts b/server/controllers/api/requests.ts index d3f0d958c..5718b59b7 100644 --- a/server/controllers/api/requests.ts +++ b/server/controllers/api/requests.ts | |||
@@ -8,6 +8,7 @@ import { | |||
8 | getRequestVideoEventScheduler | 8 | getRequestVideoEventScheduler |
9 | } from '../../lib' | 9 | } from '../../lib' |
10 | import { authenticate, ensureIsAdmin } from '../../middlewares' | 10 | import { authenticate, ensureIsAdmin } from '../../middlewares' |
11 | import { RequestSchedulerAttributes } from '../../../shared' | ||
11 | 12 | ||
12 | const requestsRouter = express.Router() | 13 | const requestsRouter = express.Router() |
13 | 14 | ||
@@ -44,7 +45,7 @@ function buildRequestSchedulerFunction (requestScheduler: AbstractRequestSchedul | |||
44 | requestScheduler.remainingRequestsCount(function (err, count) { | 45 | requestScheduler.remainingRequestsCount(function (err, count) { |
45 | if (err) return callback(err) | 46 | if (err) return callback(err) |
46 | 47 | ||
47 | const result = { | 48 | const result: RequestSchedulerAttributes = { |
48 | totalRequests: count, | 49 | totalRequests: count, |
49 | requestsLimitPods: requestScheduler.limitPods, | 50 | requestsLimitPods: requestScheduler.limitPods, |
50 | requestsLimitPerPod: requestScheduler.limitPerPod, | 51 | requestsLimitPerPod: requestScheduler.limitPerPod, |
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 7792ffd74..750563ada 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts | |||
@@ -3,6 +3,8 @@ import * as validator from 'validator' | |||
3 | 3 | ||
4 | import { exists } from './misc' | 4 | import { exists } from './misc' |
5 | import { CONSTRAINTS_FIELDS, USER_ROLES } from '../../initializers' | 5 | import { CONSTRAINTS_FIELDS, USER_ROLES } from '../../initializers' |
6 | import { UserRole } from '../../../shared' | ||
7 | |||
6 | const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS | 8 | const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS |
7 | 9 | ||
8 | function isUserPasswordValid (value: string) { | 10 | function isUserPasswordValid (value: string) { |
@@ -10,7 +12,7 @@ function isUserPasswordValid (value: string) { | |||
10 | } | 12 | } |
11 | 13 | ||
12 | function isUserRoleValid (value: string) { | 14 | function isUserRoleValid (value: string) { |
13 | return values(USER_ROLES).indexOf(value) !== -1 | 15 | return values(USER_ROLES).indexOf(value as UserRole) !== -1 |
14 | } | 16 | } |
15 | 17 | ||
16 | function isUserUsernameValid (value: string) { | 18 | function isUserUsernameValid (value: string) { |
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 8904975c0..72d226e81 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -11,6 +11,7 @@ import { | |||
11 | } from '../../initializers' | 11 | } from '../../initializers' |
12 | import { isUserUsernameValid } from './users' | 12 | import { isUserUsernameValid } from './users' |
13 | import { isArray, exists } from './misc' | 13 | import { isArray, exists } from './misc' |
14 | import { VideoRateType } from '../../../shared' | ||
14 | 15 | ||
15 | const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS | 16 | const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS |
16 | const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES | 17 | const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES |
@@ -105,7 +106,7 @@ function isVideoEventCountValid (value: string) { | |||
105 | } | 106 | } |
106 | 107 | ||
107 | function isVideoRatingTypeValid (value: string) { | 108 | function isVideoRatingTypeValid (value: string) { |
108 | return values(VIDEO_RATE_TYPES).indexOf(value) !== -1 | 109 | return values(VIDEO_RATE_TYPES).indexOf(value as VideoRateType) !== -1 |
109 | } | 110 | } |
110 | 111 | ||
111 | function isVideoFile (value: string, files: { [ fieldname: string ]: Express.Multer.File[] }) { | 112 | function isVideoFile (value: string, files: { [ fieldname: string ]: Express.Multer.File[] }) { |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index b476ef928..bf99f4df6 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -4,6 +4,15 @@ import { join } from 'path' | |||
4 | // Do not use barrels, remain constants as independent as possible | 4 | // Do not use barrels, remain constants as independent as possible |
5 | import { root, isTestInstance } from '../helpers/core-utils' | 5 | import { root, isTestInstance } from '../helpers/core-utils' |
6 | 6 | ||
7 | import { | ||
8 | UserRole, | ||
9 | VideoRateType, | ||
10 | RequestEndpoint, | ||
11 | RequestVideoEventType, | ||
12 | RequestVideoQaduType, | ||
13 | JobState | ||
14 | } from '../../shared/models' | ||
15 | |||
7 | // --------------------------------------------------------------------------- | 16 | // --------------------------------------------------------------------------- |
8 | 17 | ||
9 | const LAST_MIGRATION_VERSION = 50 | 18 | const LAST_MIGRATION_VERSION = 50 |
@@ -105,7 +114,7 @@ const CONSTRAINTS_FIELDS = { | |||
105 | } | 114 | } |
106 | } | 115 | } |
107 | 116 | ||
108 | const VIDEO_RATE_TYPES = { | 117 | const VIDEO_RATE_TYPES: { [ id: string ]: VideoRateType } = { |
109 | LIKE: 'like', | 118 | LIKE: 'like', |
110 | DISLIKE: 'dislike' | 119 | DISLIKE: 'dislike' |
111 | } | 120 | } |
@@ -198,7 +207,7 @@ const REQUESTS_VIDEO_EVENT_LIMIT_PER_POD = 50 | |||
198 | // Number of requests to retry for replay requests module | 207 | // Number of requests to retry for replay requests module |
199 | const RETRY_REQUESTS = 5 | 208 | const RETRY_REQUESTS = 5 |
200 | 209 | ||
201 | const REQUEST_ENDPOINTS = { | 210 | const REQUEST_ENDPOINTS: { [ id: string ]: RequestEndpoint } = { |
202 | VIDEOS: 'videos' | 211 | VIDEOS: 'videos' |
203 | } | 212 | } |
204 | 213 | ||
@@ -213,13 +222,13 @@ REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = { | |||
213 | const REQUEST_VIDEO_QADU_ENDPOINT = 'videos/qadu' | 222 | const REQUEST_VIDEO_QADU_ENDPOINT = 'videos/qadu' |
214 | const REQUEST_VIDEO_EVENT_ENDPOINT = 'videos/events' | 223 | const REQUEST_VIDEO_EVENT_ENDPOINT = 'videos/events' |
215 | 224 | ||
216 | const REQUEST_VIDEO_QADU_TYPES = { | 225 | const REQUEST_VIDEO_QADU_TYPES: { [ id: string ]: RequestVideoQaduType } = { |
217 | LIKES: 'likes', | 226 | LIKES: 'likes', |
218 | DISLIKES: 'dislikes', | 227 | DISLIKES: 'dislikes', |
219 | VIEWS: 'views' | 228 | VIEWS: 'views' |
220 | } | 229 | } |
221 | 230 | ||
222 | const REQUEST_VIDEO_EVENT_TYPES = { | 231 | const REQUEST_VIDEO_EVENT_TYPES: { [ id: string ]: RequestVideoEventType } = { |
223 | LIKES: 'likes', | 232 | LIKES: 'likes', |
224 | DISLIKES: 'dislikes', | 233 | DISLIKES: 'dislikes', |
225 | VIEWS: 'views' | 234 | VIEWS: 'views' |
@@ -230,7 +239,7 @@ const REMOTE_SCHEME = { | |||
230 | WS: 'wss' | 239 | WS: 'wss' |
231 | } | 240 | } |
232 | 241 | ||
233 | const JOB_STATES = { | 242 | const JOB_STATES: { [ id: string ]: JobState } = { |
234 | PENDING: 'pending', | 243 | PENDING: 'pending', |
235 | PROCESSING: 'processing', | 244 | PROCESSING: 'processing', |
236 | ERROR: 'error', | 245 | ERROR: 'error', |
@@ -271,7 +280,7 @@ const PREVIEWS_SIZE = '640x480' | |||
271 | 280 | ||
272 | // --------------------------------------------------------------------------- | 281 | // --------------------------------------------------------------------------- |
273 | 282 | ||
274 | const USER_ROLES = { | 283 | const USER_ROLES: { [ id: string ]: UserRole } = { |
275 | ADMIN: 'admin', | 284 | ADMIN: 'admin', |
276 | USER: 'user' | 285 | USER: 'user' |
277 | } | 286 | } |
diff --git a/server/lib/friends.ts b/server/lib/friends.ts index e097f9254..d07433a5d 100644 --- a/server/lib/friends.ts +++ b/server/lib/friends.ts | |||
@@ -28,10 +28,18 @@ import { | |||
28 | RequestVideoEventScheduler, | 28 | RequestVideoEventScheduler, |
29 | RequestVideoEventSchedulerOptions | 29 | RequestVideoEventSchedulerOptions |
30 | } from './request' | 30 | } from './request' |
31 | import { PodInstance, VideoInstance } from '../models' | 31 | import { |
32 | PodInstance, | ||
33 | VideoInstance | ||
34 | } from '../models' | ||
35 | import { | ||
36 | RequestEndpoint, | ||
37 | RequestVideoEventType, | ||
38 | RequestVideoQaduType | ||
39 | } from '../../shared' | ||
32 | 40 | ||
33 | type QaduParam = { videoId: string, type: string } | 41 | type QaduParam = { videoId: string, type: RequestVideoQaduType } |
34 | type EventParam = { videoId: string, type: string } | 42 | type EventParam = { videoId: string, type: RequestVideoEventType } |
35 | 43 | ||
36 | const ENDPOINT_ACTIONS = REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] | 44 | const ENDPOINT_ACTIONS = REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] |
37 | 45 | ||
@@ -391,7 +399,7 @@ function makeRequestsToWinningPods (cert: string, podsList: PodInstance[], callb | |||
391 | // Wrapper that populate "toIds" argument with all our friends if it is not specified | 399 | // Wrapper that populate "toIds" argument with all our friends if it is not specified |
392 | type CreateRequestOptions = { | 400 | type CreateRequestOptions = { |
393 | type: string | 401 | type: string |
394 | endpoint: string | 402 | endpoint: RequestEndpoint |
395 | data: Object | 403 | data: Object |
396 | toIds?: number[] | 404 | toIds?: number[] |
397 | transaction: Sequelize.Transaction | 405 | transaction: Sequelize.Transaction |
diff --git a/server/lib/request/request-scheduler.ts b/server/lib/request/request-scheduler.ts index 38c0cca3d..575e0227c 100644 --- a/server/lib/request/request-scheduler.ts +++ b/server/lib/request/request-scheduler.ts | |||
@@ -7,10 +7,11 @@ import { | |||
7 | REQUESTS_LIMIT_PODS, | 7 | REQUESTS_LIMIT_PODS, |
8 | REQUESTS_LIMIT_PER_POD | 8 | REQUESTS_LIMIT_PER_POD |
9 | } from '../../initializers' | 9 | } from '../../initializers' |
10 | import { RequestEndpoint } from '../../../shared' | ||
10 | 11 | ||
11 | export type RequestSchedulerOptions = { | 12 | export type RequestSchedulerOptions = { |
12 | type: string | 13 | type: string |
13 | endpoint: string | 14 | endpoint: RequestEndpoint |
14 | data: Object | 15 | data: Object |
15 | toIds: number[] | 16 | toIds: number[] |
16 | transaction: Sequelize.Transaction | 17 | transaction: Sequelize.Transaction |
diff --git a/server/lib/request/request-video-event-scheduler.ts b/server/lib/request/request-video-event-scheduler.ts index c9d165117..4bb76f4c9 100644 --- a/server/lib/request/request-video-event-scheduler.ts +++ b/server/lib/request/request-video-event-scheduler.ts | |||
@@ -7,9 +7,10 @@ import { | |||
7 | REQUESTS_VIDEO_EVENT_LIMIT_PER_POD, | 7 | REQUESTS_VIDEO_EVENT_LIMIT_PER_POD, |
8 | REQUEST_VIDEO_EVENT_ENDPOINT | 8 | REQUEST_VIDEO_EVENT_ENDPOINT |
9 | } from '../../initializers' | 9 | } from '../../initializers' |
10 | import { RequestVideoEventType } from '../../../shared' | ||
10 | 11 | ||
11 | export type RequestVideoEventSchedulerOptions = { | 12 | export type RequestVideoEventSchedulerOptions = { |
12 | type: string | 13 | type: RequestVideoEventType |
13 | videoId: string | 14 | videoId: string |
14 | count?: number | 15 | count?: number |
15 | transaction?: Sequelize.Transaction | 16 | transaction?: Sequelize.Transaction |
diff --git a/server/lib/request/request-video-qadu-scheduler.ts b/server/lib/request/request-video-qadu-scheduler.ts index 49970a2e6..d7169cc81 100644 --- a/server/lib/request/request-video-qadu-scheduler.ts +++ b/server/lib/request/request-video-qadu-scheduler.ts | |||
@@ -9,9 +9,10 @@ import { | |||
9 | REQUEST_VIDEO_QADU_ENDPOINT, | 9 | REQUEST_VIDEO_QADU_ENDPOINT, |
10 | REQUEST_VIDEO_QADU_TYPES | 10 | REQUEST_VIDEO_QADU_TYPES |
11 | } from '../../initializers' | 11 | } from '../../initializers' |
12 | import { RequestVideoQaduType } from '../../../shared' | ||
12 | 13 | ||
13 | export type RequestVideoQaduSchedulerOptions = { | 14 | export type RequestVideoQaduSchedulerOptions = { |
14 | type: string | 15 | type: RequestVideoQaduType |
15 | videoId: string | 16 | videoId: string |
16 | transaction?: Sequelize.Transaction | 17 | transaction?: Sequelize.Transaction |
17 | } | 18 | } |
diff --git a/server/models/job/job-interface.ts b/server/models/job/job-interface.ts index ab6678257..31b377367 100644 --- a/server/models/job/job-interface.ts +++ b/server/models/job/job-interface.ts | |||
@@ -1,8 +1,10 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { JobState } from '../../../shared/models/job.model' | ||
4 | |||
3 | export namespace JobMethods { | 5 | export namespace JobMethods { |
4 | export type ListWithLimitCallback = (err: Error, jobInstances: JobInstance[]) => void | 6 | export type ListWithLimitCallback = (err: Error, jobInstances: JobInstance[]) => void |
5 | export type ListWithLimit = (limit: number, state: string, callback: ListWithLimitCallback) => void | 7 | export type ListWithLimit = (limit: number, state: JobState, callback: ListWithLimitCallback) => void |
6 | } | 8 | } |
7 | 9 | ||
8 | export interface JobClass { | 10 | export interface JobClass { |
@@ -10,7 +12,7 @@ export interface JobClass { | |||
10 | } | 12 | } |
11 | 13 | ||
12 | export interface JobAttributes { | 14 | export interface JobAttributes { |
13 | state: string | 15 | state: JobState |
14 | handlerName: string | 16 | handlerName: string |
15 | handlerInputData: object | 17 | handlerInputData: object |
16 | } | 18 | } |
diff --git a/server/models/job/job.ts b/server/models/job/job.ts index 60a6c551b..38e4e8f30 100644 --- a/server/models/job/job.ts +++ b/server/models/job/job.ts | |||
@@ -11,6 +11,7 @@ import { | |||
11 | 11 | ||
12 | JobMethods | 12 | JobMethods |
13 | } from './job-interface' | 13 | } from './job-interface' |
14 | import { JobState } from '../../../shared/models/job.model' | ||
14 | 15 | ||
15 | let Job: Sequelize.Model<JobInstance, JobAttributes> | 16 | let Job: Sequelize.Model<JobInstance, JobAttributes> |
16 | let listWithLimit: JobMethods.ListWithLimit | 17 | let listWithLimit: JobMethods.ListWithLimit |
@@ -48,7 +49,7 @@ export default function defineJob (sequelize: Sequelize.Sequelize, DataTypes: Se | |||
48 | 49 | ||
49 | // --------------------------------------------------------------------------- | 50 | // --------------------------------------------------------------------------- |
50 | 51 | ||
51 | listWithLimit = function (limit: number, state: string, callback: JobMethods.ListWithLimitCallback) { | 52 | listWithLimit = function (limit: number, state: JobState, callback: JobMethods.ListWithLimitCallback) { |
52 | const query = { | 53 | const query = { |
53 | order: [ | 54 | order: [ |
54 | [ 'id', 'ASC' ] | 55 | [ 'id', 'ASC' ] |
diff --git a/server/models/request/request-interface.ts b/server/models/request/request-interface.ts index 70fd734e1..483850633 100644 --- a/server/models/request/request-interface.ts +++ b/server/models/request/request-interface.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { PodInstance, PodAttributes } from '../pod' | 3 | import { PodInstance, PodAttributes } from '../pod' |
4 | import { RequestEndpoint } from '../../../shared/models/request-scheduler.model' | ||
4 | 5 | ||
5 | export type RequestsGrouped = { | 6 | export type RequestsGrouped = { |
6 | [ podId: number ]: { | 7 | [ podId: number ]: { |
@@ -32,7 +33,7 @@ export interface RequestClass { | |||
32 | 33 | ||
33 | export interface RequestAttributes { | 34 | export interface RequestAttributes { |
34 | request: object | 35 | request: object |
35 | endpoint: string | 36 | endpoint: RequestEndpoint |
36 | } | 37 | } |
37 | 38 | ||
38 | export interface RequestInstance extends RequestClass, RequestAttributes, Sequelize.Instance<RequestAttributes> { | 39 | export interface RequestInstance extends RequestClass, RequestAttributes, Sequelize.Instance<RequestAttributes> { |
diff --git a/server/models/request/request-video-event-interface.ts b/server/models/request/request-video-event-interface.ts index 219d8edc0..3ed03339a 100644 --- a/server/models/request/request-video-event-interface.ts +++ b/server/models/request/request-video-event-interface.ts | |||
@@ -3,10 +3,12 @@ import * as Sequelize from 'sequelize' | |||
3 | import { VideoInstance } from '../video' | 3 | import { VideoInstance } from '../video' |
4 | import { PodInstance } from '../pod' | 4 | import { PodInstance } from '../pod' |
5 | 5 | ||
6 | import { RequestVideoEventType } from '../../../shared/models/request-scheduler.model' | ||
7 | |||
6 | export type RequestsVideoEventGrouped = { | 8 | export type RequestsVideoEventGrouped = { |
7 | [ podId: number ]: { | 9 | [ podId: number ]: { |
8 | id: number | 10 | id: number |
9 | type: string | 11 | type: RequestVideoEventType |
10 | count: number | 12 | count: number |
11 | video: VideoInstance | 13 | video: VideoInstance |
12 | pod: PodInstance | 14 | pod: PodInstance |
@@ -35,7 +37,7 @@ export interface RequestVideoEventClass { | |||
35 | } | 37 | } |
36 | 38 | ||
37 | export interface RequestVideoEventAttributes { | 39 | export interface RequestVideoEventAttributes { |
38 | type: string | 40 | type: RequestVideoEventType |
39 | count: number | 41 | count: number |
40 | } | 42 | } |
41 | 43 | ||
diff --git a/server/models/request/request-video-qadu-interface.ts b/server/models/request/request-video-qadu-interface.ts index 625b063dc..805771cda 100644 --- a/server/models/request/request-video-qadu-interface.ts +++ b/server/models/request/request-video-qadu-interface.ts | |||
@@ -3,6 +3,8 @@ import * as Sequelize from 'sequelize' | |||
3 | import { VideoInstance } from '../video' | 3 | import { VideoInstance } from '../video' |
4 | import { PodInstance } from '../pod' | 4 | import { PodInstance } from '../pod' |
5 | 5 | ||
6 | import { RequestVideoQaduType } from '../../../shared/models/request-scheduler.model' | ||
7 | |||
6 | export type RequestsVideoQaduGrouped = { | 8 | export type RequestsVideoQaduGrouped = { |
7 | [ podId: number ]: { | 9 | [ podId: number ]: { |
8 | request: RequestVideoQaduInstance | 10 | request: RequestVideoQaduInstance |
@@ -33,7 +35,7 @@ export interface RequestVideoQaduClass { | |||
33 | } | 35 | } |
34 | 36 | ||
35 | export interface RequestVideoQaduAttributes { | 37 | export interface RequestVideoQaduAttributes { |
36 | type: string | 38 | type: RequestVideoQaduType |
37 | } | 39 | } |
38 | 40 | ||
39 | export interface RequestVideoQaduInstance extends RequestVideoQaduClass, RequestVideoQaduAttributes, Sequelize.Instance<RequestVideoQaduAttributes> { | 41 | export interface RequestVideoQaduInstance extends RequestVideoQaduClass, RequestVideoQaduAttributes, Sequelize.Instance<RequestVideoQaduAttributes> { |
diff --git a/server/models/user/user-interface.ts b/server/models/user/user-interface.ts index 6726e8ab5..fd98a042e 100644 --- a/server/models/user/user-interface.ts +++ b/server/models/user/user-interface.ts | |||
@@ -2,7 +2,7 @@ import * as Sequelize from 'sequelize' | |||
2 | import * as Bluebird from 'bluebird' | 2 | import * as Bluebird from 'bluebird' |
3 | 3 | ||
4 | // Don't use barrel, import just what we need | 4 | // Don't use barrel, import just what we need |
5 | import { User as FormatedUser } from '../../../shared/models/user.model' | 5 | import { UserRole, User as FormatedUser } from '../../../shared/models/user.model' |
6 | 6 | ||
7 | export namespace UserMethods { | 7 | export namespace UserMethods { |
8 | export type IsPasswordMatchCallback = (err: Error, same: boolean) => void | 8 | export type IsPasswordMatchCallback = (err: Error, same: boolean) => void |
@@ -51,7 +51,7 @@ export interface UserAttributes { | |||
51 | username: string | 51 | username: string |
52 | email: string | 52 | email: string |
53 | displayNSFW?: boolean | 53 | displayNSFW?: boolean |
54 | role: string | 54 | role: UserRole |
55 | } | 55 | } |
56 | 56 | ||
57 | export interface UserInstance extends UserClass, UserAttributes, Sequelize.Instance<UserAttributes> { | 57 | export interface UserInstance extends UserClass, UserAttributes, Sequelize.Instance<UserAttributes> { |
diff --git a/server/models/user/user-video-rate-interface.ts b/server/models/user/user-video-rate-interface.ts index e48869fd2..a726639b1 100644 --- a/server/models/user/user-video-rate-interface.ts +++ b/server/models/user/user-video-rate-interface.ts | |||
@@ -1,8 +1,10 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { VideoRateType } from '../../../shared/models/user-video-rate.model' | ||
4 | |||
3 | export namespace UserVideoRateMethods { | 5 | export namespace UserVideoRateMethods { |
4 | export type LoadCallback = (err: Error, userVideoRateInstance: UserVideoRateInstance) => void | 6 | export type LoadCallback = (err: Error, userVideoRateInstance: UserVideoRateInstance) => void |
5 | export type Load = (userId, videoId, transaction, callback) => void | 7 | export type Load = (userId: number, videoId: string, transaction: Sequelize.Transaction, callback: LoadCallback) => void |
6 | } | 8 | } |
7 | 9 | ||
8 | export interface UserVideoRateClass { | 10 | export interface UserVideoRateClass { |
@@ -10,7 +12,7 @@ export interface UserVideoRateClass { | |||
10 | } | 12 | } |
11 | 13 | ||
12 | export interface UserVideoRateAttributes { | 14 | export interface UserVideoRateAttributes { |
13 | type: string | 15 | type: VideoRateType |
14 | } | 16 | } |
15 | 17 | ||
16 | export interface UserVideoRateInstance extends UserVideoRateClass, UserVideoRateAttributes, Sequelize.Instance<UserVideoRateAttributes> { | 18 | export interface UserVideoRateInstance extends UserVideoRateClass, UserVideoRateAttributes, Sequelize.Instance<UserVideoRateAttributes> { |
diff --git a/server/models/user/user-video-rate.ts b/server/models/user/user-video-rate.ts index 68be62fc2..1094eb281 100644 --- a/server/models/user/user-video-rate.ts +++ b/server/models/user/user-video-rate.ts | |||
@@ -67,7 +67,7 @@ function associate (models) { | |||
67 | }) | 67 | }) |
68 | } | 68 | } |
69 | 69 | ||
70 | load = function (userId: number, videoId: number, transaction: Sequelize.Transaction, callback: UserVideoRateMethods.LoadCallback) { | 70 | load = function (userId: number, videoId: string, transaction: Sequelize.Transaction, callback: UserVideoRateMethods.LoadCallback) { |
71 | const options: Sequelize.FindOptions = { | 71 | const options: Sequelize.FindOptions = { |
72 | where: { | 72 | where: { |
73 | userId, | 73 | userId, |
diff --git a/shared/models/index.ts b/shared/models/index.ts index b498d620a..1ddc8545f 100644 --- a/shared/models/index.ts +++ b/shared/models/index.ts | |||
@@ -1,4 +1,7 @@ | |||
1 | export * from './job.model' | ||
1 | export * from './pod.model' | 2 | export * from './pod.model' |
3 | export * from './request-scheduler.model' | ||
4 | export * from './user-video-rate.model' | ||
2 | export * from './user.model' | 5 | export * from './user.model' |
3 | export * from './video-abuse.model' | 6 | export * from './video-abuse.model' |
4 | export * from './video-blacklist.model' | 7 | export * from './video-blacklist.model' |
diff --git a/shared/models/job.model.ts b/shared/models/job.model.ts new file mode 100644 index 000000000..411c91482 --- /dev/null +++ b/shared/models/job.model.ts | |||
@@ -0,0 +1 @@ | |||
export type JobState = 'pending' | 'processing' | 'error' | 'success' | |||
diff --git a/shared/models/request-scheduler.model.ts b/shared/models/request-scheduler.model.ts new file mode 100644 index 000000000..f94ccfcab --- /dev/null +++ b/shared/models/request-scheduler.model.ts | |||
@@ -0,0 +1,19 @@ | |||
1 | export type RequestEndpoint = 'videos' | ||
2 | |||
3 | export type RequestVideoQaduType = 'likes' | 'dislikes' | 'views' | ||
4 | |||
5 | export type RequestVideoEventType = 'likes' | 'dislikes' | 'views' | ||
6 | |||
7 | export type RequestSchedulerAttributes = { | ||
8 | totalRequests: number | ||
9 | requestsLimitPods: number | ||
10 | requestsLimitPerPod: number | ||
11 | remainingMilliSeconds: number | ||
12 | milliSecondsInterval: number | ||
13 | } | ||
14 | |||
15 | export interface RequestScheduler { | ||
16 | requestScheduler: RequestSchedulerAttributes | ||
17 | requestVideoQaduScheduler: RequestSchedulerAttributes | ||
18 | requestVideoEventScheduler: RequestSchedulerAttributes | ||
19 | } | ||
diff --git a/shared/models/user-video-rate.model.ts b/shared/models/user-video-rate.model.ts new file mode 100644 index 000000000..d48774a4b --- /dev/null +++ b/shared/models/user-video-rate.model.ts | |||
@@ -0,0 +1 @@ | |||
export type VideoRateType = 'like' | 'dislike' | |||
diff --git a/shared/models/user.model.ts b/shared/models/user.model.ts index a6be359d3..92dc73ec2 100644 --- a/shared/models/user.model.ts +++ b/shared/models/user.model.ts | |||
@@ -1,8 +1,10 @@ | |||
1 | export type UserRole = 'admin' | 'user' | ||
2 | |||
1 | export interface User { | 3 | export interface User { |
2 | id: number | 4 | id: number |
3 | username: string | 5 | username: string |
4 | email: string | 6 | email: string |
5 | displayNSFW: boolean | 7 | displayNSFW: boolean |
6 | role: string | 8 | role: UserRole |
7 | createdAt: Date | 9 | createdAt: Date |
8 | } | 10 | } |