aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/abuse/abuse.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-07-27 16:26:25 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-07-31 11:35:19 +0200
commit594d3e48d8a887bbf48ce4cc594c1c36c9640fb1 (patch)
treebae28fa6215a3a3c6ccd78aea6ea7e75c500a96f /server/models/abuse/abuse.ts
parent94148c9028829b5576a5dcbfba2c7fb9cf6443d3 (diff)
downloadPeerTube-594d3e48d8a887bbf48ce4cc594c1c36c9640fb1.tar.gz
PeerTube-594d3e48d8a887bbf48ce4cc594c1c36c9640fb1.tar.zst
PeerTube-594d3e48d8a887bbf48ce4cc594c1c36c9640fb1.zip
Add abuse messages/states notifications
Diffstat (limited to 'server/models/abuse/abuse.ts')
-rw-r--r--server/models/abuse/abuse.ts54
1 files changed, 50 insertions, 4 deletions
diff --git a/server/models/abuse/abuse.ts b/server/models/abuse/abuse.ts
index 3353e9e41..1b599db62 100644
--- a/server/models/abuse/abuse.ts
+++ b/server/models/abuse/abuse.ts
@@ -32,14 +32,14 @@ import {
32 UserVideoAbuse 32 UserVideoAbuse
33} from '@shared/models' 33} from '@shared/models'
34import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants' 34import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants'
35import { MAbuse, MAbuseAdminFormattable, MAbuseAP, MAbuseReporter, MAbuseUserFormattable, MUserAccountId } from '../../types/models' 35import { MAbuseAdminFormattable, MAbuseAP, MAbuseFull, MAbuseReporter, MAbuseUserFormattable, MUserAccountId } from '../../types/models'
36import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account' 36import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account'
37import { getSort, throwIfNotValid } from '../utils' 37import { getSort, throwIfNotValid } from '../utils'
38import { ThumbnailModel } from '../video/thumbnail' 38import { ThumbnailModel } from '../video/thumbnail'
39import { VideoModel } from '../video/video' 39import { ScopeNames as VideoScopeNames, VideoModel } from '../video/video'
40import { VideoBlacklistModel } from '../video/video-blacklist' 40import { VideoBlacklistModel } from '../video/video-blacklist'
41import { ScopeNames as VideoChannelScopeNames, SummaryOptions as ChannelSummaryOptions, VideoChannelModel } from '../video/video-channel' 41import { ScopeNames as VideoChannelScopeNames, SummaryOptions as ChannelSummaryOptions, VideoChannelModel } from '../video/video-channel'
42import { VideoCommentModel } from '../video/video-comment' 42import { ScopeNames as CommentScopeNames, VideoCommentModel } from '../video/video-comment'
43import { buildAbuseListQuery, BuildAbusesQueryOptions } from './abuse-query-builder' 43import { buildAbuseListQuery, BuildAbusesQueryOptions } from './abuse-query-builder'
44import { VideoAbuseModel } from './video-abuse' 44import { VideoAbuseModel } from './video-abuse'
45import { VideoCommentAbuseModel } from './video-comment-abuse' 45import { VideoCommentAbuseModel } from './video-comment-abuse'
@@ -307,6 +307,52 @@ export class AbuseModel extends Model<AbuseModel> {
307 return AbuseModel.findOne(query) 307 return AbuseModel.findOne(query)
308 } 308 }
309 309
310 static loadFull (id: number): Bluebird<MAbuseFull> {
311 const query = {
312 where: {
313 id
314 },
315 include: [
316 {
317 model: AccountModel.scope(AccountScopeNames.SUMMARY),
318 required: false,
319 as: 'ReporterAccount'
320 },
321 {
322 model: AccountModel.scope(AccountScopeNames.SUMMARY),
323 as: 'FlaggedAccount'
324 },
325 {
326 model: VideoAbuseModel,
327 required: false,
328 include: [
329 {
330 model: VideoModel.scope([ VideoScopeNames.WITH_ACCOUNT_DETAILS ])
331 }
332 ]
333 },
334 {
335 model: VideoCommentAbuseModel,
336 required: false,
337 include: [
338 {
339 model: VideoCommentModel.scope([
340 CommentScopeNames.WITH_ACCOUNT
341 ]),
342 include: [
343 {
344 model: VideoModel
345 }
346 ]
347 }
348 ]
349 }
350 ]
351 }
352
353 return AbuseModel.findOne(query)
354 }
355
310 static async listForAdminApi (parameters: { 356 static async listForAdminApi (parameters: {
311 start: number 357 start: number
312 count: number 358 count: number
@@ -455,7 +501,7 @@ export class AbuseModel extends Model<AbuseModel> {
455 blacklisted: abuseModel.Video?.isBlacklisted() || false, 501 blacklisted: abuseModel.Video?.isBlacklisted() || false,
456 thumbnailPath: abuseModel.Video?.getMiniatureStaticPath(), 502 thumbnailPath: abuseModel.Video?.getMiniatureStaticPath(),
457 503
458 channel: abuseModel.Video?.VideoChannel.toFormattedJSON() || abuseModel.deletedVideo?.channel, 504 channel: abuseModel.Video?.VideoChannel.toFormattedJSON() || abuseModel.deletedVideo?.channel
459 } 505 }
460 } 506 }
461 507