aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-abuse.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-abuse.ts')
-rw-r--r--server/models/video/video-abuse.ts18
1 files changed, 6 insertions, 12 deletions
diff --git a/server/models/video/video-abuse.ts b/server/models/video/video-abuse.ts
index d68608ca6..e8c3bd823 100644
--- a/server/models/video/video-abuse.ts
+++ b/server/models/video/video-abuse.ts
@@ -9,7 +9,7 @@ import {
9 isVideoAbuseStateValid 9 isVideoAbuseStateValid
10} from '../../helpers/custom-validators/video-abuses' 10} from '../../helpers/custom-validators/video-abuses'
11import { AccountModel } from '../account/account' 11import { AccountModel } from '../account/account'
12import { buildBlockedAccountSQL, getSort, throwIfNotValid } from '../utils' 12import { buildBlockedAccountSQL, getSort, throwIfNotValid, searchAttribute } from '../utils'
13import { VideoModel } from './video' 13import { VideoModel } from './video'
14import { VideoAbuseState, VideoDetails } from '../../../shared' 14import { VideoAbuseState, VideoDetails } from '../../../shared'
15import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants' 15import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants'
@@ -17,8 +17,8 @@ import { MUserAccountId, MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo }
17import * as Bluebird from 'bluebird' 17import * as Bluebird from 'bluebird'
18import { literal, Op } from 'sequelize' 18import { literal, Op } from 'sequelize'
19import { ThumbnailModel } from './thumbnail' 19import { ThumbnailModel } from './thumbnail'
20import { VideoChannelModel } from './video-channel'
21import { VideoBlacklistModel } from './video-blacklist' 20import { VideoBlacklistModel } from './video-blacklist'
21import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel'
22 22
23export enum ScopeNames { 23export enum ScopeNames {
24 FOR_API = 'FOR_API' 24 FOR_API = 'FOR_API'
@@ -33,12 +33,6 @@ export enum ScopeNames {
33 serverAccountId: number 33 serverAccountId: number
34 userAccountId: any 34 userAccountId: any
35 }) => { 35 }) => {
36 const search = (sourceField, targetField) => sourceField ? ({
37 [targetField]: {
38 [Op.iLike]: `%${sourceField}%`
39 }
40 }) : {}
41
42 let where = { 36 let where = {
43 reporterAccountId: { 37 reporterAccountId: {
44 [Op.notIn]: literal('(' + buildBlockedAccountSQL(options.serverAccountId, options.userAccountId) + ')') 38 [Op.notIn]: literal('(' + buildBlockedAccountSQL(options.serverAccountId, options.userAccountId) + ')')
@@ -148,19 +142,19 @@ export enum ScopeNames {
148 { 142 {
149 model: AccountModel, 143 model: AccountModel,
150 required: true, 144 required: true,
151 where: { ...search(options.searchReporter, 'name') } 145 where: { ...searchAttribute(options.searchReporter, 'name') }
152 }, 146 },
153 { 147 {
154 model: VideoModel, 148 model: VideoModel,
155 required: false, 149 required: false,
156 where: { ...search(options.searchVideo, 'name') }, 150 where: { ...searchAttribute(options.searchVideo, 'name') },
157 include: [ 151 include: [
158 { 152 {
159 model: ThumbnailModel 153 model: ThumbnailModel
160 }, 154 },
161 { 155 {
162 model: VideoChannelModel.scope([ 'WITH_ACTOR', 'WITH_ACCOUNT' ]), 156 model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, { withAccount: true } as SummaryOptions ] }),
163 where: { ...search(options.searchVideoChannel, 'name') } 157 where: { ...searchAttribute(options.searchVideoChannel, 'name') }
164 }, 158 },
165 { 159 {
166 attributes: [ 'id', 'reason', 'unfederated' ], 160 attributes: [ 'id', 'reason', 'unfederated' ],