aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-10 16:54:01 +0200
committerChocobozzz <me@florianbigard.com>2018-08-10 16:54:01 +0200
commit268eebed921ac13a9ce0f4717f4923aa24190657 (patch)
tree52f8436968c8dcc686663ef5db8dffd7ed191d34 /server/initializers
parent904a463c7792837f0a468a522a28448323e48593 (diff)
downloadPeerTube-268eebed921ac13a9ce0f4717f4923aa24190657.tar.gz
PeerTube-268eebed921ac13a9ce0f4717f4923aa24190657.tar.zst
PeerTube-268eebed921ac13a9ce0f4717f4923aa24190657.zip
Add state and moderationComment for abuses on server side
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts14
-rw-r--r--server/initializers/migrations/0250-video-abuse-state.ts47
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'
3import { JobType, VideoRateType, VideoState } from '../../shared/models' 3import { JobType, VideoRateType, VideoState } from '../../shared/models'
4import { ActivityPubActorType } from '../../shared/models/activitypub' 4import { ActivityPubActorType } from '../../shared/models/activitypub'
5import { FollowState } from '../../shared/models/actors' 5import { FollowState } from '../../shared/models/actors'
6import { VideoPrivacy } from '../../shared/models/videos' 6import { 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
8import { buildPath, isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' 8import { buildPath, isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
9import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' 9import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
@@ -15,7 +15,7 @@ let config: IConfig = require('config')
15 15
16// --------------------------------------------------------------------------- 16// ---------------------------------------------------------------------------
17 17
18const LAST_MIGRATION_VERSION = 245 18const 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
413const VIDEO_ABUSE_STATES = {
414 [VideoAbuseState.PENDING]: 'Pending',
415 [VideoAbuseState.REJECTED]: 'Rejected',
416 [VideoAbuseState.ACCEPTED]: 'Accepted'
417}
418
412const VIDEO_MIMETYPE_EXT = { 419const 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 @@
1import * as Sequelize from 'sequelize'
2import { CONSTRAINTS_FIELDS } from '../constants'
3import { VideoAbuseState } from '../../../shared/models/videos'
4
5async 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
43function down (options) {
44 throw new Error('Not implemented.')
45}
46
47export { up, down }