diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-12 20:04:58 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-12 20:37:51 +0200 |
commit | 2186386cca113506791583cb07d6ccacba7af4e0 (patch) | |
tree | 3c214c0b5fbd64332624267fa6e51fd4a9cf6474 /server/initializers | |
parent | 6ccdf3a23ecec5ba2eeaf487fd1fafdc7606b4bf (diff) | |
download | PeerTube-2186386cca113506791583cb07d6ccacba7af4e0.tar.gz PeerTube-2186386cca113506791583cb07d6ccacba7af4e0.tar.zst PeerTube-2186386cca113506791583cb07d6ccacba7af4e0.zip |
Add concept of video state, and add ability to wait transcoding before
publishing a video
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/constants.ts | 10 | ||||
-rw-r--r-- | server/initializers/migrations/0220-video-state.ts | 62 |
2 files changed, 70 insertions, 2 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 79e4bb7f0..8dbc1b060 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { IConfig } from 'config' | 1 | import { IConfig } from 'config' |
2 | import { dirname, join } from 'path' | 2 | import { dirname, join } from 'path' |
3 | import { JobType, VideoRateType } from '../../shared/models' | 3 | import { JobType, VideoRateType, VideoState } from '../../shared/models' |
4 | import { ActivityPubActorType } from '../../shared/models/activitypub' | 4 | import { ActivityPubActorType } from '../../shared/models/activitypub' |
5 | import { FollowState } from '../../shared/models/actors' | 5 | import { FollowState } from '../../shared/models/actors' |
6 | import { VideoPrivacy } from '../../shared/models/videos' | 6 | import { VideoPrivacy } from '../../shared/models/videos' |
@@ -14,7 +14,7 @@ let config: IConfig = require('config') | |||
14 | 14 | ||
15 | // --------------------------------------------------------------------------- | 15 | // --------------------------------------------------------------------------- |
16 | 16 | ||
17 | const LAST_MIGRATION_VERSION = 215 | 17 | const LAST_MIGRATION_VERSION = 220 |
18 | 18 | ||
19 | // --------------------------------------------------------------------------- | 19 | // --------------------------------------------------------------------------- |
20 | 20 | ||
@@ -326,6 +326,11 @@ const VIDEO_PRIVACIES = { | |||
326 | [VideoPrivacy.PRIVATE]: 'Private' | 326 | [VideoPrivacy.PRIVATE]: 'Private' |
327 | } | 327 | } |
328 | 328 | ||
329 | const VIDEO_STATES = { | ||
330 | [VideoState.PUBLISHED]: 'Published', | ||
331 | [VideoState.TO_TRANSCODE]: 'To transcode' | ||
332 | } | ||
333 | |||
329 | const VIDEO_MIMETYPE_EXT = { | 334 | const VIDEO_MIMETYPE_EXT = { |
330 | 'video/webm': '.webm', | 335 | 'video/webm': '.webm', |
331 | 'video/ogg': '.ogv', | 336 | 'video/ogg': '.ogv', |
@@ -493,6 +498,7 @@ export { | |||
493 | VIDEO_LANGUAGES, | 498 | VIDEO_LANGUAGES, |
494 | VIDEO_PRIVACIES, | 499 | VIDEO_PRIVACIES, |
495 | VIDEO_LICENCES, | 500 | VIDEO_LICENCES, |
501 | VIDEO_STATES, | ||
496 | VIDEO_RATE_TYPES, | 502 | VIDEO_RATE_TYPES, |
497 | VIDEO_MIMETYPE_EXT, | 503 | VIDEO_MIMETYPE_EXT, |
498 | VIDEO_TRANSCODING_FPS, | 504 | VIDEO_TRANSCODING_FPS, |
diff --git a/server/initializers/migrations/0220-video-state.ts b/server/initializers/migrations/0220-video-state.ts new file mode 100644 index 000000000..491702157 --- /dev/null +++ b/server/initializers/migrations/0220-video-state.ts | |||
@@ -0,0 +1,62 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | async function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | }): Promise<void> { | ||
8 | // waitingTranscoding column | ||
9 | { | ||
10 | const data = { | ||
11 | type: Sequelize.BOOLEAN, | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | await utils.queryInterface.addColumn('video', 'waitTranscoding', data) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const query = 'UPDATE video SET "waitTranscoding" = false' | ||
20 | await utils.sequelize.query(query) | ||
21 | } | ||
22 | |||
23 | { | ||
24 | const data = { | ||
25 | type: Sequelize.BOOLEAN, | ||
26 | allowNull: false, | ||
27 | defaultValue: null | ||
28 | } | ||
29 | await utils.queryInterface.changeColumn('video', 'waitTranscoding', data) | ||
30 | } | ||
31 | |||
32 | // state | ||
33 | { | ||
34 | const data = { | ||
35 | type: Sequelize.INTEGER, | ||
36 | allowNull: true, | ||
37 | defaultValue: null | ||
38 | } | ||
39 | await utils.queryInterface.addColumn('video', 'state', data) | ||
40 | } | ||
41 | |||
42 | { | ||
43 | // Published | ||
44 | const query = 'UPDATE video SET "state" = 1' | ||
45 | await utils.sequelize.query(query) | ||
46 | } | ||
47 | |||
48 | { | ||
49 | const data = { | ||
50 | type: Sequelize.INTEGER, | ||
51 | allowNull: false, | ||
52 | defaultValue: null | ||
53 | } | ||
54 | await utils.queryInterface.changeColumn('video', 'state', data) | ||
55 | } | ||
56 | } | ||
57 | |||
58 | function down (options) { | ||
59 | throw new Error('Not implemented.') | ||
60 | } | ||
61 | |||
62 | export { up, down } | ||