diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-24 19:41:09 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-26 09:11:38 +0200 |
commit | 72c7248b6fdcdb2175e726ff51b42e7555f2bd84 (patch) | |
tree | 1bfdee99dbe2392cc997edba8e314e2a8a401c72 /server/initializers | |
parent | 8113a93a0d9f31aa9e23702bbc31b8a76275ae22 (diff) | |
download | PeerTube-72c7248b6fdcdb2175e726ff51b42e7555f2bd84.tar.gz PeerTube-72c7248b6fdcdb2175e726ff51b42e7555f2bd84.tar.zst PeerTube-72c7248b6fdcdb2175e726ff51b42e7555f2bd84.zip |
Add video channels
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/constants.ts | 23 | ||||
-rw-r--r-- | server/initializers/database.ts | 2 | ||||
-rw-r--r-- | server/initializers/installer.ts | 19 |
3 files changed, 32 insertions, 12 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 132164746..54dce980f 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -10,6 +10,7 @@ import { | |||
10 | RequestEndpoint, | 10 | RequestEndpoint, |
11 | RequestVideoEventType, | 11 | RequestVideoEventType, |
12 | RequestVideoQaduType, | 12 | RequestVideoQaduType, |
13 | RemoteVideoRequestType, | ||
13 | JobState | 14 | JobState |
14 | } from '../../shared/models' | 15 | } from '../../shared/models' |
15 | 16 | ||
@@ -35,6 +36,7 @@ const SORTABLE_COLUMNS = { | |||
35 | PODS: [ 'id', 'host', 'score', 'createdAt' ], | 36 | PODS: [ 'id', 'host', 'score', 'createdAt' ], |
36 | USERS: [ 'id', 'username', 'createdAt' ], | 37 | USERS: [ 'id', 'username', 'createdAt' ], |
37 | VIDEO_ABUSES: [ 'id', 'createdAt' ], | 38 | VIDEO_ABUSES: [ 'id', 'createdAt' ], |
39 | VIDEO_CHANNELS: [ 'id', 'name', 'updatedAt', 'createdAt' ], | ||
38 | VIDEOS: [ 'name', 'duration', 'createdAt', 'views', 'likes' ], | 40 | VIDEOS: [ 'name', 'duration', 'createdAt', 'views', 'likes' ], |
39 | BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ] | 41 | BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ] |
40 | } | 42 | } |
@@ -115,6 +117,10 @@ const CONSTRAINTS_FIELDS = { | |||
115 | VIDEO_ABUSES: { | 117 | VIDEO_ABUSES: { |
116 | REASON: { min: 2, max: 300 } // Length | 118 | REASON: { min: 2, max: 300 } // Length |
117 | }, | 119 | }, |
120 | VIDEO_CHANNELS: { | ||
121 | NAME: { min: 3, max: 50 }, // Length | ||
122 | DESCRIPTION: { min: 3, max: 250 } // Length | ||
123 | }, | ||
118 | VIDEOS: { | 124 | VIDEOS: { |
119 | NAME: { min: 3, max: 50 }, // Length | 125 | NAME: { min: 3, max: 50 }, // Length |
120 | DESCRIPTION: { min: 3, max: 250 }, // Length | 126 | DESCRIPTION: { min: 3, max: 250 }, // Length |
@@ -232,11 +238,20 @@ const REQUEST_ENDPOINTS: { [ id: string ]: RequestEndpoint } = { | |||
232 | VIDEOS: 'videos' | 238 | VIDEOS: 'videos' |
233 | } | 239 | } |
234 | 240 | ||
235 | const REQUEST_ENDPOINT_ACTIONS: { [ id: string ]: any } = {} | 241 | const REQUEST_ENDPOINT_ACTIONS: { |
242 | [ id: string ]: { | ||
243 | [ id: string ]: RemoteVideoRequestType | ||
244 | } | ||
245 | } = {} | ||
236 | REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = { | 246 | REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = { |
237 | ADD: 'add', | 247 | ADD_VIDEO: 'add-video', |
238 | UPDATE: 'update', | 248 | UPDATE_VIDEO: 'update-video', |
239 | REMOVE: 'remove', | 249 | REMOVE_VIDEO: 'remove-video', |
250 | ADD_CHANNEL: 'add-channel', | ||
251 | UPDATE_CHANNEL: 'update-channel', | ||
252 | REMOVE_CHANNEL: 'remove-channel', | ||
253 | ADD_AUTHOR: 'add-author', | ||
254 | REMOVE_AUTHOR: 'remove-author', | ||
240 | REPORT_ABUSE: 'report-abuse' | 255 | REPORT_ABUSE: 'report-abuse' |
241 | } | 256 | } |
242 | 257 | ||
diff --git a/server/initializers/database.ts b/server/initializers/database.ts index c5a385361..d461cb440 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts | |||
@@ -14,6 +14,7 @@ import { VideoTagModel } from './../models/video/video-tag-interface' | |||
14 | import { BlacklistedVideoModel } from './../models/video/video-blacklist-interface' | 14 | import { BlacklistedVideoModel } from './../models/video/video-blacklist-interface' |
15 | import { VideoFileModel } from './../models/video/video-file-interface' | 15 | import { VideoFileModel } from './../models/video/video-file-interface' |
16 | import { VideoAbuseModel } from './../models/video/video-abuse-interface' | 16 | import { VideoAbuseModel } from './../models/video/video-abuse-interface' |
17 | import { VideoChannelModel } from './../models/video/video-channel-interface' | ||
17 | import { UserModel } from './../models/user/user-interface' | 18 | import { UserModel } from './../models/user/user-interface' |
18 | import { UserVideoRateModel } from './../models/user/user-video-rate-interface' | 19 | import { UserVideoRateModel } from './../models/user/user-video-rate-interface' |
19 | import { TagModel } from './../models/video/tag-interface' | 20 | import { TagModel } from './../models/video/tag-interface' |
@@ -50,6 +51,7 @@ const database: { | |||
50 | UserVideoRate?: UserVideoRateModel, | 51 | UserVideoRate?: UserVideoRateModel, |
51 | User?: UserModel, | 52 | User?: UserModel, |
52 | VideoAbuse?: VideoAbuseModel, | 53 | VideoAbuse?: VideoAbuseModel, |
54 | VideoChannel?: VideoChannelModel, | ||
53 | VideoFile?: VideoFileModel, | 55 | VideoFile?: VideoFileModel, |
54 | BlacklistedVideo?: BlacklistedVideoModel, | 56 | BlacklistedVideo?: BlacklistedVideoModel, |
55 | VideoTag?: VideoTagModel, | 57 | VideoTag?: VideoTagModel, |
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts index 10b74b85f..b997de07f 100644 --- a/server/initializers/installer.ts +++ b/server/initializers/installer.ts | |||
@@ -5,6 +5,7 @@ import { database as db } from './database' | |||
5 | import { USER_ROLES, CONFIG, LAST_MIGRATION_VERSION, CACHE } from './constants' | 5 | import { USER_ROLES, CONFIG, LAST_MIGRATION_VERSION, CACHE } from './constants' |
6 | import { clientsExist, usersExist } from './checker' | 6 | import { clientsExist, usersExist } from './checker' |
7 | import { logger, createCertsIfNotExist, mkdirpPromise, rimrafPromise } from '../helpers' | 7 | import { logger, createCertsIfNotExist, mkdirpPromise, rimrafPromise } from '../helpers' |
8 | import { createUserAuthorAndChannel } from '../lib' | ||
8 | 9 | ||
9 | function installApplication () { | 10 | function installApplication () { |
10 | return db.sequelize.sync() | 11 | return db.sequelize.sync() |
@@ -91,7 +92,7 @@ function createOAuthAdminIfNotExist () { | |||
91 | const username = 'root' | 92 | const username = 'root' |
92 | const role = USER_ROLES.ADMIN | 93 | const role = USER_ROLES.ADMIN |
93 | const email = CONFIG.ADMIN.EMAIL | 94 | const email = CONFIG.ADMIN.EMAIL |
94 | const createOptions: { validate?: boolean } = {} | 95 | let validatePassword = true |
95 | let password = '' | 96 | let password = '' |
96 | 97 | ||
97 | // Do not generate a random password for tests | 98 | // Do not generate a random password for tests |
@@ -103,7 +104,7 @@ function createOAuthAdminIfNotExist () { | |||
103 | } | 104 | } |
104 | 105 | ||
105 | // Our password is weak so do not validate it | 106 | // Our password is weak so do not validate it |
106 | createOptions.validate = false | 107 | validatePassword = false |
107 | } else { | 108 | } else { |
108 | password = passwordGenerator(8, true) | 109 | password = passwordGenerator(8, true) |
109 | } | 110 | } |
@@ -115,13 +116,15 @@ function createOAuthAdminIfNotExist () { | |||
115 | role, | 116 | role, |
116 | videoQuota: -1 | 117 | videoQuota: -1 |
117 | } | 118 | } |
119 | const user = db.User.build(userData) | ||
118 | 120 | ||
119 | return db.User.create(userData, createOptions).then(createdUser => { | 121 | return createUserAuthorAndChannel(user, validatePassword) |
120 | logger.info('Username: ' + username) | 122 | .then(({ user }) => { |
121 | logger.info('User password: ' + password) | 123 | logger.info('Username: ' + username) |
124 | logger.info('User password: ' + password) | ||
122 | 125 | ||
123 | logger.info('Creating Application table.') | 126 | logger.info('Creating Application table.') |
124 | return db.Application.create({ migrationVersion: LAST_MIGRATION_VERSION }) | 127 | return db.Application.create({ migrationVersion: LAST_MIGRATION_VERSION }) |
125 | }) | 128 | }) |
126 | }) | 129 | }) |
127 | } | 130 | } |