diff options
Diffstat (limited to 'shared')
33 files changed, 430 insertions, 138 deletions
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts index 2ac0c6338..af4d23856 100644 --- a/shared/extra-utils/index.ts +++ b/shared/extra-utils/index.ts | |||
@@ -17,6 +17,7 @@ export * from './videos/services' | |||
17 | export * from './videos/video-playlists' | 17 | export * from './videos/video-playlists' |
18 | export * from './users/users' | 18 | export * from './users/users' |
19 | export * from './users/accounts' | 19 | export * from './users/accounts' |
20 | export * from './moderation/abuses' | ||
20 | export * from './videos/video-abuses' | 21 | export * from './videos/video-abuses' |
21 | export * from './videos/video-blacklist' | 22 | export * from './videos/video-blacklist' |
22 | export * from './videos/video-captions' | 23 | export * from './videos/video-captions' |
diff --git a/shared/extra-utils/moderation/abuses.ts b/shared/extra-utils/moderation/abuses.ts new file mode 100644 index 000000000..62af9556e --- /dev/null +++ b/shared/extra-utils/moderation/abuses.ts | |||
@@ -0,0 +1,156 @@ | |||
1 | |||
2 | import { AbuseFilter, AbusePredefinedReasonsString, AbuseState, AbuseUpdate, AbuseVideoIs } from '@shared/models' | ||
3 | import { makeDeleteRequest, makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' | ||
4 | |||
5 | function reportAbuse (options: { | ||
6 | url: string | ||
7 | token: string | ||
8 | |||
9 | reason: string | ||
10 | |||
11 | accountId?: number | ||
12 | videoId?: number | ||
13 | commentId?: number | ||
14 | |||
15 | predefinedReasons?: AbusePredefinedReasonsString[] | ||
16 | |||
17 | startAt?: number | ||
18 | endAt?: number | ||
19 | |||
20 | statusCodeExpected?: number | ||
21 | }) { | ||
22 | const path = '/api/v1/abuses' | ||
23 | |||
24 | const video = options.videoId ? { | ||
25 | id: options.videoId, | ||
26 | startAt: options.startAt, | ||
27 | endAt: options.endAt | ||
28 | } : undefined | ||
29 | |||
30 | const comment = options.commentId ? { | ||
31 | id: options.commentId | ||
32 | } : undefined | ||
33 | |||
34 | const account = options.accountId ? { | ||
35 | id: options.accountId | ||
36 | } : undefined | ||
37 | |||
38 | const body = { | ||
39 | account, | ||
40 | video, | ||
41 | comment, | ||
42 | |||
43 | reason: options.reason, | ||
44 | predefinedReasons: options.predefinedReasons | ||
45 | } | ||
46 | |||
47 | return makePostBodyRequest({ | ||
48 | url: options.url, | ||
49 | path, | ||
50 | token: options.token, | ||
51 | |||
52 | fields: body, | ||
53 | statusCodeExpected: options.statusCodeExpected || 200 | ||
54 | }) | ||
55 | } | ||
56 | |||
57 | function getAbusesList (options: { | ||
58 | url: string | ||
59 | token: string | ||
60 | |||
61 | start?: number | ||
62 | count?: number | ||
63 | sort?: string | ||
64 | |||
65 | id?: number | ||
66 | predefinedReason?: AbusePredefinedReasonsString | ||
67 | search?: string | ||
68 | filter?: AbuseFilter | ||
69 | state?: AbuseState | ||
70 | videoIs?: AbuseVideoIs | ||
71 | searchReporter?: string | ||
72 | searchReportee?: string | ||
73 | searchVideo?: string | ||
74 | searchVideoChannel?: string | ||
75 | }) { | ||
76 | const { | ||
77 | url, | ||
78 | token, | ||
79 | start, | ||
80 | count, | ||
81 | sort, | ||
82 | id, | ||
83 | predefinedReason, | ||
84 | search, | ||
85 | filter, | ||
86 | state, | ||
87 | videoIs, | ||
88 | searchReporter, | ||
89 | searchReportee, | ||
90 | searchVideo, | ||
91 | searchVideoChannel | ||
92 | } = options | ||
93 | const path = '/api/v1/abuses' | ||
94 | |||
95 | const query = { | ||
96 | id, | ||
97 | predefinedReason, | ||
98 | search, | ||
99 | state, | ||
100 | filter, | ||
101 | videoIs, | ||
102 | start, | ||
103 | count, | ||
104 | sort: sort || 'createdAt', | ||
105 | searchReporter, | ||
106 | searchReportee, | ||
107 | searchVideo, | ||
108 | searchVideoChannel | ||
109 | } | ||
110 | |||
111 | return makeGetRequest({ | ||
112 | url, | ||
113 | path, | ||
114 | token, | ||
115 | query, | ||
116 | statusCodeExpected: 200 | ||
117 | }) | ||
118 | } | ||
119 | |||
120 | function updateAbuse ( | ||
121 | url: string, | ||
122 | token: string, | ||
123 | abuseId: number, | ||
124 | body: AbuseUpdate, | ||
125 | statusCodeExpected = 204 | ||
126 | ) { | ||
127 | const path = '/api/v1/abuses/' + abuseId | ||
128 | |||
129 | return makePutBodyRequest({ | ||
130 | url, | ||
131 | token, | ||
132 | path, | ||
133 | fields: body, | ||
134 | statusCodeExpected | ||
135 | }) | ||
136 | } | ||
137 | |||
138 | function deleteAbuse (url: string, token: string, abuseId: number, statusCodeExpected = 204) { | ||
139 | const path = '/api/v1/abuses/' + abuseId | ||
140 | |||
141 | return makeDeleteRequest({ | ||
142 | url, | ||
143 | token, | ||
144 | path, | ||
145 | statusCodeExpected | ||
146 | }) | ||
147 | } | ||
148 | |||
149 | // --------------------------------------------------------------------------- | ||
150 | |||
151 | export { | ||
152 | reportAbuse, | ||
153 | getAbusesList, | ||
154 | updateAbuse, | ||
155 | deleteAbuse | ||
156 | } | ||
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index 0f883d839..994aac628 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts | |||
@@ -37,8 +37,8 @@ interface ServerInfo { | |||
37 | video?: { | 37 | video?: { |
38 | id: number | 38 | id: number |
39 | uuid: string | 39 | uuid: string |
40 | name: string | 40 | name?: string |
41 | account: { | 41 | account?: { |
42 | name: string | 42 | name: string |
43 | } | 43 | } |
44 | } | 44 | } |
diff --git a/shared/extra-utils/users/user-notifications.ts b/shared/extra-utils/users/user-notifications.ts index a17a39de9..2061e3353 100644 --- a/shared/extra-utils/users/user-notifications.ts +++ b/shared/extra-utils/users/user-notifications.ts | |||
@@ -139,13 +139,17 @@ async function checkNotification ( | |||
139 | } | 139 | } |
140 | 140 | ||
141 | function checkVideo (video: any, videoName?: string, videoUUID?: string) { | 141 | function checkVideo (video: any, videoName?: string, videoUUID?: string) { |
142 | expect(video.name).to.be.a('string') | 142 | if (videoName) { |
143 | expect(video.name).to.not.be.empty | 143 | expect(video.name).to.be.a('string') |
144 | if (videoName) expect(video.name).to.equal(videoName) | 144 | expect(video.name).to.not.be.empty |
145 | expect(video.name).to.equal(videoName) | ||
146 | } | ||
145 | 147 | ||
146 | expect(video.uuid).to.be.a('string') | 148 | if (videoUUID) { |
147 | expect(video.uuid).to.not.be.empty | 149 | expect(video.uuid).to.be.a('string') |
148 | if (videoUUID) expect(video.uuid).to.equal(videoUUID) | 150 | expect(video.uuid).to.not.be.empty |
151 | expect(video.uuid).to.equal(videoUUID) | ||
152 | } | ||
149 | 153 | ||
150 | expect(video.id).to.be.a('number') | 154 | expect(video.id).to.be.a('number') |
151 | } | 155 | } |
@@ -436,18 +440,43 @@ async function checkNewCommentOnMyVideo (base: CheckerBaseParams, uuid: string, | |||
436 | } | 440 | } |
437 | 441 | ||
438 | async function checkNewVideoAbuseForModerators (base: CheckerBaseParams, videoUUID: string, videoName: string, type: CheckerType) { | 442 | async function checkNewVideoAbuseForModerators (base: CheckerBaseParams, videoUUID: string, videoName: string, type: CheckerType) { |
439 | const notificationType = UserNotificationType.NEW_VIDEO_ABUSE_FOR_MODERATORS | 443 | const notificationType = UserNotificationType.NEW_ABUSE_FOR_MODERATORS |
444 | |||
445 | function notificationChecker (notification: UserNotification, type: CheckerType) { | ||
446 | if (type === 'presence') { | ||
447 | expect(notification).to.not.be.undefined | ||
448 | expect(notification.type).to.equal(notificationType) | ||
449 | |||
450 | expect(notification.abuse.id).to.be.a('number') | ||
451 | checkVideo(notification.abuse.video, videoName, videoUUID) | ||
452 | } else { | ||
453 | expect(notification).to.satisfy((n: UserNotification) => { | ||
454 | return n === undefined || n.abuse === undefined || n.abuse.video.uuid !== videoUUID | ||
455 | }) | ||
456 | } | ||
457 | } | ||
458 | |||
459 | function emailNotificationFinder (email: object) { | ||
460 | const text = email['text'] | ||
461 | return text.indexOf(videoUUID) !== -1 && text.indexOf('abuse') !== -1 | ||
462 | } | ||
463 | |||
464 | await checkNotification(base, notificationChecker, emailNotificationFinder, type) | ||
465 | } | ||
466 | |||
467 | async function checkNewCommentAbuseForModerators (base: CheckerBaseParams, videoUUID: string, videoName: string, type: CheckerType) { | ||
468 | const notificationType = UserNotificationType.NEW_ABUSE_FOR_MODERATORS | ||
440 | 469 | ||
441 | function notificationChecker (notification: UserNotification, type: CheckerType) { | 470 | function notificationChecker (notification: UserNotification, type: CheckerType) { |
442 | if (type === 'presence') { | 471 | if (type === 'presence') { |
443 | expect(notification).to.not.be.undefined | 472 | expect(notification).to.not.be.undefined |
444 | expect(notification.type).to.equal(notificationType) | 473 | expect(notification.type).to.equal(notificationType) |
445 | 474 | ||
446 | expect(notification.videoAbuse.id).to.be.a('number') | 475 | expect(notification.abuse.id).to.be.a('number') |
447 | checkVideo(notification.videoAbuse.video, videoName, videoUUID) | 476 | checkVideo(notification.abuse.comment.video, videoName, videoUUID) |
448 | } else { | 477 | } else { |
449 | expect(notification).to.satisfy((n: UserNotification) => { | 478 | expect(notification).to.satisfy((n: UserNotification) => { |
450 | return n === undefined || n.videoAbuse === undefined || n.videoAbuse.video.uuid !== videoUUID | 479 | return n === undefined || n.abuse === undefined || n.abuse.comment.video.uuid !== videoUUID |
451 | }) | 480 | }) |
452 | } | 481 | } |
453 | } | 482 | } |
@@ -460,6 +489,31 @@ async function checkNewVideoAbuseForModerators (base: CheckerBaseParams, videoUU | |||
460 | await checkNotification(base, notificationChecker, emailNotificationFinder, type) | 489 | await checkNotification(base, notificationChecker, emailNotificationFinder, type) |
461 | } | 490 | } |
462 | 491 | ||
492 | async function checkNewAccountAbuseForModerators (base: CheckerBaseParams, displayName: string, type: CheckerType) { | ||
493 | const notificationType = UserNotificationType.NEW_ABUSE_FOR_MODERATORS | ||
494 | |||
495 | function notificationChecker (notification: UserNotification, type: CheckerType) { | ||
496 | if (type === 'presence') { | ||
497 | expect(notification).to.not.be.undefined | ||
498 | expect(notification.type).to.equal(notificationType) | ||
499 | |||
500 | expect(notification.abuse.id).to.be.a('number') | ||
501 | expect(notification.abuse.account.displayName).to.equal(displayName) | ||
502 | } else { | ||
503 | expect(notification).to.satisfy((n: UserNotification) => { | ||
504 | return n === undefined || n.abuse === undefined || n.abuse.account.displayName !== displayName | ||
505 | }) | ||
506 | } | ||
507 | } | ||
508 | |||
509 | function emailNotificationFinder (email: object) { | ||
510 | const text = email['text'] | ||
511 | return text.indexOf(displayName) !== -1 && text.indexOf('abuse') !== -1 | ||
512 | } | ||
513 | |||
514 | await checkNotification(base, notificationChecker, emailNotificationFinder, type) | ||
515 | } | ||
516 | |||
463 | async function checkVideoAutoBlacklistForModerators (base: CheckerBaseParams, videoUUID: string, videoName: string, type: CheckerType) { | 517 | async function checkVideoAutoBlacklistForModerators (base: CheckerBaseParams, videoUUID: string, videoName: string, type: CheckerType) { |
464 | const notificationType = UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS | 518 | const notificationType = UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS |
465 | 519 | ||
@@ -516,7 +570,7 @@ function getAllNotificationsSettings () { | |||
516 | return { | 570 | return { |
517 | newVideoFromSubscription: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, | 571 | newVideoFromSubscription: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, |
518 | newCommentOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, | 572 | newCommentOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, |
519 | videoAbuseAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, | 573 | abuseAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, |
520 | videoAutoBlacklistAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, | 574 | videoAutoBlacklistAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, |
521 | blacklistOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, | 575 | blacklistOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, |
522 | myVideoImportFinished: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, | 576 | myVideoImportFinished: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, |
@@ -541,6 +595,9 @@ async function prepareNotificationsTest (serversCount = 3) { | |||
541 | smtp: { | 595 | smtp: { |
542 | hostname: 'localhost', | 596 | hostname: 'localhost', |
543 | port | 597 | port |
598 | }, | ||
599 | signup: { | ||
600 | limit: 20 | ||
544 | } | 601 | } |
545 | } | 602 | } |
546 | const servers = await flushAndRunMultipleServers(serversCount, overrideConfig) | 603 | const servers = await flushAndRunMultipleServers(serversCount, overrideConfig) |
@@ -623,5 +680,7 @@ export { | |||
623 | markAsReadNotifications, | 680 | markAsReadNotifications, |
624 | getLastNotification, | 681 | getLastNotification, |
625 | checkNewInstanceFollower, | 682 | checkNewInstanceFollower, |
626 | prepareNotificationsTest | 683 | prepareNotificationsTest, |
684 | checkNewCommentAbuseForModerators, | ||
685 | checkNewAccountAbuseForModerators | ||
627 | } | 686 | } |
diff --git a/shared/extra-utils/videos/video-abuses.ts b/shared/extra-utils/videos/video-abuses.ts index ff006672a..8827b8196 100644 --- a/shared/extra-utils/videos/video-abuses.ts +++ b/shared/extra-utils/videos/video-abuses.ts | |||
@@ -1,15 +1,15 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { VideoAbuseUpdate } from '../../models/videos/abuse/video-abuse-update.model' | 2 | import { AbusePredefinedReasonsString, AbuseState, AbuseUpdate, AbuseVideoIs } from '@shared/models' |
3 | import { makeDeleteRequest, makePutBodyRequest, makeGetRequest } from '../requests/requests' | 3 | import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests' |
4 | import { VideoAbuseState, VideoAbusePredefinedReasonsString } from '@shared/models' | 4 | |
5 | import { VideoAbuseVideoIs } from '@shared/models/videos/abuse/video-abuse-video-is.type' | 5 | // FIXME: deprecated in 2.3. Remove this file |
6 | 6 | ||
7 | function reportVideoAbuse ( | 7 | function reportVideoAbuse ( |
8 | url: string, | 8 | url: string, |
9 | token: string, | 9 | token: string, |
10 | videoId: number | string, | 10 | videoId: number | string, |
11 | reason: string, | 11 | reason: string, |
12 | predefinedReasons?: VideoAbusePredefinedReasonsString[], | 12 | predefinedReasons?: AbusePredefinedReasonsString[], |
13 | startAt?: number, | 13 | startAt?: number, |
14 | endAt?: number, | 14 | endAt?: number, |
15 | specialStatus = 200 | 15 | specialStatus = 200 |
@@ -28,10 +28,10 @@ function getVideoAbusesList (options: { | |||
28 | url: string | 28 | url: string |
29 | token: string | 29 | token: string |
30 | id?: number | 30 | id?: number |
31 | predefinedReason?: VideoAbusePredefinedReasonsString | 31 | predefinedReason?: AbusePredefinedReasonsString |
32 | search?: string | 32 | search?: string |
33 | state?: VideoAbuseState | 33 | state?: AbuseState |
34 | videoIs?: VideoAbuseVideoIs | 34 | videoIs?: AbuseVideoIs |
35 | searchReporter?: string | 35 | searchReporter?: string |
36 | searchReportee?: string | 36 | searchReportee?: string |
37 | searchVideo?: string | 37 | searchVideo?: string |
@@ -79,7 +79,7 @@ function updateVideoAbuse ( | |||
79 | token: string, | 79 | token: string, |
80 | videoId: string | number, | 80 | videoId: string | number, |
81 | videoAbuseId: number, | 81 | videoAbuseId: number, |
82 | body: VideoAbuseUpdate, | 82 | body: AbuseUpdate, |
83 | statusCodeExpected = 204 | 83 | statusCodeExpected = 204 |
84 | ) { | 84 | ) { |
85 | const path = '/api/v1/videos/' + videoId + '/abuse/' + videoAbuseId | 85 | const path = '/api/v1/videos/' + videoId + '/abuse/' + videoAbuseId |
diff --git a/shared/models/activitypub/activity.ts b/shared/models/activitypub/activity.ts index 31b9e4673..5b4ce214a 100644 --- a/shared/models/activitypub/activity.ts +++ b/shared/models/activitypub/activity.ts | |||
@@ -1,12 +1,12 @@ | |||
1 | import { ActivityPubActor } from './activitypub-actor' | 1 | import { ActivityPubActor } from './activitypub-actor' |
2 | import { ActivityPubSignature } from './activitypub-signature' | 2 | import { ActivityPubSignature } from './activitypub-signature' |
3 | import { CacheFileObject, VideoTorrentObject, ActivityFlagReasonObject } from './objects' | 3 | import { ActivityFlagReasonObject, CacheFileObject, VideoTorrentObject } from './objects' |
4 | import { AbuseObject } from './objects/abuse-object' | ||
4 | import { DislikeObject } from './objects/dislike-object' | 5 | import { DislikeObject } from './objects/dislike-object' |
5 | import { VideoAbuseObject } from './objects/video-abuse-object' | ||
6 | import { VideoCommentObject } from './objects/video-comment-object' | ||
7 | import { ViewObject } from './objects/view-object' | ||
8 | import { APObject } from './objects/object.model' | 6 | import { APObject } from './objects/object.model' |
9 | import { PlaylistObject } from './objects/playlist-object' | 7 | import { PlaylistObject } from './objects/playlist-object' |
8 | import { VideoCommentObject } from './objects/video-comment-object' | ||
9 | import { ViewObject } from './objects/view-object' | ||
10 | 10 | ||
11 | export type Activity = | 11 | export type Activity = |
12 | ActivityCreate | | 12 | ActivityCreate | |
@@ -53,7 +53,7 @@ export interface BaseActivity { | |||
53 | 53 | ||
54 | export interface ActivityCreate extends BaseActivity { | 54 | export interface ActivityCreate extends BaseActivity { |
55 | type: 'Create' | 55 | type: 'Create' |
56 | object: VideoTorrentObject | VideoAbuseObject | ViewObject | DislikeObject | VideoCommentObject | CacheFileObject | PlaylistObject | 56 | object: VideoTorrentObject | AbuseObject | ViewObject | DislikeObject | VideoCommentObject | CacheFileObject | PlaylistObject |
57 | } | 57 | } |
58 | 58 | ||
59 | export interface ActivityUpdate extends BaseActivity { | 59 | export interface ActivityUpdate extends BaseActivity { |
diff --git a/shared/models/activitypub/objects/video-abuse-object.ts b/shared/models/activitypub/objects/abuse-object.ts index 73add8ef4..ad45cc064 100644 --- a/shared/models/activitypub/objects/video-abuse-object.ts +++ b/shared/models/activitypub/objects/abuse-object.ts | |||
@@ -1,10 +1,12 @@ | |||
1 | import { ActivityFlagReasonObject } from './common-objects' | 1 | import { ActivityFlagReasonObject } from './common-objects' |
2 | 2 | ||
3 | export interface VideoAbuseObject { | 3 | export interface AbuseObject { |
4 | type: 'Flag' | 4 | type: 'Flag' |
5 | content: string | 5 | content: string |
6 | object: string | string[] | 6 | object: string | string[] |
7 | |||
7 | tag?: ActivityFlagReasonObject[] | 8 | tag?: ActivityFlagReasonObject[] |
9 | |||
8 | startAt?: number | 10 | startAt?: number |
9 | endAt?: number | 11 | endAt?: number |
10 | } | 12 | } |
diff --git a/shared/models/activitypub/objects/common-objects.ts b/shared/models/activitypub/objects/common-objects.ts index 096d422ea..711ce45f4 100644 --- a/shared/models/activitypub/objects/common-objects.ts +++ b/shared/models/activitypub/objects/common-objects.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { VideoAbusePredefinedReasonsString } from '@shared/models/videos' | 1 | import { AbusePredefinedReasonsString } from '@shared/models' |
2 | 2 | ||
3 | export interface ActivityIdentifierObject { | 3 | export interface ActivityIdentifierObject { |
4 | identifier: string | 4 | identifier: string |
@@ -85,7 +85,7 @@ export interface ActivityMentionObject { | |||
85 | 85 | ||
86 | export interface ActivityFlagReasonObject { | 86 | export interface ActivityFlagReasonObject { |
87 | type: 'Hashtag' | 87 | type: 'Hashtag' |
88 | name: VideoAbusePredefinedReasonsString | 88 | name: AbusePredefinedReasonsString |
89 | } | 89 | } |
90 | 90 | ||
91 | export type ActivityTagObject = | 91 | export type ActivityTagObject = |
diff --git a/shared/models/activitypub/objects/index.ts b/shared/models/activitypub/objects/index.ts index fba61e12f..a6a20e87a 100644 --- a/shared/models/activitypub/objects/index.ts +++ b/shared/models/activitypub/objects/index.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | export * from './abuse-object' | ||
1 | export * from './cache-file-object' | 2 | export * from './cache-file-object' |
2 | export * from './common-objects' | 3 | export * from './common-objects' |
3 | export * from './video-abuse-object' | 4 | export * from './dislike-object' |
4 | export * from './video-torrent-object' | 5 | export * from './video-torrent-object' |
5 | export * from './view-object' | 6 | export * from './view-object' |
6 | export * from './dislike-object' | ||
diff --git a/shared/models/index.ts b/shared/models/index.ts index 3d4bdedde..a68f57148 100644 --- a/shared/models/index.ts +++ b/shared/models/index.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | export * from './activitypub' | 1 | export * from './activitypub' |
2 | export * from './actors' | 2 | export * from './actors' |
3 | export * from './avatars' | 3 | export * from './avatars' |
4 | export * from './blocklist' | 4 | export * from './moderation' |
5 | export * from './bulk' | 5 | export * from './bulk' |
6 | export * from './redundancy' | 6 | export * from './redundancy' |
7 | export * from './users' | 7 | export * from './users' |
@@ -14,4 +14,3 @@ export * from './search' | |||
14 | export * from './server' | 14 | export * from './server' |
15 | export * from './oauth-client-local.model' | 15 | export * from './oauth-client-local.model' |
16 | export * from './result-list.model' | 16 | export * from './result-list.model' |
17 | export * from './server/server-config.model' | ||
diff --git a/shared/models/moderation/abuse/abuse-create.model.ts b/shared/models/moderation/abuse/abuse-create.model.ts new file mode 100644 index 000000000..b0358dbb9 --- /dev/null +++ b/shared/models/moderation/abuse/abuse-create.model.ts | |||
@@ -0,0 +1,29 @@ | |||
1 | import { AbusePredefinedReasonsString } from './abuse-reason.model' | ||
2 | |||
3 | export interface AbuseCreate { | ||
4 | reason: string | ||
5 | |||
6 | predefinedReasons?: AbusePredefinedReasonsString[] | ||
7 | |||
8 | account?: { | ||
9 | id: number | ||
10 | } | ||
11 | |||
12 | video?: { | ||
13 | id: number | ||
14 | startAt?: number | ||
15 | endAt?: number | ||
16 | } | ||
17 | |||
18 | comment?: { | ||
19 | id: number | ||
20 | } | ||
21 | } | ||
22 | |||
23 | // FIXME: deprecated in 2.3. Remove it | ||
24 | export interface VideoAbuseCreate { | ||
25 | reason: string | ||
26 | predefinedReasons?: AbusePredefinedReasonsString[] | ||
27 | startAt?: number | ||
28 | endAt?: number | ||
29 | } | ||
diff --git a/shared/models/moderation/abuse/abuse-filter.type.ts b/shared/models/moderation/abuse/abuse-filter.type.ts new file mode 100644 index 000000000..7dafc6d77 --- /dev/null +++ b/shared/models/moderation/abuse/abuse-filter.type.ts | |||
@@ -0,0 +1 @@ | |||
export type AbuseFilter = 'video' | 'comment' | 'account' | |||
diff --git a/shared/models/moderation/abuse/abuse-reason.model.ts b/shared/models/moderation/abuse/abuse-reason.model.ts new file mode 100644 index 000000000..36875969d --- /dev/null +++ b/shared/models/moderation/abuse/abuse-reason.model.ts | |||
@@ -0,0 +1,33 @@ | |||
1 | export enum AbusePredefinedReasons { | ||
2 | VIOLENT_OR_REPULSIVE = 1, | ||
3 | HATEFUL_OR_ABUSIVE, | ||
4 | SPAM_OR_MISLEADING, | ||
5 | PRIVACY, | ||
6 | RIGHTS, | ||
7 | SERVER_RULES, | ||
8 | THUMBNAILS, | ||
9 | CAPTIONS | ||
10 | } | ||
11 | |||
12 | export type AbusePredefinedReasonsString = | ||
13 | 'violentOrRepulsive' | | ||
14 | 'hatefulOrAbusive' | | ||
15 | 'spamOrMisleading' | | ||
16 | 'privacy' | | ||
17 | 'rights' | | ||
18 | 'serverRules' | | ||
19 | 'thumbnails' | | ||
20 | 'captions' | ||
21 | |||
22 | export const abusePredefinedReasonsMap: { | ||
23 | [key in AbusePredefinedReasonsString]: AbusePredefinedReasons | ||
24 | } = { | ||
25 | violentOrRepulsive: AbusePredefinedReasons.VIOLENT_OR_REPULSIVE, | ||
26 | hatefulOrAbusive: AbusePredefinedReasons.HATEFUL_OR_ABUSIVE, | ||
27 | spamOrMisleading: AbusePredefinedReasons.SPAM_OR_MISLEADING, | ||
28 | privacy: AbusePredefinedReasons.PRIVACY, | ||
29 | rights: AbusePredefinedReasons.RIGHTS, | ||
30 | serverRules: AbusePredefinedReasons.SERVER_RULES, | ||
31 | thumbnails: AbusePredefinedReasons.THUMBNAILS, | ||
32 | captions: AbusePredefinedReasons.CAPTIONS | ||
33 | } | ||
diff --git a/shared/models/videos/abuse/video-abuse-state.model.ts b/shared/models/moderation/abuse/abuse-state.model.ts index 529f034bd..b00cccad8 100644 --- a/shared/models/videos/abuse/video-abuse-state.model.ts +++ b/shared/models/moderation/abuse/abuse-state.model.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | export enum VideoAbuseState { | 1 | export enum AbuseState { |
2 | PENDING = 1, | 2 | PENDING = 1, |
3 | REJECTED = 2, | 3 | REJECTED = 2, |
4 | ACCEPTED = 3 | 4 | ACCEPTED = 3 |
diff --git a/shared/models/moderation/abuse/abuse-update.model.ts b/shared/models/moderation/abuse/abuse-update.model.ts new file mode 100644 index 000000000..4360fe7ac --- /dev/null +++ b/shared/models/moderation/abuse/abuse-update.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { AbuseState } from './abuse-state.model' | ||
2 | |||
3 | export interface AbuseUpdate { | ||
4 | moderationComment?: string | ||
5 | |||
6 | state?: AbuseState | ||
7 | } | ||
diff --git a/shared/models/moderation/abuse/abuse-video-is.type.ts b/shared/models/moderation/abuse/abuse-video-is.type.ts new file mode 100644 index 000000000..74937f3b9 --- /dev/null +++ b/shared/models/moderation/abuse/abuse-video-is.type.ts | |||
@@ -0,0 +1 @@ | |||
export type AbuseVideoIs = 'deleted' | 'blacklisted' | |||
diff --git a/shared/models/moderation/abuse/abuse.model.ts b/shared/models/moderation/abuse/abuse.model.ts new file mode 100644 index 000000000..0a0c6bd35 --- /dev/null +++ b/shared/models/moderation/abuse/abuse.model.ts | |||
@@ -0,0 +1,73 @@ | |||
1 | import { Account } from '../../actors/account.model' | ||
2 | import { AbuseState } from './abuse-state.model' | ||
3 | import { AbusePredefinedReasonsString } from './abuse-reason.model' | ||
4 | import { VideoConstant } from '../../videos/video-constant.model' | ||
5 | import { VideoChannel } from '../../videos/channel/video-channel.model' | ||
6 | |||
7 | export interface VideoAbuse { | ||
8 | id: number | ||
9 | name: string | ||
10 | uuid: string | ||
11 | nsfw: boolean | ||
12 | |||
13 | deleted: boolean | ||
14 | blacklisted: boolean | ||
15 | |||
16 | startAt: number | null | ||
17 | endAt: number | null | ||
18 | |||
19 | thumbnailPath?: string | ||
20 | channel?: VideoChannel | ||
21 | |||
22 | countReports: number | ||
23 | nthReport: number | ||
24 | } | ||
25 | |||
26 | export interface VideoCommentAbuse { | ||
27 | id: number | ||
28 | threadId: number | ||
29 | |||
30 | video: { | ||
31 | id: number | ||
32 | name: string | ||
33 | uuid: string | ||
34 | } | ||
35 | |||
36 | text: string | ||
37 | |||
38 | deleted: boolean | ||
39 | } | ||
40 | |||
41 | export interface Abuse { | ||
42 | id: number | ||
43 | |||
44 | reason: string | ||
45 | predefinedReasons?: AbusePredefinedReasonsString[] | ||
46 | |||
47 | reporterAccount: Account | ||
48 | flaggedAccount: Account | ||
49 | |||
50 | state: VideoConstant<AbuseState> | ||
51 | moderationComment?: string | ||
52 | |||
53 | video?: VideoAbuse | ||
54 | comment?: VideoCommentAbuse | ||
55 | |||
56 | createdAt: Date | ||
57 | updatedAt: Date | ||
58 | |||
59 | countReportsForReporter?: number | ||
60 | countReportsForReportee?: number | ||
61 | |||
62 | // FIXME: deprecated in 2.3, remove the following properties | ||
63 | |||
64 | // @deprecated | ||
65 | startAt?: null | ||
66 | // @deprecated | ||
67 | endAt?: null | ||
68 | |||
69 | // @deprecated | ||
70 | count?: number | ||
71 | // @deprecated | ||
72 | nth?: number | ||
73 | } | ||
diff --git a/shared/models/moderation/abuse/index.ts b/shared/models/moderation/abuse/index.ts new file mode 100644 index 000000000..55046426a --- /dev/null +++ b/shared/models/moderation/abuse/index.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export * from './abuse-create.model' | ||
2 | export * from './abuse-filter.type' | ||
3 | export * from './abuse-reason.model' | ||
4 | export * from './abuse-state.model' | ||
5 | export * from './abuse-update.model' | ||
6 | export * from './abuse-video-is.type' | ||
7 | export * from './abuse.model' | ||
diff --git a/shared/models/blocklist/account-block.model.ts b/shared/models/moderation/account-block.model.ts index a942ed614..a942ed614 100644 --- a/shared/models/blocklist/account-block.model.ts +++ b/shared/models/moderation/account-block.model.ts | |||
diff --git a/shared/models/blocklist/index.ts b/shared/models/moderation/index.ts index fc7873270..8b6042e97 100644 --- a/shared/models/blocklist/index.ts +++ b/shared/models/moderation/index.ts | |||
@@ -1,2 +1,3 @@ | |||
1 | export * from './abuse' | ||
1 | export * from './account-block.model' | 2 | export * from './account-block.model' |
2 | export * from './server-block.model' | 3 | export * from './server-block.model' |
diff --git a/shared/models/blocklist/server-block.model.ts b/shared/models/moderation/server-block.model.ts index a8b8af0b7..a8b8af0b7 100644 --- a/shared/models/blocklist/server-block.model.ts +++ b/shared/models/moderation/server-block.model.ts | |||
diff --git a/shared/models/users/user-notification-setting.model.ts b/shared/models/users/user-notification-setting.model.ts index 451f40d58..4e2230a76 100644 --- a/shared/models/users/user-notification-setting.model.ts +++ b/shared/models/users/user-notification-setting.model.ts | |||
@@ -7,7 +7,7 @@ export enum UserNotificationSettingValue { | |||
7 | export interface UserNotificationSetting { | 7 | export interface UserNotificationSetting { |
8 | newVideoFromSubscription: UserNotificationSettingValue | 8 | newVideoFromSubscription: UserNotificationSettingValue |
9 | newCommentOnMyVideo: UserNotificationSettingValue | 9 | newCommentOnMyVideo: UserNotificationSettingValue |
10 | videoAbuseAsModerator: UserNotificationSettingValue | 10 | abuseAsModerator: UserNotificationSettingValue |
11 | videoAutoBlacklistAsModerator: UserNotificationSettingValue | 11 | videoAutoBlacklistAsModerator: UserNotificationSettingValue |
12 | blacklistOnMyVideo: UserNotificationSettingValue | 12 | blacklistOnMyVideo: UserNotificationSettingValue |
13 | myVideoPublished: UserNotificationSettingValue | 13 | myVideoPublished: UserNotificationSettingValue |
diff --git a/shared/models/users/user-notification.model.ts b/shared/models/users/user-notification.model.ts index e9be1ca7f..5f7c33976 100644 --- a/shared/models/users/user-notification.model.ts +++ b/shared/models/users/user-notification.model.ts | |||
@@ -3,7 +3,7 @@ import { FollowState } from '../actors' | |||
3 | export enum UserNotificationType { | 3 | export enum UserNotificationType { |
4 | NEW_VIDEO_FROM_SUBSCRIPTION = 1, | 4 | NEW_VIDEO_FROM_SUBSCRIPTION = 1, |
5 | NEW_COMMENT_ON_MY_VIDEO = 2, | 5 | NEW_COMMENT_ON_MY_VIDEO = 2, |
6 | NEW_VIDEO_ABUSE_FOR_MODERATORS = 3, | 6 | NEW_ABUSE_FOR_MODERATORS = 3, |
7 | 7 | ||
8 | BLACKLIST_ON_MY_VIDEO = 4, | 8 | BLACKLIST_ON_MY_VIDEO = 4, |
9 | UNBLACKLIST_ON_MY_VIDEO = 5, | 9 | UNBLACKLIST_ON_MY_VIDEO = 5, |
@@ -64,9 +64,22 @@ export interface UserNotification { | |||
64 | video: VideoInfo | 64 | video: VideoInfo |
65 | } | 65 | } |
66 | 66 | ||
67 | videoAbuse?: { | 67 | abuse?: { |
68 | id: number | 68 | id: number |
69 | video: VideoInfo | 69 | |
70 | video?: VideoInfo | ||
71 | |||
72 | comment?: { | ||
73 | threadId: number | ||
74 | |||
75 | video: { | ||
76 | id: number | ||
77 | uuid: string | ||
78 | name: string | ||
79 | } | ||
80 | } | ||
81 | |||
82 | account?: ActorInfo | ||
70 | } | 83 | } |
71 | 84 | ||
72 | videoBlacklist?: { | 85 | videoBlacklist?: { |
diff --git a/shared/models/users/user-right.enum.ts b/shared/models/users/user-right.enum.ts index 2f88a65de..4a7ae4373 100644 --- a/shared/models/users/user-right.enum.ts +++ b/shared/models/users/user-right.enum.ts | |||
@@ -11,7 +11,7 @@ export enum UserRight { | |||
11 | 11 | ||
12 | MANAGE_SERVER_REDUNDANCY, | 12 | MANAGE_SERVER_REDUNDANCY, |
13 | 13 | ||
14 | MANAGE_VIDEO_ABUSES, | 14 | MANAGE_ABUSES, |
15 | 15 | ||
16 | MANAGE_JOBS, | 16 | MANAGE_JOBS, |
17 | 17 | ||
diff --git a/shared/models/users/user-role.ts b/shared/models/users/user-role.ts index 2b08b5850..772988c0c 100644 --- a/shared/models/users/user-role.ts +++ b/shared/models/users/user-role.ts | |||
@@ -20,7 +20,7 @@ const userRoleRights: { [ id in UserRole ]: UserRight[] } = { | |||
20 | 20 | ||
21 | [UserRole.MODERATOR]: [ | 21 | [UserRole.MODERATOR]: [ |
22 | UserRight.MANAGE_VIDEO_BLACKLIST, | 22 | UserRight.MANAGE_VIDEO_BLACKLIST, |
23 | UserRight.MANAGE_VIDEO_ABUSES, | 23 | UserRight.MANAGE_ABUSES, |
24 | UserRight.REMOVE_ANY_VIDEO, | 24 | UserRight.REMOVE_ANY_VIDEO, |
25 | UserRight.REMOVE_ANY_VIDEO_CHANNEL, | 25 | UserRight.REMOVE_ANY_VIDEO_CHANNEL, |
26 | UserRight.REMOVE_ANY_VIDEO_PLAYLIST, | 26 | UserRight.REMOVE_ANY_VIDEO_PLAYLIST, |
diff --git a/shared/models/users/user.model.ts b/shared/models/users/user.model.ts index 6c959ceea..859736b2f 100644 --- a/shared/models/users/user.model.ts +++ b/shared/models/users/user.model.ts | |||
@@ -31,10 +31,13 @@ export interface User { | |||
31 | videoQuotaDaily: number | 31 | videoQuotaDaily: number |
32 | videoQuotaUsed?: number | 32 | videoQuotaUsed?: number |
33 | videoQuotaUsedDaily?: number | 33 | videoQuotaUsedDaily?: number |
34 | |||
34 | videosCount?: number | 35 | videosCount?: number |
35 | videoAbusesCount?: number | 36 | |
36 | videoAbusesAcceptedCount?: number | 37 | abusesCount?: number |
37 | videoAbusesCreatedCount?: number | 38 | abusesAcceptedCount?: number |
39 | abusesCreatedCount?: number | ||
40 | |||
38 | videoCommentsCount? : number | 41 | videoCommentsCount? : number |
39 | 42 | ||
40 | theme: string | 43 | theme: string |
diff --git a/shared/models/videos/abuse/index.ts b/shared/models/videos/abuse/index.ts deleted file mode 100644 index f70bc736f..000000000 --- a/shared/models/videos/abuse/index.ts +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | export * from './video-abuse-create.model' | ||
2 | export * from './video-abuse-reason.model' | ||
3 | export * from './video-abuse-state.model' | ||
4 | export * from './video-abuse-update.model' | ||
5 | export * from './video-abuse-video-is.type' | ||
6 | export * from './video-abuse.model' | ||
diff --git a/shared/models/videos/abuse/video-abuse-create.model.ts b/shared/models/videos/abuse/video-abuse-create.model.ts deleted file mode 100644 index c93cb8b2c..000000000 --- a/shared/models/videos/abuse/video-abuse-create.model.ts +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | import { VideoAbusePredefinedReasonsString } from './video-abuse-reason.model' | ||
2 | |||
3 | export interface VideoAbuseCreate { | ||
4 | reason: string | ||
5 | predefinedReasons?: VideoAbusePredefinedReasonsString[] | ||
6 | startAt?: number | ||
7 | endAt?: number | ||
8 | } | ||
diff --git a/shared/models/videos/abuse/video-abuse-reason.model.ts b/shared/models/videos/abuse/video-abuse-reason.model.ts deleted file mode 100644 index 9064f0c1a..000000000 --- a/shared/models/videos/abuse/video-abuse-reason.model.ts +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | export enum VideoAbusePredefinedReasons { | ||
2 | VIOLENT_OR_REPULSIVE = 1, | ||
3 | HATEFUL_OR_ABUSIVE, | ||
4 | SPAM_OR_MISLEADING, | ||
5 | PRIVACY, | ||
6 | RIGHTS, | ||
7 | SERVER_RULES, | ||
8 | THUMBNAILS, | ||
9 | CAPTIONS | ||
10 | } | ||
11 | |||
12 | export type VideoAbusePredefinedReasonsString = | ||
13 | 'violentOrRepulsive' | | ||
14 | 'hatefulOrAbusive' | | ||
15 | 'spamOrMisleading' | | ||
16 | 'privacy' | | ||
17 | 'rights' | | ||
18 | 'serverRules' | | ||
19 | 'thumbnails' | | ||
20 | 'captions' | ||
21 | |||
22 | export const videoAbusePredefinedReasonsMap: { | ||
23 | [key in VideoAbusePredefinedReasonsString]: VideoAbusePredefinedReasons | ||
24 | } = { | ||
25 | violentOrRepulsive: VideoAbusePredefinedReasons.VIOLENT_OR_REPULSIVE, | ||
26 | hatefulOrAbusive: VideoAbusePredefinedReasons.HATEFUL_OR_ABUSIVE, | ||
27 | spamOrMisleading: VideoAbusePredefinedReasons.SPAM_OR_MISLEADING, | ||
28 | privacy: VideoAbusePredefinedReasons.PRIVACY, | ||
29 | rights: VideoAbusePredefinedReasons.RIGHTS, | ||
30 | serverRules: VideoAbusePredefinedReasons.SERVER_RULES, | ||
31 | thumbnails: VideoAbusePredefinedReasons.THUMBNAILS, | ||
32 | captions: VideoAbusePredefinedReasons.CAPTIONS | ||
33 | } | ||
diff --git a/shared/models/videos/abuse/video-abuse-update.model.ts b/shared/models/videos/abuse/video-abuse-update.model.ts deleted file mode 100644 index 9b32aae48..000000000 --- a/shared/models/videos/abuse/video-abuse-update.model.ts +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | import { VideoAbuseState } from './video-abuse-state.model' | ||
2 | |||
3 | export interface VideoAbuseUpdate { | ||
4 | moderationComment?: string | ||
5 | state?: VideoAbuseState | ||
6 | } | ||
diff --git a/shared/models/videos/abuse/video-abuse-video-is.type.ts b/shared/models/videos/abuse/video-abuse-video-is.type.ts deleted file mode 100644 index e86018993..000000000 --- a/shared/models/videos/abuse/video-abuse-video-is.type.ts +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | export type VideoAbuseVideoIs = 'deleted' | 'blacklisted' | ||
diff --git a/shared/models/videos/abuse/video-abuse.model.ts b/shared/models/videos/abuse/video-abuse.model.ts deleted file mode 100644 index 38605dcac..000000000 --- a/shared/models/videos/abuse/video-abuse.model.ts +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | import { Account } from '../../actors/index' | ||
2 | import { VideoConstant } from '../video-constant.model' | ||
3 | import { VideoAbuseState } from './video-abuse-state.model' | ||
4 | import { VideoChannel } from '../channel/video-channel.model' | ||
5 | import { VideoAbusePredefinedReasonsString } from './video-abuse-reason.model' | ||
6 | |||
7 | export interface VideoAbuse { | ||
8 | id: number | ||
9 | reason: string | ||
10 | predefinedReasons?: VideoAbusePredefinedReasonsString[] | ||
11 | reporterAccount: Account | ||
12 | |||
13 | state: VideoConstant<VideoAbuseState> | ||
14 | moderationComment?: string | ||
15 | |||
16 | video: { | ||
17 | id: number | ||
18 | name: string | ||
19 | uuid: string | ||
20 | nsfw: boolean | ||
21 | deleted: boolean | ||
22 | blacklisted: boolean | ||
23 | thumbnailPath?: string | ||
24 | channel?: VideoChannel | ||
25 | } | ||
26 | |||
27 | createdAt: Date | ||
28 | updatedAt: Date | ||
29 | |||
30 | startAt: number | ||
31 | endAt: number | ||
32 | |||
33 | count?: number | ||
34 | nth?: number | ||
35 | |||
36 | countReportsForReporter?: number | ||
37 | countReportsForReportee?: number | ||
38 | } | ||
diff --git a/shared/models/videos/index.ts b/shared/models/videos/index.ts index e1d96b40a..20b9638ab 100644 --- a/shared/models/videos/index.ts +++ b/shared/models/videos/index.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | export * from './abuse' | ||
2 | export * from './blacklist' | 1 | export * from './blacklist' |
3 | export * from './caption' | 2 | export * from './caption' |
4 | export * from './channel' | 3 | export * from './channel' |