diff options
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video-abuse.ts | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/server/models/video/video-abuse.ts b/server/models/video/video-abuse.ts index 6ef1a915d..3636db18d 100644 --- a/server/models/video/video-abuse.ts +++ b/server/models/video/video-abuse.ts | |||
@@ -7,12 +7,13 @@ import { | |||
7 | isVideoAbuseStateValid | 7 | isVideoAbuseStateValid |
8 | } from '../../helpers/custom-validators/video-abuses' | 8 | } from '../../helpers/custom-validators/video-abuses' |
9 | import { AccountModel } from '../account/account' | 9 | import { AccountModel } from '../account/account' |
10 | import { getSort, throwIfNotValid } from '../utils' | 10 | import { buildBlockedAccountSQL, getSort, throwIfNotValid } from '../utils' |
11 | import { VideoModel } from './video' | 11 | import { VideoModel } from './video' |
12 | import { VideoAbuseState } from '../../../shared' | 12 | import { VideoAbuseState } from '../../../shared' |
13 | import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants' | 13 | import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants' |
14 | import { MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo } from '../../typings/models' | 14 | import { MUserAccountId, MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo } from '../../typings/models' |
15 | import * as Bluebird from 'bluebird' | 15 | import * as Bluebird from 'bluebird' |
16 | import { literal, Op } from 'sequelize' | ||
16 | 17 | ||
17 | @Table({ | 18 | @Table({ |
18 | tableName: 'videoAbuse', | 19 | tableName: 'videoAbuse', |
@@ -85,11 +86,25 @@ export class VideoAbuseModel extends Model<VideoAbuseModel> { | |||
85 | return VideoAbuseModel.findOne(query) | 86 | return VideoAbuseModel.findOne(query) |
86 | } | 87 | } |
87 | 88 | ||
88 | static listForApi (start: number, count: number, sort: string) { | 89 | static listForApi (parameters: { |
90 | start: number, | ||
91 | count: number, | ||
92 | sort: string, | ||
93 | serverAccountId: number | ||
94 | user?: MUserAccountId | ||
95 | }) { | ||
96 | const { start, count, sort, user, serverAccountId } = parameters | ||
97 | const userAccountId = user ? user.Account.id : undefined | ||
98 | |||
89 | const query = { | 99 | const query = { |
90 | offset: start, | 100 | offset: start, |
91 | limit: count, | 101 | limit: count, |
92 | order: getSort(sort), | 102 | order: getSort(sort), |
103 | where: { | ||
104 | reporterAccountId: { | ||
105 | [Op.notIn]: literal('(' + buildBlockedAccountSQL(serverAccountId, userAccountId) + ')') | ||
106 | } | ||
107 | }, | ||
93 | include: [ | 108 | include: [ |
94 | { | 109 | { |
95 | model: AccountModel, | 110 | model: AccountModel, |