From 1ebddadd0704812a4600c39cabe2268321e88331 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Mon, 22 Jun 2020 13:00:39 +0200 Subject: predefined report reasons & improved reporter UI (#2842) - added `startAt` and `endAt` optional timestamps to help pin down reported sections of a video - added predefined report reasons - added video player with report modal --- shared/extra-utils/videos/video-abuses.ts | 18 ++++++++++-- shared/models/activitypub/activity.ts | 5 +++- .../models/activitypub/objects/common-objects.ts | 11 ++++++-- .../activitypub/objects/video-abuse-object.ts | 5 ++++ .../videos/abuse/video-abuse-create.model.ts | 5 ++++ .../videos/abuse/video-abuse-reason.model.ts | 33 ++++++++++++++++++++++ shared/models/videos/abuse/video-abuse.model.ts | 5 ++++ shared/models/videos/index.ts | 1 + 8 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 shared/models/videos/abuse/video-abuse-reason.model.ts (limited to 'shared') 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 @@ import * as request from 'supertest' import { VideoAbuseUpdate } from '../../models/videos/abuse/video-abuse-update.model' import { makeDeleteRequest, makePutBodyRequest, makeGetRequest } from '../requests/requests' -import { VideoAbuseState } from '@shared/models' +import { VideoAbuseState, VideoAbusePredefinedReasonsString } from '@shared/models' import { VideoAbuseVideoIs } from '@shared/models/videos/abuse/video-abuse-video-is.type' -function reportVideoAbuse (url: string, token: string, videoId: number | string, reason: string, specialStatus = 200) { +function reportVideoAbuse ( + url: string, + token: string, + videoId: number | string, + reason: string, + predefinedReasons?: VideoAbusePredefinedReasonsString[], + startAt?: number, + endAt?: number, + specialStatus = 200 +) { const path = '/api/v1/videos/' + videoId + '/abuse' return request(url) .post(path) .set('Accept', 'application/json') .set('Authorization', 'Bearer ' + token) - .send({ reason }) + .send({ reason, predefinedReasons, startAt, endAt }) .expect(specialStatus) } @@ -19,6 +28,7 @@ function getVideoAbusesList (options: { url: string token: string id?: number + predefinedReason?: VideoAbusePredefinedReasonsString search?: string state?: VideoAbuseState videoIs?: VideoAbuseVideoIs @@ -31,6 +41,7 @@ function getVideoAbusesList (options: { url, token, id, + predefinedReason, search, state, videoIs, @@ -44,6 +55,7 @@ function getVideoAbusesList (options: { const query = { sort: 'createdAt', id, + predefinedReason, search, state, 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 @@ import { ActivityPubActor } from './activitypub-actor' import { ActivityPubSignature } from './activitypub-signature' -import { CacheFileObject, VideoTorrentObject } from './objects' +import { CacheFileObject, VideoTorrentObject, ActivityFlagReasonObject } from './objects' import { DislikeObject } from './objects/dislike-object' import { VideoAbuseObject } from './objects/video-abuse-object' import { VideoCommentObject } from './objects/video-comment-object' @@ -113,4 +113,7 @@ export interface ActivityFlag extends BaseActivity { type: 'Flag' content: string object: APObject | APObject[] + tag?: ActivityFlagReasonObject[] + startAt?: number + endAt?: number } 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 @@ +import { VideoAbusePredefinedReasonsString } from '@shared/models/videos' + export interface ActivityIdentifierObject { identifier: string name: string @@ -70,17 +72,22 @@ export type ActivityHtmlUrlObject = { } export interface ActivityHashTagObject { - type: 'Hashtag' | 'Mention' + type: 'Hashtag' href?: string name: string } export interface ActivityMentionObject { - type: 'Hashtag' | 'Mention' + type: 'Mention' href?: string name: string } +export interface ActivityFlagReasonObject { + type: 'Hashtag' + name: VideoAbusePredefinedReasonsString +} + export type ActivityTagObject = ActivityPlaylistSegmentHashesObject | 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 @@ +import { ActivityFlagReasonObject } from './common-objects' + export interface VideoAbuseObject { type: 'Flag' content: string object: string | string[] + tag?: ActivityFlagReasonObject[] + startAt?: number + endAt?: number } 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 @@ +import { VideoAbusePredefinedReasonsString } from './video-abuse-reason.model' + export interface VideoAbuseCreate { reason: string + predefinedReasons?: VideoAbusePredefinedReasonsString[] + startAt?: number + endAt?: number } 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 @@ +export enum VideoAbusePredefinedReasons { + VIOLENT_OR_REPULSIVE = 1, + HATEFUL_OR_ABUSIVE, + SPAM_OR_MISLEADING, + PRIVACY, + RIGHTS, + SERVER_RULES, + THUMBNAILS, + CAPTIONS +} + +export type VideoAbusePredefinedReasonsString = + 'violentOrRepulsive' | + 'hatefulOrAbusive' | + 'spamOrMisleading' | + 'privacy' | + 'rights' | + 'serverRules' | + 'thumbnails' | + 'captions' + +export const videoAbusePredefinedReasonsMap: { + [key in VideoAbusePredefinedReasonsString]: VideoAbusePredefinedReasons +} = { + violentOrRepulsive: VideoAbusePredefinedReasons.VIOLENT_OR_REPULSIVE, + hatefulOrAbusive: VideoAbusePredefinedReasons.HATEFUL_OR_ABUSIVE, + spamOrMisleading: VideoAbusePredefinedReasons.SPAM_OR_MISLEADING, + privacy: VideoAbusePredefinedReasons.PRIVACY, + rights: VideoAbusePredefinedReasons.RIGHTS, + serverRules: VideoAbusePredefinedReasons.SERVER_RULES, + thumbnails: VideoAbusePredefinedReasons.THUMBNAILS, + captions: VideoAbusePredefinedReasons.CAPTIONS +} 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' import { VideoConstant } from '../video-constant.model' import { VideoAbuseState } from './video-abuse-state.model' import { VideoChannel } from '../channel/video-channel.model' +import { VideoAbusePredefinedReasonsString } from './video-abuse-reason.model' export interface VideoAbuse { id: number reason: string + predefinedReasons?: VideoAbusePredefinedReasonsString[] reporterAccount: Account state: VideoConstant @@ -25,6 +27,9 @@ export interface VideoAbuse { createdAt: Date updatedAt: Date + startAt: number + endAt: number + count?: number nth?: number 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' export * from './rate/user-video-rate.type' export * from './abuse/video-abuse-state.model' export * from './abuse/video-abuse-create.model' +export * from './abuse/video-abuse-reason.model' export * from './abuse/video-abuse.model' export * from './abuse/video-abuse-update.model' export * from './blacklist/video-blacklist.model' -- cgit v1.2.3