aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/models/moderation
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-07-01 16:05:30 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-07-10 14:02:41 +0200
commitd95d15598847c7f020aa056e7e6e0c02d2bbf732 (patch)
treea8a593f1269688caf9e5f99559996f346290fec5 /shared/models/moderation
parent72493e44e9b455a04c4f093ed6c6ffa300b98d8b (diff)
downloadPeerTube-d95d15598847c7f020aa056e7e6e0c02d2bbf732.tar.gz
PeerTube-d95d15598847c7f020aa056e7e6e0c02d2bbf732.tar.zst
PeerTube-d95d15598847c7f020aa056e7e6e0c02d2bbf732.zip
Use 3 tables to represent abuses
Diffstat (limited to 'shared/models/moderation')
-rw-r--r--shared/models/moderation/abuse/abuse-create.model.ts26
-rw-r--r--shared/models/moderation/abuse/abuse-filter.ts1
-rw-r--r--shared/models/moderation/abuse/abuse-reason.model.ts33
-rw-r--r--shared/models/moderation/abuse/abuse-state.model.ts5
-rw-r--r--shared/models/moderation/abuse/abuse-update.model.ts7
-rw-r--r--shared/models/moderation/abuse/abuse-video-is.type.ts1
-rw-r--r--shared/models/moderation/abuse/abuse.model.ts53
-rw-r--r--shared/models/moderation/abuse/index.ts6
-rw-r--r--shared/models/moderation/account-block.model.ts7
-rw-r--r--shared/models/moderation/index.ts3
-rw-r--r--shared/models/moderation/server-block.model.ts9
11 files changed, 151 insertions, 0 deletions
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..c0d04e46d
--- /dev/null
+++ b/shared/models/moderation/abuse/abuse-create.model.ts
@@ -0,0 +1,26 @@
1import { AbusePredefinedReasonsString } from './abuse-reason.model'
2
3export interface AbuseCreate {
4 accountId: number
5
6 reason: string
7 predefinedReasons?: AbusePredefinedReasonsString[]
8
9 video?: {
10 id: number
11 startAt?: number
12 endAt?: number
13 }
14
15 comment?: {
16 id: number
17 }
18}
19
20// FIXME: deprecated in 2.3. Remove it
21export interface VideoAbuseCreate {
22 reason: string
23 predefinedReasons?: AbusePredefinedReasonsString[]
24 startAt?: number
25 endAt?: number
26}
diff --git a/shared/models/moderation/abuse/abuse-filter.ts b/shared/models/moderation/abuse/abuse-filter.ts
new file mode 100644
index 000000000..03303bbab
--- /dev/null
+++ b/shared/models/moderation/abuse/abuse-filter.ts
@@ -0,0 +1 @@
export type AbuseFilter = 'video' | 'comment'
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 @@
1export 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
12export type AbusePredefinedReasonsString =
13 'violentOrRepulsive' |
14 'hatefulOrAbusive' |
15 'spamOrMisleading' |
16 'privacy' |
17 'rights' |
18 'serverRules' |
19 'thumbnails' |
20 'captions'
21
22export 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/moderation/abuse/abuse-state.model.ts b/shared/models/moderation/abuse/abuse-state.model.ts
new file mode 100644
index 000000000..b00cccad8
--- /dev/null
+++ b/shared/models/moderation/abuse/abuse-state.model.ts
@@ -0,0 +1,5 @@
1export enum AbuseState {
2 PENDING = 1,
3 REJECTED = 2,
4 ACCEPTED = 3
5}
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 @@
1import { AbuseState } from './abuse-state.model'
2
3export 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..9ff150c4a
--- /dev/null
+++ b/shared/models/moderation/abuse/abuse.model.ts
@@ -0,0 +1,53 @@
1import { Account } from '../../actors/account.model'
2import { AbuseState } from './abuse-state.model'
3import { AbusePredefinedReasonsString } from './abuse-reason.model'
4import { VideoConstant } from '../../videos/video-constant.model'
5import { VideoChannel } from '../../videos/channel/video-channel.model'
6
7export interface VideoAbuse {
8 id: number
9 name: string
10 uuid: string
11 nsfw: boolean
12 deleted: boolean
13 blacklisted: boolean
14
15 startAt: number | null
16 endAt: number | null
17
18 thumbnailPath?: string
19 channel?: VideoChannel
20}
21
22export interface VideoCommentAbuse {
23 id: number
24 account?: Account
25 text: string
26 deleted: boolean
27}
28
29export interface Abuse {
30 id: number
31 reason: string
32 predefinedReasons?: AbusePredefinedReasonsString[]
33 reporterAccount: Account
34
35 state: VideoConstant<AbuseState>
36 moderationComment?: string
37
38 video?: VideoAbuse
39 comment?: VideoCommentAbuse
40
41 createdAt: Date
42 updatedAt: Date
43
44 // FIXME: deprecated in 2.3, remove this
45 startAt: null
46 endAt: null
47
48 count?: number
49 nth?: number
50
51 countReportsForReporter?: number
52 countReportsForReportee?: number
53}
diff --git a/shared/models/moderation/abuse/index.ts b/shared/models/moderation/abuse/index.ts
new file mode 100644
index 000000000..32a6b4e6c
--- /dev/null
+++ b/shared/models/moderation/abuse/index.ts
@@ -0,0 +1,6 @@
1export * from './abuse-create.model'
2export * from './abuse-reason.model'
3export * from './abuse-state.model'
4export * from './abuse-update.model'
5export * from './abuse-video-is.type'
6export * from './abuse.model'
diff --git a/shared/models/moderation/account-block.model.ts b/shared/models/moderation/account-block.model.ts
new file mode 100644
index 000000000..a942ed614
--- /dev/null
+++ b/shared/models/moderation/account-block.model.ts
@@ -0,0 +1,7 @@
1import { Account } from '../actors'
2
3export interface AccountBlock {
4 byAccount: Account
5 blockedAccount: Account
6 createdAt: Date | string
7}
diff --git a/shared/models/moderation/index.ts b/shared/models/moderation/index.ts
new file mode 100644
index 000000000..8b6042e97
--- /dev/null
+++ b/shared/models/moderation/index.ts
@@ -0,0 +1,3 @@
1export * from './abuse'
2export * from './account-block.model'
3export * from './server-block.model'
diff --git a/shared/models/moderation/server-block.model.ts b/shared/models/moderation/server-block.model.ts
new file mode 100644
index 000000000..a8b8af0b7
--- /dev/null
+++ b/shared/models/moderation/server-block.model.ts
@@ -0,0 +1,9 @@
1import { Account } from '../actors'
2
3export interface ServerBlock {
4 byAccount: Account
5 blockedServer: {
6 host: string
7 }
8 createdAt: Date | string
9}