diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 09:45:46 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 09:45:46 +0200 |
commit | 74889a71fe687dda74f2a687653122327807af36 (patch) | |
tree | e938e8b6401b74fbec80513a877d9967f2c0dbcd | |
parent | 15a302943d84bc0978b84fe33110c4daa451d311 (diff) | |
download | PeerTube-74889a71fe687dda74f2a687653122327807af36.tar.gz PeerTube-74889a71fe687dda74f2a687653122327807af36.tar.zst PeerTube-74889a71fe687dda74f2a687653122327807af36.zip |
Reorganize model files
-rw-r--r-- | server/initializers/database.ts | 68 | ||||
-rw-r--r-- | server/models/application/application-interface.ts (renamed from server/models/application-interface.ts) | 0 | ||||
-rw-r--r-- | server/models/application/application.ts (renamed from server/models/application.ts) | 2 | ||||
-rw-r--r-- | server/models/application/index.ts | 1 | ||||
-rw-r--r-- | server/models/index.ts | 24 | ||||
-rw-r--r-- | server/models/job/index.ts | 1 | ||||
-rw-r--r-- | server/models/job/job-interface.ts (renamed from server/models/job-interface.ts) | 0 | ||||
-rw-r--r-- | server/models/job/job.ts (renamed from server/models/job.ts) | 4 | ||||
-rw-r--r-- | server/models/oauth/index.ts | 2 | ||||
-rw-r--r-- | server/models/oauth/oauth-client-interface.ts (renamed from server/models/oauth-client-interface.ts) | 0 | ||||
-rw-r--r-- | server/models/oauth/oauth-client.ts (renamed from server/models/oauth-client.ts) | 2 | ||||
-rw-r--r-- | server/models/oauth/oauth-token-interface.ts (renamed from server/models/oauth-token-interface.ts) | 2 | ||||
-rw-r--r-- | server/models/oauth/oauth-token.ts (renamed from server/models/oauth-token.ts) | 4 | ||||
-rw-r--r-- | server/models/pod/index.ts | 1 | ||||
-rw-r--r-- | server/models/pod/pod-interface.ts (renamed from server/models/pod-interface.ts) | 2 | ||||
-rw-r--r-- | server/models/pod/pod.ts (renamed from server/models/pod.ts) | 6 | ||||
-rw-r--r-- | server/models/request/index.ts | 4 | ||||
-rw-r--r-- | server/models/request/request-interface.ts (renamed from server/models/request-interface.ts) | 2 | ||||
-rw-r--r-- | server/models/request/request-to-pod-interface.ts (renamed from server/models/request-to-pod-interface.ts) | 0 | ||||
-rw-r--r-- | server/models/request/request-to-pod.ts (renamed from server/models/request-to-pod.ts) | 2 | ||||
-rw-r--r-- | server/models/request/request-video-event-interface.ts (renamed from server/models/request-video-event-interface.ts) | 4 | ||||
-rw-r--r-- | server/models/request/request-video-event.ts (renamed from server/models/request-video-event.ts) | 8 | ||||
-rw-r--r-- | server/models/request/request-video-qadu-interface.ts (renamed from server/models/request-video-qadu-interface.ts) | 4 | ||||
-rw-r--r-- | server/models/request/request-video-qadu.ts (renamed from server/models/request-video-qadu.ts) | 6 | ||||
-rw-r--r-- | server/models/request/request.ts (renamed from server/models/request.ts) | 6 | ||||
-rw-r--r-- | server/models/user/index.ts | 2 | ||||
-rw-r--r-- | server/models/user/user-interface.ts (renamed from server/models/user-interface.ts) | 2 | ||||
-rw-r--r-- | server/models/user/user-video-rate-interface.ts (renamed from server/models/user-video-rate-interface.ts) | 0 | ||||
-rw-r--r-- | server/models/user/user-video-rate.ts (renamed from server/models/user-video-rate.ts) | 4 | ||||
-rw-r--r-- | server/models/user/user.ts (renamed from server/models/user.ts) | 8 | ||||
-rw-r--r-- | server/models/video/author-interface.ts (renamed from server/models/author-interface.ts) | 2 | ||||
-rw-r--r-- | server/models/video/author.ts (renamed from server/models/author.ts) | 4 | ||||
-rw-r--r-- | server/models/video/index.ts | 6 | ||||
-rw-r--r-- | server/models/video/tag-interface.ts (renamed from server/models/tag-interface.ts) | 0 | ||||
-rw-r--r-- | server/models/video/tag.ts (renamed from server/models/tag.ts) | 2 | ||||
-rw-r--r-- | server/models/video/video-abuse-interface.ts (renamed from server/models/video-abuse-interface.ts) | 2 | ||||
-rw-r--r-- | server/models/video/video-abuse.ts (renamed from server/models/video-abuse.ts) | 6 | ||||
-rw-r--r-- | server/models/video/video-blacklist-interface.ts (renamed from server/models/video-blacklist-interface.ts) | 2 | ||||
-rw-r--r-- | server/models/video/video-blacklist.ts (renamed from server/models/video-blacklist.ts) | 2 | ||||
-rw-r--r-- | server/models/video/video-interface.ts (renamed from server/models/video-interface.ts) | 2 | ||||
-rw-r--r-- | server/models/video/video-tag-interface.ts (renamed from server/models/video-tag-interface.ts) | 0 | ||||
-rw-r--r-- | server/models/video/video-tag.ts (renamed from server/models/video-tag.ts) | 2 | ||||
-rw-r--r-- | server/models/video/video.ts (renamed from server/models/video.ts) | 10 |
43 files changed, 128 insertions, 83 deletions
diff --git a/server/initializers/database.ts b/server/initializers/database.ts index 0ab9e98db..1662c1968 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import * as fs from 'fs' | 1 | import * as fs from 'fs' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import * as Sequelize from 'sequelize' | 3 | import * as Sequelize from 'sequelize' |
4 | import { each } from 'async' | ||
4 | 5 | ||
5 | import { CONFIG } from './constants' | 6 | import { CONFIG } from './constants' |
6 | // Do not use barrel, we need to load database first | 7 | // Do not use barrel, we need to load database first |
@@ -72,24 +73,13 @@ const sequelize = new Sequelize(dbname, username, password, { | |||
72 | database.sequelize = sequelize | 73 | database.sequelize = sequelize |
73 | 74 | ||
74 | database.init = function (silent: boolean, callback: (err: Error) => void) { | 75 | database.init = function (silent: boolean, callback: (err: Error) => void) { |
75 | |||
76 | const modelDirectory = join(__dirname, '..', 'models') | 76 | const modelDirectory = join(__dirname, '..', 'models') |
77 | fs.readdir(modelDirectory, function (err, files) { | ||
78 | if (err) throw err | ||
79 | 77 | ||
80 | files.filter(function (file) { | 78 | getModelFiles(modelDirectory, function (err, filePaths) { |
81 | // For all models but not utils.js | 79 | if (err) throw err |
82 | if ( | ||
83 | file === 'index.js' || file === 'index.ts' || | ||
84 | file === 'utils.js' || file === 'utils.ts' || | ||
85 | file.endsWith('-interface.js') || file.endsWith('-interface.ts') || | ||
86 | file.endsWith('.js.map') | ||
87 | ) return false | ||
88 | 80 | ||
89 | return true | 81 | filePaths.forEach(function (filePath) { |
90 | }) | 82 | const model = sequelize.import(filePath) |
91 | .forEach(function (file) { | ||
92 | const model = sequelize.import(join(modelDirectory, file)) | ||
93 | 83 | ||
94 | database[model['name']] = model | 84 | database[model['name']] = model |
95 | }) | 85 | }) |
@@ -111,3 +101,51 @@ database.init = function (silent: boolean, callback: (err: Error) => void) { | |||
111 | export { | 101 | export { |
112 | database | 102 | database |
113 | } | 103 | } |
104 | |||
105 | // --------------------------------------------------------------------------- | ||
106 | |||
107 | function getModelFiles (modelDirectory: string, callback: (err: Error, filePaths: string[]) => void) { | ||
108 | fs.readdir(modelDirectory, function (err, files) { | ||
109 | if (err) throw err | ||
110 | |||
111 | const directories = files.filter(function (directory) { | ||
112 | // For all models but not utils.js | ||
113 | if ( | ||
114 | directory === 'index.js' || directory === 'index.ts' || | ||
115 | directory === 'utils.js' || directory === 'utils.ts' | ||
116 | ) return false | ||
117 | |||
118 | return true | ||
119 | }) | ||
120 | |||
121 | let modelFilePaths: string[] = [] | ||
122 | |||
123 | // For each directory we read it and append model in the modelFilePaths array | ||
124 | each(directories, function (directory: string, eachCallback: ErrorCallback<Error>) { | ||
125 | const modelDirectoryPath = join(modelDirectory, directory) | ||
126 | |||
127 | fs.readdir(modelDirectoryPath, function (err, files) { | ||
128 | if (err) return eachCallback(err) | ||
129 | |||
130 | const filteredFiles = files.filter(file => { | ||
131 | if ( | ||
132 | file === 'index.js' || file === 'index.ts' || | ||
133 | file === 'utils.js' || file === 'utils.ts' || | ||
134 | file.endsWith('-interface.js') || file.endsWith('-interface.ts') || | ||
135 | file.endsWith('.js.map') | ||
136 | ) return false | ||
137 | |||
138 | return true | ||
139 | }).map(file => { | ||
140 | return join(modelDirectoryPath, file) | ||
141 | }) | ||
142 | |||
143 | modelFilePaths = modelFilePaths.concat(filteredFiles) | ||
144 | |||
145 | return eachCallback(null) | ||
146 | }) | ||
147 | }, function(err: Error) { | ||
148 | return callback(err, modelFilePaths) | ||
149 | }) | ||
150 | }) | ||
151 | } | ||
diff --git a/server/models/application-interface.ts b/server/models/application/application-interface.ts index c03513db1..c03513db1 100644 --- a/server/models/application-interface.ts +++ b/server/models/application/application-interface.ts | |||
diff --git a/server/models/application.ts b/server/models/application/application.ts index 55bb40d84..0e9a1ebb3 100644 --- a/server/models/application.ts +++ b/server/models/application/application.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { addMethodsToModel } from './utils' | 3 | import { addMethodsToModel } from '../utils' |
4 | import { | 4 | import { |
5 | ApplicationClass, | 5 | ApplicationClass, |
6 | ApplicationAttributes, | 6 | ApplicationAttributes, |
diff --git a/server/models/application/index.ts b/server/models/application/index.ts new file mode 100644 index 000000000..706f85cb9 --- /dev/null +++ b/server/models/application/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './application-interface' | |||
diff --git a/server/models/index.ts b/server/models/index.ts index 432c0dc4a..b392a8a77 100644 --- a/server/models/index.ts +++ b/server/models/index.ts | |||
@@ -1,17 +1,7 @@ | |||
1 | export * from './application-interface' | 1 | export * from './application' |
2 | export * from './author-interface' | 2 | export * from './job' |
3 | export * from './job-interface' | 3 | export * from './oauth' |
4 | export * from './oauth-client-interface' | 4 | export * from './pod' |
5 | export * from './oauth-token-interface' | 5 | export * from './request' |
6 | export * from './pod-interface' | 6 | export * from './user' |
7 | export * from './request-interface' | 7 | export * from './video' |
8 | export * from './request-to-pod-interface' | ||
9 | export * from './request-video-event-interface' | ||
10 | export * from './request-video-qadu-interface' | ||
11 | export * from './tag-interface' | ||
12 | export * from './user-video-rate-interface' | ||
13 | export * from './user-interface' | ||
14 | export * from './video-abuse-interface' | ||
15 | export * from './video-blacklist-interface' | ||
16 | export * from './video-tag-interface' | ||
17 | export * from './video-interface' | ||
diff --git a/server/models/job/index.ts b/server/models/job/index.ts new file mode 100644 index 000000000..56925fd32 --- /dev/null +++ b/server/models/job/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './job-interface' | |||
diff --git a/server/models/job-interface.ts b/server/models/job/job-interface.ts index ab6678257..ab6678257 100644 --- a/server/models/job-interface.ts +++ b/server/models/job/job-interface.ts | |||
diff --git a/server/models/job.ts b/server/models/job/job.ts index d4380a575..60a6c551b 100644 --- a/server/models/job.ts +++ b/server/models/job/job.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { values } from 'lodash' | 1 | import { values } from 'lodash' |
2 | import * as Sequelize from 'sequelize' | 2 | import * as Sequelize from 'sequelize' |
3 | 3 | ||
4 | import { JOB_STATES } from '../initializers' | 4 | import { JOB_STATES } from '../../initializers' |
5 | 5 | ||
6 | import { addMethodsToModel } from './utils' | 6 | import { addMethodsToModel } from '../utils' |
7 | import { | 7 | import { |
8 | JobClass, | 8 | JobClass, |
9 | JobInstance, | 9 | JobInstance, |
diff --git a/server/models/oauth/index.ts b/server/models/oauth/index.ts new file mode 100644 index 000000000..a20d3a56a --- /dev/null +++ b/server/models/oauth/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './oauth-client-interface' | ||
2 | export * from './oauth-token-interface' | ||
diff --git a/server/models/oauth-client-interface.ts b/server/models/oauth/oauth-client-interface.ts index 3b4325740..3b4325740 100644 --- a/server/models/oauth-client-interface.ts +++ b/server/models/oauth/oauth-client-interface.ts | |||
diff --git a/server/models/oauth-client.ts b/server/models/oauth/oauth-client.ts index a5438f45a..fbc2a3393 100644 --- a/server/models/oauth-client.ts +++ b/server/models/oauth/oauth-client.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { addMethodsToModel } from './utils' | 3 | import { addMethodsToModel } from '../utils' |
4 | import { | 4 | import { |
5 | OAuthClientClass, | 5 | OAuthClientClass, |
6 | OAuthClientInstance, | 6 | OAuthClientInstance, |
diff --git a/server/models/oauth-token-interface.ts b/server/models/oauth/oauth-token-interface.ts index 88526697e..815ad5eef 100644 --- a/server/models/oauth-token-interface.ts +++ b/server/models/oauth/oauth-token-interface.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import * as Bluebird from 'bluebird' | 2 | import * as Bluebird from 'bluebird' |
3 | 3 | ||
4 | import { UserModel } from './user-interface' | 4 | import { UserModel } from '../user' |
5 | 5 | ||
6 | export type OAuthTokenInfo = { | 6 | export type OAuthTokenInfo = { |
7 | refreshToken: string | 7 | refreshToken: string |
diff --git a/server/models/oauth-token.ts b/server/models/oauth/oauth-token.ts index 91cef11dd..eab9cf858 100644 --- a/server/models/oauth-token.ts +++ b/server/models/oauth/oauth-token.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { logger } from '../helpers' | 3 | import { logger } from '../../helpers' |
4 | 4 | ||
5 | import { addMethodsToModel } from './utils' | 5 | import { addMethodsToModel } from '../utils' |
6 | import { | 6 | import { |
7 | OAuthTokenClass, | 7 | OAuthTokenClass, |
8 | OAuthTokenInstance, | 8 | OAuthTokenInstance, |
diff --git a/server/models/pod/index.ts b/server/models/pod/index.ts new file mode 100644 index 000000000..d2bf50d4d --- /dev/null +++ b/server/models/pod/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './pod-interface' | |||
diff --git a/server/models/pod-interface.ts b/server/models/pod/pod-interface.ts index 8f362bd5c..01ccda64c 100644 --- a/server/models/pod-interface.ts +++ b/server/models/pod/pod-interface.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | // Don't use barrel, import just what we need | 3 | // Don't use barrel, import just what we need |
4 | import { Pod as FormatedPod } from '../../shared/models/pod.model' | 4 | import { Pod as FormatedPod } from '../../../shared/models/pod.model' |
5 | 5 | ||
6 | export namespace PodMethods { | 6 | export namespace PodMethods { |
7 | export type ToFormatedJSON = () => FormatedPod | 7 | export type ToFormatedJSON = () => FormatedPod |
diff --git a/server/models/pod.ts b/server/models/pod/pod.ts index fef9d4da6..4c6e63024 100644 --- a/server/models/pod.ts +++ b/server/models/pod/pod.ts | |||
@@ -2,10 +2,10 @@ import { each, waterfall } from 'async' | |||
2 | import { map } from 'lodash' | 2 | import { map } from 'lodash' |
3 | import * as Sequelize from 'sequelize' | 3 | import * as Sequelize from 'sequelize' |
4 | 4 | ||
5 | import { FRIEND_SCORE, PODS_SCORE } from '../initializers' | 5 | import { FRIEND_SCORE, PODS_SCORE } from '../../initializers' |
6 | import { logger, isHostValid } from '../helpers' | 6 | import { logger, isHostValid } from '../../helpers' |
7 | 7 | ||
8 | import { addMethodsToModel } from './utils' | 8 | import { addMethodsToModel } from '../utils' |
9 | import { | 9 | import { |
10 | PodClass, | 10 | PodClass, |
11 | PodInstance, | 11 | PodInstance, |
diff --git a/server/models/request/index.ts b/server/models/request/index.ts new file mode 100644 index 000000000..824c140f5 --- /dev/null +++ b/server/models/request/index.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export * from './request-interface' | ||
2 | export * from './request-to-pod-interface' | ||
3 | export * from './request-video-event-interface' | ||
4 | export * from './request-video-qadu-interface' | ||
diff --git a/server/models/request-interface.ts b/server/models/request/request-interface.ts index 4bbd79966..70fd734e1 100644 --- a/server/models/request-interface.ts +++ b/server/models/request/request-interface.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { PodInstance, PodAttributes } from './pod-interface' | 3 | import { PodInstance, PodAttributes } from '../pod' |
4 | 4 | ||
5 | export type RequestsGrouped = { | 5 | export type RequestsGrouped = { |
6 | [ podId: number ]: { | 6 | [ podId: number ]: { |
diff --git a/server/models/request-to-pod-interface.ts b/server/models/request/request-to-pod-interface.ts index 6d75ca6e5..6d75ca6e5 100644 --- a/server/models/request-to-pod-interface.ts +++ b/server/models/request/request-to-pod-interface.ts | |||
diff --git a/server/models/request-to-pod.ts b/server/models/request/request-to-pod.ts index d2f31463c..67331be1d 100644 --- a/server/models/request-to-pod.ts +++ b/server/models/request/request-to-pod.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { addMethodsToModel } from './utils' | 3 | import { addMethodsToModel } from '../utils' |
4 | import { | 4 | import { |
5 | RequestToPodClass, | 5 | RequestToPodClass, |
6 | RequestToPodInstance, | 6 | RequestToPodInstance, |
diff --git a/server/models/request-video-event-interface.ts b/server/models/request/request-video-event-interface.ts index ad576a2b1..219d8edc0 100644 --- a/server/models/request-video-event-interface.ts +++ b/server/models/request/request-video-event-interface.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { VideoInstance } from './video-interface' | 3 | import { VideoInstance } from '../video' |
4 | import { PodInstance } from './pod-interface' | 4 | import { PodInstance } from '../pod' |
5 | 5 | ||
6 | export type RequestsVideoEventGrouped = { | 6 | export type RequestsVideoEventGrouped = { |
7 | [ podId: number ]: { | 7 | [ podId: number ]: { |
diff --git a/server/models/request-video-event.ts b/server/models/request/request-video-event.ts index 32438b581..f552ef50b 100644 --- a/server/models/request-video-event.ts +++ b/server/models/request/request-video-event.ts | |||
@@ -5,10 +5,10 @@ | |||
5 | import { values } from 'lodash' | 5 | import { values } from 'lodash' |
6 | import * as Sequelize from 'sequelize' | 6 | import * as Sequelize from 'sequelize' |
7 | 7 | ||
8 | import { database as db } from '../initializers/database' | 8 | import { database as db } from '../../initializers/database' |
9 | import { REQUEST_VIDEO_EVENT_TYPES } from '../initializers' | 9 | import { REQUEST_VIDEO_EVENT_TYPES } from '../../initializers' |
10 | import { isVideoEventCountValid } from '../helpers' | 10 | import { isVideoEventCountValid } from '../../helpers' |
11 | import { addMethodsToModel } from './utils' | 11 | import { addMethodsToModel } from '../utils' |
12 | import { | 12 | import { |
13 | RequestVideoEventClass, | 13 | RequestVideoEventClass, |
14 | RequestVideoEventInstance, | 14 | RequestVideoEventInstance, |
diff --git a/server/models/request-video-qadu-interface.ts b/server/models/request/request-video-qadu-interface.ts index 04de7f159..625b063dc 100644 --- a/server/models/request-video-qadu-interface.ts +++ b/server/models/request/request-video-qadu-interface.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { VideoInstance } from './video-interface' | 3 | import { VideoInstance } from '../video' |
4 | import { PodInstance } from './pod-interface' | 4 | import { PodInstance } from '../pod' |
5 | 5 | ||
6 | export type RequestsVideoQaduGrouped = { | 6 | export type RequestsVideoQaduGrouped = { |
7 | [ podId: number ]: { | 7 | [ podId: number ]: { |
diff --git a/server/models/request-video-qadu.ts b/server/models/request/request-video-qadu.ts index 27ce0ff29..da62239f5 100644 --- a/server/models/request-video-qadu.ts +++ b/server/models/request/request-video-qadu.ts | |||
@@ -12,9 +12,9 @@ | |||
12 | import { values } from 'lodash' | 12 | import { values } from 'lodash' |
13 | import * as Sequelize from 'sequelize' | 13 | import * as Sequelize from 'sequelize' |
14 | 14 | ||
15 | import { database as db } from '../initializers/database' | 15 | import { database as db } from '../../initializers/database' |
16 | import { REQUEST_VIDEO_QADU_TYPES } from '../initializers' | 16 | import { REQUEST_VIDEO_QADU_TYPES } from '../../initializers' |
17 | import { addMethodsToModel } from './utils' | 17 | import { addMethodsToModel } from '../utils' |
18 | import { | 18 | import { |
19 | RequestVideoQaduClass, | 19 | RequestVideoQaduClass, |
20 | RequestVideoQaduInstance, | 20 | RequestVideoQaduInstance, |
diff --git a/server/models/request.ts b/server/models/request/request.ts index e6c367f28..66e7da845 100644 --- a/server/models/request.ts +++ b/server/models/request/request.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { values } from 'lodash' | 1 | import { values } from 'lodash' |
2 | import * as Sequelize from 'sequelize' | 2 | import * as Sequelize from 'sequelize' |
3 | 3 | ||
4 | import { database as db } from '../initializers/database' | 4 | import { database as db } from '../../initializers/database' |
5 | import { REQUEST_ENDPOINTS } from '../initializers' | 5 | import { REQUEST_ENDPOINTS } from '../../initializers' |
6 | import { addMethodsToModel } from './utils' | 6 | import { addMethodsToModel } from '../utils' |
7 | import { | 7 | import { |
8 | RequestClass, | 8 | RequestClass, |
9 | RequestInstance, | 9 | RequestInstance, |
diff --git a/server/models/user/index.ts b/server/models/user/index.ts new file mode 100644 index 000000000..ed3689518 --- /dev/null +++ b/server/models/user/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './user-video-rate-interface' | ||
2 | export * from './user-interface' | ||
diff --git a/server/models/user-interface.ts b/server/models/user/user-interface.ts index 98963b743..1ba4bd800 100644 --- a/server/models/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 { 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 |
diff --git a/server/models/user-video-rate-interface.ts b/server/models/user/user-video-rate-interface.ts index e48869fd2..e48869fd2 100644 --- a/server/models/user-video-rate-interface.ts +++ b/server/models/user/user-video-rate-interface.ts | |||
diff --git a/server/models/user-video-rate.ts b/server/models/user/user-video-rate.ts index 0326e1796..68be62fc2 100644 --- a/server/models/user-video-rate.ts +++ b/server/models/user/user-video-rate.ts | |||
@@ -5,9 +5,9 @@ | |||
5 | import { values } from 'lodash' | 5 | import { values } from 'lodash' |
6 | import * as Sequelize from 'sequelize' | 6 | import * as Sequelize from 'sequelize' |
7 | 7 | ||
8 | import { VIDEO_RATE_TYPES } from '../initializers' | 8 | import { VIDEO_RATE_TYPES } from '../../initializers' |
9 | 9 | ||
10 | import { addMethodsToModel } from './utils' | 10 | import { addMethodsToModel } from '../utils' |
11 | import { | 11 | import { |
12 | UserVideoRateClass, | 12 | UserVideoRateClass, |
13 | UserVideoRateInstance, | 13 | UserVideoRateInstance, |
diff --git a/server/models/user.ts b/server/models/user/user.ts index 1a56a6dc3..d78f5f845 100644 --- a/server/models/user.ts +++ b/server/models/user/user.ts | |||
@@ -1,17 +1,17 @@ | |||
1 | import { values } from 'lodash' | 1 | import { values } from 'lodash' |
2 | import * as Sequelize from 'sequelize' | 2 | import * as Sequelize from 'sequelize' |
3 | 3 | ||
4 | import { getSort } from './utils' | 4 | import { getSort } from '../utils' |
5 | import { USER_ROLES } from '../initializers' | 5 | import { USER_ROLES } from '../../initializers' |
6 | import { | 6 | import { |
7 | cryptPassword, | 7 | cryptPassword, |
8 | comparePassword, | 8 | comparePassword, |
9 | isUserPasswordValid, | 9 | isUserPasswordValid, |
10 | isUserUsernameValid, | 10 | isUserUsernameValid, |
11 | isUserDisplayNSFWValid | 11 | isUserDisplayNSFWValid |
12 | } from '../helpers' | 12 | } from '../../helpers' |
13 | 13 | ||
14 | import { addMethodsToModel } from './utils' | 14 | import { addMethodsToModel } from '../utils' |
15 | import { | 15 | import { |
16 | UserClass, | 16 | UserClass, |
17 | UserInstance, | 17 | UserInstance, |
diff --git a/server/models/author-interface.ts b/server/models/video/author-interface.ts index b57ce2a6b..c1b30848c 100644 --- a/server/models/author-interface.ts +++ b/server/models/video/author-interface.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { PodInstance } from './pod-interface' | 3 | import { PodInstance } from '../pod' |
4 | 4 | ||
5 | export namespace AuthorMethods { | 5 | export namespace AuthorMethods { |
6 | export type FindOrCreateAuthorCallback = (err: Error, authorInstance?: AuthorInstance) => void | 6 | export type FindOrCreateAuthorCallback = (err: Error, authorInstance?: AuthorInstance) => void |
diff --git a/server/models/author.ts b/server/models/video/author.ts index e0fb250f9..4a115e328 100644 --- a/server/models/author.ts +++ b/server/models/video/author.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { isUserUsernameValid } from '../helpers' | 3 | import { isUserUsernameValid } from '../../helpers' |
4 | 4 | ||
5 | import { addMethodsToModel } from './utils' | 5 | import { addMethodsToModel } from '../utils' |
6 | import { | 6 | import { |
7 | AuthorClass, | 7 | AuthorClass, |
8 | AuthorInstance, | 8 | AuthorInstance, |
diff --git a/server/models/video/index.ts b/server/models/video/index.ts new file mode 100644 index 000000000..84b801c72 --- /dev/null +++ b/server/models/video/index.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export * from './author-interface' | ||
2 | export * from './tag-interface' | ||
3 | export * from './video-abuse-interface' | ||
4 | export * from './video-blacklist-interface' | ||
5 | export * from './video-tag-interface' | ||
6 | export * from './video-interface' | ||
diff --git a/server/models/tag-interface.ts b/server/models/video/tag-interface.ts index e045e7ca5..e045e7ca5 100644 --- a/server/models/tag-interface.ts +++ b/server/models/video/tag-interface.ts | |||
diff --git a/server/models/tag.ts b/server/models/video/tag.ts index 54a5f79e5..3c657d751 100644 --- a/server/models/tag.ts +++ b/server/models/video/tag.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { each } from 'async' | 1 | import { each } from 'async' |
2 | import * as Sequelize from 'sequelize' | 2 | import * as Sequelize from 'sequelize' |
3 | 3 | ||
4 | import { addMethodsToModel } from './utils' | 4 | import { addMethodsToModel } from '../utils' |
5 | import { | 5 | import { |
6 | TagClass, | 6 | TagClass, |
7 | TagInstance, | 7 | TagInstance, |
diff --git a/server/models/video-abuse-interface.ts b/server/models/video/video-abuse-interface.ts index d9cb93b42..4b7f2a2ec 100644 --- a/server/models/video-abuse-interface.ts +++ b/server/models/video/video-abuse-interface.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | // Don't use barrel, import just what we need | 3 | // Don't use barrel, import just what we need |
4 | import { VideoAbuse as FormatedVideoAbuse } from '../../shared/models/video-abuse.model' | 4 | import { VideoAbuse as FormatedVideoAbuse } from '../../../shared/models/video-abuse.model' |
5 | 5 | ||
6 | export namespace VideoAbuseMethods { | 6 | export namespace VideoAbuseMethods { |
7 | export type toFormatedJSON = () => FormatedVideoAbuse | 7 | export type toFormatedJSON = () => FormatedVideoAbuse |
diff --git a/server/models/video-abuse.ts b/server/models/video/video-abuse.ts index 5602ef968..e0e0bcfe6 100644 --- a/server/models/video-abuse.ts +++ b/server/models/video/video-abuse.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { CONFIG } from '../initializers' | 3 | import { CONFIG } from '../../initializers' |
4 | import { isVideoAbuseReporterUsernameValid, isVideoAbuseReasonValid } from '../helpers' | 4 | import { isVideoAbuseReporterUsernameValid, isVideoAbuseReasonValid } from '../../helpers' |
5 | 5 | ||
6 | import { addMethodsToModel, getSort } from './utils' | 6 | import { addMethodsToModel, getSort } from '../utils' |
7 | import { | 7 | import { |
8 | VideoAbuseClass, | 8 | VideoAbuseClass, |
9 | VideoAbuseInstance, | 9 | VideoAbuseInstance, |
diff --git a/server/models/video-blacklist-interface.ts b/server/models/video/video-blacklist-interface.ts index 974718192..37f579422 100644 --- a/server/models/video-blacklist-interface.ts +++ b/server/models/video/video-blacklist-interface.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | // Don't use barrel, import just what we need | 3 | // Don't use barrel, import just what we need |
4 | import { BlacklistedVideo as FormatedBlacklistedVideo } from '../../shared/models/video-blacklist.model' | 4 | import { BlacklistedVideo as FormatedBlacklistedVideo } from '../../../shared/models/video-blacklist.model' |
5 | 5 | ||
6 | export namespace BlacklistedVideoMethods { | 6 | export namespace BlacklistedVideoMethods { |
7 | export type ToFormatedJSON = () => FormatedBlacklistedVideo | 7 | export type ToFormatedJSON = () => FormatedBlacklistedVideo |
diff --git a/server/models/video-blacklist.ts b/server/models/video/video-blacklist.ts index 040ed03d7..f4479986c 100644 --- a/server/models/video-blacklist.ts +++ b/server/models/video/video-blacklist.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { addMethodsToModel, getSort } from './utils' | 3 | import { addMethodsToModel, getSort } from '../utils' |
4 | import { | 4 | import { |
5 | BlacklistedVideoClass, | 5 | BlacklistedVideoClass, |
6 | BlacklistedVideoInstance, | 6 | BlacklistedVideoInstance, |
diff --git a/server/models/video-interface.ts b/server/models/video/video-interface.ts index 7120f91cd..71b9b0a69 100644 --- a/server/models/video-interface.ts +++ b/server/models/video/video-interface.ts | |||
@@ -4,7 +4,7 @@ import { AuthorInstance } from './author-interface' | |||
4 | import { VideoTagInstance } from './video-tag-interface' | 4 | import { VideoTagInstance } from './video-tag-interface' |
5 | 5 | ||
6 | // Don't use barrel, import just what we need | 6 | // Don't use barrel, import just what we need |
7 | import { Video as FormatedVideo } from '../../shared/models/video.model' | 7 | import { Video as FormatedVideo } from '../../../shared/models/video.model' |
8 | 8 | ||
9 | export type FormatedAddRemoteVideo = { | 9 | export type FormatedAddRemoteVideo = { |
10 | name: string | 10 | name: string |
diff --git a/server/models/video-tag-interface.ts b/server/models/video/video-tag-interface.ts index f928cecff..f928cecff 100644 --- a/server/models/video-tag-interface.ts +++ b/server/models/video/video-tag-interface.ts | |||
diff --git a/server/models/video-tag.ts b/server/models/video/video-tag.ts index 514eede25..71ca85332 100644 --- a/server/models/video-tag.ts +++ b/server/models/video/video-tag.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { addMethodsToModel } from './utils' | 3 | import { addMethodsToModel } from '../utils' |
4 | import { | 4 | import { |
5 | VideoTagClass, | 5 | VideoTagClass, |
6 | VideoTagInstance, | 6 | VideoTagInstance, |
diff --git a/server/models/video.ts b/server/models/video/video.ts index 78119f516..866b380cc 100644 --- a/server/models/video.ts +++ b/server/models/video/video.ts | |||
@@ -10,7 +10,7 @@ import * as parseTorrent from 'parse-torrent' | |||
10 | import { join } from 'path' | 10 | import { join } from 'path' |
11 | import * as Sequelize from 'sequelize' | 11 | import * as Sequelize from 'sequelize' |
12 | 12 | ||
13 | import { database as db } from '../initializers/database' | 13 | import { database as db } from '../../initializers/database' |
14 | import { VideoTagInstance } from './video-tag-interface' | 14 | import { VideoTagInstance } from './video-tag-interface' |
15 | import { | 15 | import { |
16 | logger, | 16 | logger, |
@@ -22,7 +22,7 @@ import { | |||
22 | isVideoDescriptionValid, | 22 | isVideoDescriptionValid, |
23 | isVideoInfoHashValid, | 23 | isVideoInfoHashValid, |
24 | isVideoDurationValid | 24 | isVideoDurationValid |
25 | } from '../helpers' | 25 | } from '../../helpers' |
26 | import { | 26 | import { |
27 | CONSTRAINTS_FIELDS, | 27 | CONSTRAINTS_FIELDS, |
28 | CONFIG, | 28 | CONFIG, |
@@ -32,10 +32,10 @@ import { | |||
32 | VIDEO_LICENCES, | 32 | VIDEO_LICENCES, |
33 | VIDEO_LANGUAGES, | 33 | VIDEO_LANGUAGES, |
34 | THUMBNAILS_SIZE | 34 | THUMBNAILS_SIZE |
35 | } from '../initializers' | 35 | } from '../../initializers' |
36 | import { JobScheduler, removeVideoToFriends } from '../lib' | 36 | import { JobScheduler, removeVideoToFriends } from '../../lib' |
37 | 37 | ||
38 | import { addMethodsToModel, getSort } from './utils' | 38 | import { addMethodsToModel, getSort } from '../utils' |
39 | import { | 39 | import { |
40 | VideoClass, | 40 | VideoClass, |
41 | VideoInstance, | 41 | VideoInstance, |