mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
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
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { VideoAbusePredefinedReasonsString } from './video-abuse-reason.model'
|
||||
|
||||
export interface VideoAbuseCreate {
|
||||
reason: string
|
||||
predefinedReasons?: VideoAbusePredefinedReasonsString[]
|
||||
startAt?: number
|
||||
endAt?: number
|
||||
}
|
||||
|
||||
33
shared/models/videos/abuse/video-abuse-reason.model.ts
Normal file
33
shared/models/videos/abuse/video-abuse-reason.model.ts
Normal file
@@ -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
|
||||
}
|
||||
@@ -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<VideoAbuseState>
|
||||
@@ -25,6 +27,9 @@ export interface VideoAbuse {
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
|
||||
startAt: number
|
||||
endAt: number
|
||||
|
||||
count?: number
|
||||
nth?: number
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user