aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-29 14:31:04 +0200
committerChocobozzz <me@florianbigard.com>2019-08-29 14:31:04 +0200
commitf0a47bc92aa20b91b46197a4d3fc430aea962848 (patch)
tree104bb5dd7facc0d4db09c7deeea9e189f930e72e /server/models/video
parent3155c8606cff211f495bf71c75c56cae85a5430f (diff)
downloadPeerTube-f0a47bc92aa20b91b46197a4d3fc430aea962848.tar.gz
PeerTube-f0a47bc92aa20b91b46197a4d3fc430aea962848.tar.zst
PeerTube-f0a47bc92aa20b91b46197a4d3fc430aea962848.zip
Hide video abuses from muted accounts
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/video-abuse.ts21
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'
9import { AccountModel } from '../account/account' 9import { AccountModel } from '../account/account'
10import { getSort, throwIfNotValid } from '../utils' 10import { buildBlockedAccountSQL, getSort, throwIfNotValid } from '../utils'
11import { VideoModel } from './video' 11import { VideoModel } from './video'
12import { VideoAbuseState } from '../../../shared' 12import { VideoAbuseState } from '../../../shared'
13import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants' 13import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants'
14import { MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo } from '../../typings/models' 14import { MUserAccountId, MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo } from '../../typings/models'
15import * as Bluebird from 'bluebird' 15import * as Bluebird from 'bluebird'
16import { 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,