diff options
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/constants.ts | 14 | ||||
-rw-r--r-- | server/initializers/migrations/0250-video-abuse-state.ts | 47 |
2 files changed, 58 insertions, 3 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index ea561b686..a008bf4c5 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -3,7 +3,7 @@ import { dirname, join } from 'path' | |||
3 | import { JobType, VideoRateType, VideoState } 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, VideoAbuseState } from '../../shared/models/videos' |
7 | // Do not use barrels, remain constants as independent as possible | 7 | // Do not use barrels, remain constants as independent as possible |
8 | import { buildPath, isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' | 8 | import { buildPath, isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' |
9 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' | 9 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' |
@@ -15,7 +15,7 @@ let config: IConfig = require('config') | |||
15 | 15 | ||
16 | // --------------------------------------------------------------------------- | 16 | // --------------------------------------------------------------------------- |
17 | 17 | ||
18 | const LAST_MIGRATION_VERSION = 245 | 18 | const LAST_MIGRATION_VERSION = 250 |
19 | 19 | ||
20 | // --------------------------------------------------------------------------- | 20 | // --------------------------------------------------------------------------- |
21 | 21 | ||
@@ -258,7 +258,8 @@ const CONSTRAINTS_FIELDS = { | |||
258 | BLOCKED_REASON: { min: 3, max: 250 } // Length | 258 | BLOCKED_REASON: { min: 3, max: 250 } // Length |
259 | }, | 259 | }, |
260 | VIDEO_ABUSES: { | 260 | VIDEO_ABUSES: { |
261 | REASON: { min: 2, max: 300 } // Length | 261 | REASON: { min: 2, max: 300 }, // Length |
262 | MODERATION_COMMENT: { min: 2, max: 300 } // Length | ||
262 | }, | 263 | }, |
263 | VIDEO_CHANNELS: { | 264 | VIDEO_CHANNELS: { |
264 | NAME: { min: 3, max: 120 }, // Length | 265 | NAME: { min: 3, max: 120 }, // Length |
@@ -409,6 +410,12 @@ const VIDEO_IMPORT_STATES = { | |||
409 | [VideoImportState.SUCCESS]: 'Success' | 410 | [VideoImportState.SUCCESS]: 'Success' |
410 | } | 411 | } |
411 | 412 | ||
413 | const VIDEO_ABUSE_STATES = { | ||
414 | [VideoAbuseState.PENDING]: 'Pending', | ||
415 | [VideoAbuseState.REJECTED]: 'Rejected', | ||
416 | [VideoAbuseState.ACCEPTED]: 'Accepted' | ||
417 | } | ||
418 | |||
412 | const VIDEO_MIMETYPE_EXT = { | 419 | const VIDEO_MIMETYPE_EXT = { |
413 | 'video/webm': '.webm', | 420 | 'video/webm': '.webm', |
414 | 'video/ogg': '.ogv', | 421 | 'video/ogg': '.ogv', |
@@ -625,6 +632,7 @@ export { | |||
625 | VIDEO_MIMETYPE_EXT, | 632 | VIDEO_MIMETYPE_EXT, |
626 | VIDEO_TRANSCODING_FPS, | 633 | VIDEO_TRANSCODING_FPS, |
627 | FFMPEG_NICE, | 634 | FFMPEG_NICE, |
635 | VIDEO_ABUSE_STATES, | ||
628 | JOB_REQUEST_TIMEOUT, | 636 | JOB_REQUEST_TIMEOUT, |
629 | USER_PASSWORD_RESET_LIFETIME, | 637 | USER_PASSWORD_RESET_LIFETIME, |
630 | IMAGE_MIMETYPE_EXT, | 638 | IMAGE_MIMETYPE_EXT, |
diff --git a/server/initializers/migrations/0250-video-abuse-state.ts b/server/initializers/migrations/0250-video-abuse-state.ts new file mode 100644 index 000000000..acb668ae1 --- /dev/null +++ b/server/initializers/migrations/0250-video-abuse-state.ts | |||
@@ -0,0 +1,47 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { CONSTRAINTS_FIELDS } from '../constants' | ||
3 | import { VideoAbuseState } from '../../../shared/models/videos' | ||
4 | |||
5 | async function up (utils: { | ||
6 | transaction: Sequelize.Transaction | ||
7 | queryInterface: Sequelize.QueryInterface | ||
8 | sequelize: Sequelize.Sequelize | ||
9 | }): Promise<any> { | ||
10 | { | ||
11 | const data = { | ||
12 | type: Sequelize.INTEGER, | ||
13 | allowNull: true, | ||
14 | defaultValue: null | ||
15 | } | ||
16 | await utils.queryInterface.addColumn('videoAbuse', 'state', data) | ||
17 | } | ||
18 | |||
19 | { | ||
20 | const query = 'UPDATE "videoAbuse" SET "state" = ' + VideoAbuseState.PENDING | ||
21 | await utils.sequelize.query(query) | ||
22 | } | ||
23 | |||
24 | { | ||
25 | const data = { | ||
26 | type: Sequelize.INTEGER, | ||
27 | allowNull: false, | ||
28 | defaultValue: null | ||
29 | } | ||
30 | await utils.queryInterface.changeColumn('videoAbuse', 'state', data) | ||
31 | } | ||
32 | |||
33 | { | ||
34 | const data = { | ||
35 | type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEO_ABUSES.MODERATION_COMMENT.max), | ||
36 | allowNull: true, | ||
37 | defaultValue: null | ||
38 | } | ||
39 | await utils.queryInterface.addColumn('videoAbuse', 'moderationComment', data) | ||
40 | } | ||
41 | } | ||
42 | |||
43 | function down (options) { | ||
44 | throw new Error('Not implemented.') | ||
45 | } | ||
46 | |||
47 | export { up, down } | ||