1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02: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:
Rigel Kent 2020-06-22 13:00:39 +02:00 committed by GitHub
parent 07aea1a264
commit 1ebddadd07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 658 additions and 96 deletions

View file

@ -1,4 +1,9 @@
import { ActivityCreate, ActivityFlag, VideoAbuseState } from '../../../../shared'
import {
ActivityCreate,
ActivityFlag,
VideoAbuseState,
videoAbusePredefinedReasonsMap
} from '../../../../shared'
import { VideoAbuseObject } from '../../../../shared/models/activitypub/objects'
import { retryTransactionWrapper } from '../../../helpers/database-utils'
import { logger } from '../../../helpers/logger'
@ -38,13 +43,21 @@ async function processCreateVideoAbuse (activity: ActivityCreate | ActivityFlag,
const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: object })
const reporterAccount = await sequelizeTypescript.transaction(async t => AccountModel.load(account.id, t))
const tags = Array.isArray(flag.tag) ? flag.tag : []
const predefinedReasons = tags.map(tag => videoAbusePredefinedReasonsMap[tag.name])
.filter(v => !isNaN(v))
const startAt = flag.startAt
const endAt = flag.endAt
const videoAbuseInstance = await sequelizeTypescript.transaction(async t => {
const videoAbuseData = {
reporterAccountId: account.id,
reason: flag.content,
videoId: video.id,
state: VideoAbuseState.PENDING
state: VideoAbuseState.PENDING,
predefinedReasons,
startAt,
endAt
}
const videoAbuseInstance: MVideoAbuseAccountVideo = await VideoAbuseModel.create(videoAbuseData, { transaction: t })