aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/lib/emailer.ts2
-rw-r--r--server/models/video/video-abuse.ts54
-rw-r--r--server/models/video/video.ts2
-rw-r--r--server/typings/models/video/video-abuse.ts9
4 files changed, 49 insertions, 18 deletions
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index 2c0641f3a..5a99edc7f 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -292,7 +292,7 @@ class Emailer {
292 const videoUrl = WEBSERVER.URL + videoAbuse.Video.getWatchStaticPath() 292 const videoUrl = WEBSERVER.URL + videoAbuse.Video.getWatchStaticPath()
293 293
294 const text = 'Hi,\n\n' + 294 const text = 'Hi,\n\n' +
295 `${WEBSERVER.HOST} received an abuse for the following video ${videoUrl}\n\n` + 295 `${WEBSERVER.HOST} received an abuse for the following video: ${videoUrl}\n\n` +
296 'Cheers,\n' + 296 'Cheers,\n' +
297 `${CONFIG.EMAIL.BODY.SIGNATURE}` 297 `${CONFIG.EMAIL.BODY.SIGNATURE}`
298 298
diff --git a/server/models/video/video-abuse.ts b/server/models/video/video-abuse.ts
index ea9856213..ea943ffdf 100644
--- a/server/models/video/video-abuse.ts
+++ b/server/models/video/video-abuse.ts
@@ -1,4 +1,6 @@
1import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' 1import {
2 AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt, DefaultScope
3} from 'sequelize-typescript'
2import { VideoAbuseObject } from '../../../shared/models/activitypub/objects' 4import { VideoAbuseObject } from '../../../shared/models/activitypub/objects'
3import { VideoAbuse } from '../../../shared/models/videos' 5import { VideoAbuse } from '../../../shared/models/videos'
4import { 6import {
@@ -14,7 +16,40 @@ import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/const
14import { MUserAccountId, MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo } from '../../typings/models' 16import { MUserAccountId, MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo } from '../../typings/models'
15import * as Bluebird from 'bluebird' 17import * as Bluebird from 'bluebird'
16import { literal, Op } from 'sequelize' 18import { literal, Op } from 'sequelize'
19import { ThumbnailModel } from './thumbnail'
20import { VideoChannelModel } from './video-channel'
21import { ActorModel } from '../activitypub/actor'
22import { VideoBlacklistModel } from './video-blacklist'
17 23
24@DefaultScope(() => ({
25 include: [
26 {
27 model: AccountModel,
28 required: true
29 },
30 {
31 model: VideoModel,
32 required: false,
33 include: [
34 {
35 model: ThumbnailModel
36 },
37 {
38 model: VideoChannelModel.unscoped(),
39 include: [
40 {
41 model: ActorModel
42 }
43 ]
44 },
45 {
46 attributes: [ 'id', 'reason', 'unfederated' ],
47 model: VideoBlacklistModel
48 }
49 ]
50 }
51 ]
52}))
18@Table({ 53@Table({
19 tableName: 'videoAbuse', 54 tableName: 'videoAbuse',
20 indexes: [ 55 indexes: [
@@ -114,16 +149,8 @@ export class VideoAbuseModel extends Model<VideoAbuseModel> {
114 [Op.notIn]: literal('(' + buildBlockedAccountSQL(serverAccountId, userAccountId) + ')') 149 [Op.notIn]: literal('(' + buildBlockedAccountSQL(serverAccountId, userAccountId) + ')')
115 } 150 }
116 }, 151 },
117 include: [ 152 col: 'VideoAbuseModel.id',
118 { 153 distinct: true
119 model: AccountModel,
120 required: true
121 },
122 {
123 model: VideoModel,
124 required: false
125 }
126 ]
127 } 154 }
128 155
129 return VideoAbuseModel.findAndCountAll(query) 156 return VideoAbuseModel.findAndCountAll(query)
@@ -151,7 +178,10 @@ export class VideoAbuseModel extends Model<VideoAbuseModel> {
151 uuid: video.uuid, 178 uuid: video.uuid,
152 name: video.name, 179 name: video.name,
153 nsfw: video.nsfw, 180 nsfw: video.nsfw,
154 deleted: !this.Video 181 deleted: !this.Video,
182 blacklisted: this.Video && this.Video.isBlacklisted(),
183 thumbnailPath: this.Video?.getMiniatureStaticPath(),
184 channel: this.Video?.VideoChannel.toFormattedSummaryJSON() || this.deletedVideo?.channel
155 }, 185 },
156 createdAt: this.createdAt 186 createdAt: this.createdAt
157 } 187 }
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 2636ebd8e..f32216e90 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -810,7 +810,7 @@ export class VideoModel extends Model<VideoModel> {
810 if (instance.VideoAbuses.length === 0) return undefined 810 if (instance.VideoAbuses.length === 0) return undefined
811 } 811 }
812 812
813 const details = instance.toFormattedJSON() 813 const details = instance.toFormattedDetailsJSON()
814 814
815 for (const abuse of instance.VideoAbuses) { 815 for (const abuse of instance.VideoAbuses) {
816 tasks.push((_ => { 816 tasks.push((_ => {
diff --git a/server/typings/models/video/video-abuse.ts b/server/typings/models/video/video-abuse.ts
index 49bd1ff2e..54acccdf5 100644
--- a/server/typings/models/video/video-abuse.ts
+++ b/server/typings/models/video/video-abuse.ts
@@ -1,6 +1,6 @@
1import { VideoAbuseModel } from '../../../models/video/video-abuse' 1import { VideoAbuseModel } from '../../../models/video/video-abuse'
2import { PickWith } from '../../utils' 2import { PickWith } from '../../utils'
3import { MVideo } from './video' 3import { MVideoAccountLightBlacklistAllFiles } from './video'
4import { MAccountDefault, MAccountFormattable } from '../account' 4import { MAccountDefault, MAccountFormattable } from '../account'
5 5
6type Use<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M> 6type Use<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M>
@@ -16,12 +16,12 @@ export type MVideoAbuseId = Pick<VideoAbuseModel, 'id'>
16export type MVideoAbuseVideo = 16export type MVideoAbuseVideo =
17 MVideoAbuse & 17 MVideoAbuse &
18 Pick<VideoAbuseModel, 'toActivityPubObject'> & 18 Pick<VideoAbuseModel, 'toActivityPubObject'> &
19 Use<'Video', MVideo> 19 Use<'Video', MVideoAccountLightBlacklistAllFiles>
20 20
21export type MVideoAbuseAccountVideo = 21export type MVideoAbuseAccountVideo =
22 MVideoAbuse & 22 MVideoAbuse &
23 Pick<VideoAbuseModel, 'toActivityPubObject'> & 23 Pick<VideoAbuseModel, 'toActivityPubObject'> &
24 Use<'Video', MVideo> & 24 Use<'Video', MVideoAccountLightBlacklistAllFiles> &
25 Use<'Account', MAccountDefault> 25 Use<'Account', MAccountDefault>
26 26
27// ############################################################################ 27// ############################################################################
@@ -31,4 +31,5 @@ export type MVideoAbuseAccountVideo =
31export type MVideoAbuseFormattable = 31export type MVideoAbuseFormattable =
32 MVideoAbuse & 32 MVideoAbuse &
33 Use<'Account', MAccountFormattable> & 33 Use<'Account', MAccountFormattable> &
34 Use<'Video', Pick<MVideo, 'id' | 'uuid' | 'name' | 'nsfw'>> 34 Use<'Video', Pick<MVideoAccountLightBlacklistAllFiles,
35 'id' | 'uuid' | 'name' | 'nsfw' | 'getMiniatureStaticPath' | 'isBlacklisted' | 'VideoChannel'>>