diff options
author | Chocobozzz <me@florianbigard.com> | 2020-07-27 16:26:25 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-07-31 11:35:19 +0200 |
commit | 594d3e48d8a887bbf48ce4cc594c1c36c9640fb1 (patch) | |
tree | bae28fa6215a3a3c6ccd78aea6ea7e75c500a96f /server/models/abuse | |
parent | 94148c9028829b5576a5dcbfba2c7fb9cf6443d3 (diff) | |
download | PeerTube-594d3e48d8a887bbf48ce4cc594c1c36c9640fb1.tar.gz PeerTube-594d3e48d8a887bbf48ce4cc594c1c36c9640fb1.tar.zst PeerTube-594d3e48d8a887bbf48ce4cc594c1c36c9640fb1.zip |
Add abuse messages/states notifications
Diffstat (limited to 'server/models/abuse')
-rw-r--r-- | server/models/abuse/abuse.ts | 54 |
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' |
34 | import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants' | 34 | import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants' |
35 | import { MAbuse, MAbuseAdminFormattable, MAbuseAP, MAbuseReporter, MAbuseUserFormattable, MUserAccountId } from '../../types/models' | 35 | import { MAbuseAdminFormattable, MAbuseAP, MAbuseFull, MAbuseReporter, MAbuseUserFormattable, MUserAccountId } from '../../types/models' |
36 | import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account' | 36 | import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account' |
37 | import { getSort, throwIfNotValid } from '../utils' | 37 | import { getSort, throwIfNotValid } from '../utils' |
38 | import { ThumbnailModel } from '../video/thumbnail' | 38 | import { ThumbnailModel } from '../video/thumbnail' |
39 | import { VideoModel } from '../video/video' | 39 | import { ScopeNames as VideoScopeNames, VideoModel } from '../video/video' |
40 | import { VideoBlacklistModel } from '../video/video-blacklist' | 40 | import { VideoBlacklistModel } from '../video/video-blacklist' |
41 | import { ScopeNames as VideoChannelScopeNames, SummaryOptions as ChannelSummaryOptions, VideoChannelModel } from '../video/video-channel' | 41 | import { ScopeNames as VideoChannelScopeNames, SummaryOptions as ChannelSummaryOptions, VideoChannelModel } from '../video/video-channel' |
42 | import { VideoCommentModel } from '../video/video-comment' | 42 | import { ScopeNames as CommentScopeNames, VideoCommentModel } from '../video/video-comment' |
43 | import { buildAbuseListQuery, BuildAbusesQueryOptions } from './abuse-query-builder' | 43 | import { buildAbuseListQuery, BuildAbusesQueryOptions } from './abuse-query-builder' |
44 | import { VideoAbuseModel } from './video-abuse' | 44 | import { VideoAbuseModel } from './video-abuse' |
45 | import { VideoCommentAbuseModel } from './video-comment-abuse' | 45 | import { 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 | ||