diff options
Diffstat (limited to 'shared')
-rw-r--r-- | shared/extra-utils/videos/video-abuses.ts | 18 | ||||
-rw-r--r-- | shared/models/activitypub/activity.ts | 5 | ||||
-rw-r--r-- | shared/models/activitypub/objects/common-objects.ts | 11 | ||||
-rw-r--r-- | shared/models/activitypub/objects/video-abuse-object.ts | 5 | ||||
-rw-r--r-- | shared/models/videos/abuse/video-abuse-create.model.ts | 5 | ||||
-rw-r--r-- | shared/models/videos/abuse/video-abuse-reason.model.ts | 33 | ||||
-rw-r--r-- | shared/models/videos/abuse/video-abuse.model.ts | 5 | ||||
-rw-r--r-- | shared/models/videos/index.ts | 1 |
8 files changed, 77 insertions, 6 deletions
diff --git a/shared/extra-utils/videos/video-abuses.ts b/shared/extra-utils/videos/video-abuses.ts index 81582bfc7..ff006672a 100644 --- a/shared/extra-utils/videos/video-abuses.ts +++ b/shared/extra-utils/videos/video-abuses.ts | |||
@@ -1,17 +1,26 @@ | |||
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 { VideoAbuseUpdate } from '../../models/videos/abuse/video-abuse-update.model' |
3 | import { makeDeleteRequest, makePutBodyRequest, makeGetRequest } from '../requests/requests' | 3 | import { makeDeleteRequest, makePutBodyRequest, makeGetRequest } from '../requests/requests' |
4 | import { VideoAbuseState } from '@shared/models' | 4 | import { VideoAbuseState, VideoAbusePredefinedReasonsString } from '@shared/models' |
5 | import { VideoAbuseVideoIs } from '@shared/models/videos/abuse/video-abuse-video-is.type' | 5 | import { VideoAbuseVideoIs } from '@shared/models/videos/abuse/video-abuse-video-is.type' |
6 | 6 | ||
7 | function reportVideoAbuse (url: string, token: string, videoId: number | string, reason: string, specialStatus = 200) { | 7 | function reportVideoAbuse ( |
8 | url: string, | ||
9 | token: string, | ||
10 | videoId: number | string, | ||
11 | reason: string, | ||
12 | predefinedReasons?: VideoAbusePredefinedReasonsString[], | ||
13 | startAt?: number, | ||
14 | endAt?: number, | ||
15 | specialStatus = 200 | ||
16 | ) { | ||
8 | const path = '/api/v1/videos/' + videoId + '/abuse' | 17 | const path = '/api/v1/videos/' + videoId + '/abuse' |
9 | 18 | ||
10 | return request(url) | 19 | return request(url) |
11 | .post(path) | 20 | .post(path) |
12 | .set('Accept', 'application/json') | 21 | .set('Accept', 'application/json') |
13 | .set('Authorization', 'Bearer ' + token) | 22 | .set('Authorization', 'Bearer ' + token) |
14 | .send({ reason }) | 23 | .send({ reason, predefinedReasons, startAt, endAt }) |
15 | .expect(specialStatus) | 24 | .expect(specialStatus) |
16 | } | 25 | } |
17 | 26 | ||
@@ -19,6 +28,7 @@ function getVideoAbusesList (options: { | |||
19 | url: string | 28 | url: string |
20 | token: string | 29 | token: string |
21 | id?: number | 30 | id?: number |
31 | predefinedReason?: VideoAbusePredefinedReasonsString | ||
22 | search?: string | 32 | search?: string |
23 | state?: VideoAbuseState | 33 | state?: VideoAbuseState |
24 | videoIs?: VideoAbuseVideoIs | 34 | videoIs?: VideoAbuseVideoIs |
@@ -31,6 +41,7 @@ function getVideoAbusesList (options: { | |||
31 | url, | 41 | url, |
32 | token, | 42 | token, |
33 | id, | 43 | id, |
44 | predefinedReason, | ||
34 | search, | 45 | search, |
35 | state, | 46 | state, |
36 | videoIs, | 47 | videoIs, |
@@ -44,6 +55,7 @@ function getVideoAbusesList (options: { | |||
44 | const query = { | 55 | const query = { |
45 | sort: 'createdAt', | 56 | sort: 'createdAt', |
46 | id, | 57 | id, |
58 | predefinedReason, | ||
47 | search, | 59 | search, |
48 | state, | 60 | state, |
49 | videoIs, | 61 | videoIs, |
diff --git a/shared/models/activitypub/activity.ts b/shared/models/activitypub/activity.ts index 20ecf176c..31b9e4673 100644 --- a/shared/models/activitypub/activity.ts +++ b/shared/models/activitypub/activity.ts | |||
@@ -1,6 +1,6 @@ | |||
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 } from './objects' | 3 | import { CacheFileObject, VideoTorrentObject, ActivityFlagReasonObject } from './objects' |
4 | import { DislikeObject } from './objects/dislike-object' | 4 | import { DislikeObject } from './objects/dislike-object' |
5 | import { VideoAbuseObject } from './objects/video-abuse-object' | 5 | import { VideoAbuseObject } from './objects/video-abuse-object' |
6 | import { VideoCommentObject } from './objects/video-comment-object' | 6 | import { VideoCommentObject } from './objects/video-comment-object' |
@@ -113,4 +113,7 @@ export interface ActivityFlag extends BaseActivity { | |||
113 | type: 'Flag' | 113 | type: 'Flag' |
114 | content: string | 114 | content: string |
115 | object: APObject | APObject[] | 115 | object: APObject | APObject[] |
116 | tag?: ActivityFlagReasonObject[] | ||
117 | startAt?: number | ||
118 | endAt?: number | ||
116 | } | 119 | } |
diff --git a/shared/models/activitypub/objects/common-objects.ts b/shared/models/activitypub/objects/common-objects.ts index bb3ffe678..096d422ea 100644 --- a/shared/models/activitypub/objects/common-objects.ts +++ b/shared/models/activitypub/objects/common-objects.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | import { VideoAbusePredefinedReasonsString } from '@shared/models/videos' | ||
2 | |||
1 | export interface ActivityIdentifierObject { | 3 | export interface ActivityIdentifierObject { |
2 | identifier: string | 4 | identifier: string |
3 | name: string | 5 | name: string |
@@ -70,17 +72,22 @@ export type ActivityHtmlUrlObject = { | |||
70 | } | 72 | } |
71 | 73 | ||
72 | export interface ActivityHashTagObject { | 74 | export interface ActivityHashTagObject { |
73 | type: 'Hashtag' | 'Mention' | 75 | type: 'Hashtag' |
74 | href?: string | 76 | href?: string |
75 | name: string | 77 | name: string |
76 | } | 78 | } |
77 | 79 | ||
78 | export interface ActivityMentionObject { | 80 | export interface ActivityMentionObject { |
79 | type: 'Hashtag' | 'Mention' | 81 | type: 'Mention' |
80 | href?: string | 82 | href?: string |
81 | name: string | 83 | name: string |
82 | } | 84 | } |
83 | 85 | ||
86 | export interface ActivityFlagReasonObject { | ||
87 | type: 'Hashtag' | ||
88 | name: VideoAbusePredefinedReasonsString | ||
89 | } | ||
90 | |||
84 | export type ActivityTagObject = | 91 | export type ActivityTagObject = |
85 | ActivityPlaylistSegmentHashesObject | 92 | ActivityPlaylistSegmentHashesObject |
86 | | ActivityPlaylistInfohashesObject | 93 | | ActivityPlaylistInfohashesObject |
diff --git a/shared/models/activitypub/objects/video-abuse-object.ts b/shared/models/activitypub/objects/video-abuse-object.ts index d9622b414..73add8ef4 100644 --- a/shared/models/activitypub/objects/video-abuse-object.ts +++ b/shared/models/activitypub/objects/video-abuse-object.ts | |||
@@ -1,5 +1,10 @@ | |||
1 | import { ActivityFlagReasonObject } from './common-objects' | ||
2 | |||
1 | export interface VideoAbuseObject { | 3 | export interface VideoAbuseObject { |
2 | type: 'Flag' | 4 | type: 'Flag' |
3 | content: string | 5 | content: string |
4 | object: string | string[] | 6 | object: string | string[] |
7 | tag?: ActivityFlagReasonObject[] | ||
8 | startAt?: number | ||
9 | endAt?: number | ||
5 | } | 10 | } |
diff --git a/shared/models/videos/abuse/video-abuse-create.model.ts b/shared/models/videos/abuse/video-abuse-create.model.ts index db6458275..c93cb8b2c 100644 --- a/shared/models/videos/abuse/video-abuse-create.model.ts +++ b/shared/models/videos/abuse/video-abuse-create.model.ts | |||
@@ -1,3 +1,8 @@ | |||
1 | import { VideoAbusePredefinedReasonsString } from './video-abuse-reason.model' | ||
2 | |||
1 | export interface VideoAbuseCreate { | 3 | export interface VideoAbuseCreate { |
2 | reason: string | 4 | reason: string |
5 | predefinedReasons?: VideoAbusePredefinedReasonsString[] | ||
6 | startAt?: number | ||
7 | endAt?: number | ||
3 | } | 8 | } |
diff --git a/shared/models/videos/abuse/video-abuse-reason.model.ts b/shared/models/videos/abuse/video-abuse-reason.model.ts new file mode 100644 index 000000000..9064f0c1a --- /dev/null +++ b/shared/models/videos/abuse/video-abuse-reason.model.ts | |||
@@ -0,0 +1,33 @@ | |||
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.model.ts b/shared/models/videos/abuse/video-abuse.model.ts index f2c2cdc41..38605dcac 100644 --- a/shared/models/videos/abuse/video-abuse.model.ts +++ b/shared/models/videos/abuse/video-abuse.model.ts | |||
@@ -2,10 +2,12 @@ import { Account } from '../../actors/index' | |||
2 | import { VideoConstant } from '../video-constant.model' | 2 | import { VideoConstant } from '../video-constant.model' |
3 | import { VideoAbuseState } from './video-abuse-state.model' | 3 | import { VideoAbuseState } from './video-abuse-state.model' |
4 | import { VideoChannel } from '../channel/video-channel.model' | 4 | import { VideoChannel } from '../channel/video-channel.model' |
5 | import { VideoAbusePredefinedReasonsString } from './video-abuse-reason.model' | ||
5 | 6 | ||
6 | export interface VideoAbuse { | 7 | export interface VideoAbuse { |
7 | id: number | 8 | id: number |
8 | reason: string | 9 | reason: string |
10 | predefinedReasons?: VideoAbusePredefinedReasonsString[] | ||
9 | reporterAccount: Account | 11 | reporterAccount: Account |
10 | 12 | ||
11 | state: VideoConstant<VideoAbuseState> | 13 | state: VideoConstant<VideoAbuseState> |
@@ -25,6 +27,9 @@ export interface VideoAbuse { | |||
25 | createdAt: Date | 27 | createdAt: Date |
26 | updatedAt: Date | 28 | updatedAt: Date |
27 | 29 | ||
30 | startAt: number | ||
31 | endAt: number | ||
32 | |||
28 | count?: number | 33 | count?: number |
29 | nth?: number | 34 | nth?: number |
30 | 35 | ||
diff --git a/shared/models/videos/index.ts b/shared/models/videos/index.ts index 51ccb9fbd..58bd1ebd7 100644 --- a/shared/models/videos/index.ts +++ b/shared/models/videos/index.ts | |||
@@ -4,6 +4,7 @@ export * from './rate/account-video-rate.model' | |||
4 | export * from './rate/user-video-rate.type' | 4 | export * from './rate/user-video-rate.type' |
5 | export * from './abuse/video-abuse-state.model' | 5 | export * from './abuse/video-abuse-state.model' |
6 | export * from './abuse/video-abuse-create.model' | 6 | export * from './abuse/video-abuse-create.model' |
7 | export * from './abuse/video-abuse-reason.model' | ||
7 | export * from './abuse/video-abuse.model' | 8 | export * from './abuse/video-abuse.model' |
8 | export * from './abuse/video-abuse-update.model' | 9 | export * from './abuse/video-abuse-update.model' |
9 | export * from './blacklist/video-blacklist.model' | 10 | export * from './blacklist/video-blacklist.model' |