From d95d15598847c7f020aa056e7e6e0c02d2bbf732 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 1 Jul 2020 16:05:30 +0200 Subject: Use 3 tables to represent abuses --- .../models/moderation/abuse/abuse-create.model.ts | 26 +++++++++++ shared/models/moderation/abuse/abuse-filter.ts | 1 + .../models/moderation/abuse/abuse-reason.model.ts | 33 ++++++++++++++ .../models/moderation/abuse/abuse-state.model.ts | 5 ++ .../models/moderation/abuse/abuse-update.model.ts | 7 +++ .../models/moderation/abuse/abuse-video-is.type.ts | 1 + shared/models/moderation/abuse/abuse.model.ts | 53 ++++++++++++++++++++++ shared/models/moderation/abuse/index.ts | 6 +++ shared/models/moderation/account-block.model.ts | 7 +++ shared/models/moderation/index.ts | 3 ++ shared/models/moderation/server-block.model.ts | 9 ++++ 11 files changed, 151 insertions(+) create mode 100644 shared/models/moderation/abuse/abuse-create.model.ts create mode 100644 shared/models/moderation/abuse/abuse-filter.ts create mode 100644 shared/models/moderation/abuse/abuse-reason.model.ts create mode 100644 shared/models/moderation/abuse/abuse-state.model.ts create mode 100644 shared/models/moderation/abuse/abuse-update.model.ts create mode 100644 shared/models/moderation/abuse/abuse-video-is.type.ts create mode 100644 shared/models/moderation/abuse/abuse.model.ts create mode 100644 shared/models/moderation/abuse/index.ts create mode 100644 shared/models/moderation/account-block.model.ts create mode 100644 shared/models/moderation/index.ts create mode 100644 shared/models/moderation/server-block.model.ts (limited to 'shared/models/moderation') 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 @@ +import { AbusePredefinedReasonsString } from './abuse-reason.model' + +export interface AbuseCreate { + accountId: number + + reason: string + predefinedReasons?: AbusePredefinedReasonsString[] + + video?: { + id: number + startAt?: number + endAt?: number + } + + comment?: { + id: number + } +} + +// FIXME: deprecated in 2.3. Remove it +export interface VideoAbuseCreate { + reason: string + predefinedReasons?: AbusePredefinedReasonsString[] + startAt?: number + endAt?: number +} 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 @@ +export enum AbusePredefinedReasons { + VIOLENT_OR_REPULSIVE = 1, + HATEFUL_OR_ABUSIVE, + SPAM_OR_MISLEADING, + PRIVACY, + RIGHTS, + SERVER_RULES, + THUMBNAILS, + CAPTIONS +} + +export type AbusePredefinedReasonsString = + 'violentOrRepulsive' | + 'hatefulOrAbusive' | + 'spamOrMisleading' | + 'privacy' | + 'rights' | + 'serverRules' | + 'thumbnails' | + 'captions' + +export const abusePredefinedReasonsMap: { + [key in AbusePredefinedReasonsString]: AbusePredefinedReasons +} = { + violentOrRepulsive: AbusePredefinedReasons.VIOLENT_OR_REPULSIVE, + hatefulOrAbusive: AbusePredefinedReasons.HATEFUL_OR_ABUSIVE, + spamOrMisleading: AbusePredefinedReasons.SPAM_OR_MISLEADING, + privacy: AbusePredefinedReasons.PRIVACY, + rights: AbusePredefinedReasons.RIGHTS, + serverRules: AbusePredefinedReasons.SERVER_RULES, + thumbnails: AbusePredefinedReasons.THUMBNAILS, + captions: AbusePredefinedReasons.CAPTIONS +} 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 @@ +export enum AbuseState { + PENDING = 1, + REJECTED = 2, + 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 @@ +import { AbuseState } from './abuse-state.model' + +export interface AbuseUpdate { + moderationComment?: string + + state?: AbuseState +} 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 @@ +import { Account } from '../../actors/account.model' +import { AbuseState } from './abuse-state.model' +import { AbusePredefinedReasonsString } from './abuse-reason.model' +import { VideoConstant } from '../../videos/video-constant.model' +import { VideoChannel } from '../../videos/channel/video-channel.model' + +export interface VideoAbuse { + id: number + name: string + uuid: string + nsfw: boolean + deleted: boolean + blacklisted: boolean + + startAt: number | null + endAt: number | null + + thumbnailPath?: string + channel?: VideoChannel +} + +export interface VideoCommentAbuse { + id: number + account?: Account + text: string + deleted: boolean +} + +export interface Abuse { + id: number + reason: string + predefinedReasons?: AbusePredefinedReasonsString[] + reporterAccount: Account + + state: VideoConstant + moderationComment?: string + + video?: VideoAbuse + comment?: VideoCommentAbuse + + createdAt: Date + updatedAt: Date + + // FIXME: deprecated in 2.3, remove this + startAt: null + endAt: null + + count?: number + nth?: number + + countReportsForReporter?: number + countReportsForReportee?: number +} 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 @@ +export * from './abuse-create.model' +export * from './abuse-reason.model' +export * from './abuse-state.model' +export * from './abuse-update.model' +export * from './abuse-video-is.type' +export * 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 @@ +import { Account } from '../actors' + +export interface AccountBlock { + byAccount: Account + blockedAccount: Account + createdAt: Date | string +} 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 @@ +export * from './abuse' +export * from './account-block.model' +export * 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 @@ +import { Account } from '../actors' + +export interface ServerBlock { + byAccount: Account + blockedServer: { + host: string + } + createdAt: Date | string +} -- cgit v1.2.3