diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-04-17 10:47:22 +0200 |
---|---|---|
committer | Rigel Kent <par@rigelk.eu> | 2020-05-01 16:41:02 +0200 |
commit | 86521a67b2edb06a139b095e489c205457eaba8f (patch) | |
tree | 3a0106ab146c3d8436ce502a43d38838800c4595 /server | |
parent | 9b4241e33bf46c4f0468565ce41ca7f810b2dbfa (diff) | |
download | PeerTube-86521a67b2edb06a139b095e489c205457eaba8f.tar.gz PeerTube-86521a67b2edb06a139b095e489c205457eaba8f.tar.zst PeerTube-86521a67b2edb06a139b095e489c205457eaba8f.zip |
Add video channel and video thumbnail, rework video appearance in row
Diffstat (limited to 'server')
-rw-r--r-- | server/lib/emailer.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-abuse.ts | 54 | ||||
-rw-r--r-- | server/models/video/video.ts | 2 | ||||
-rw-r--r-- | server/typings/models/video/video-abuse.ts | 9 |
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 @@ | |||
1 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' | 1 | import { |
2 | AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt, DefaultScope | ||
3 | } from 'sequelize-typescript' | ||
2 | import { VideoAbuseObject } from '../../../shared/models/activitypub/objects' | 4 | import { VideoAbuseObject } from '../../../shared/models/activitypub/objects' |
3 | import { VideoAbuse } from '../../../shared/models/videos' | 5 | import { VideoAbuse } from '../../../shared/models/videos' |
4 | import { | 6 | import { |
@@ -14,7 +16,40 @@ import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/const | |||
14 | import { MUserAccountId, MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo } from '../../typings/models' | 16 | import { MUserAccountId, MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo } from '../../typings/models' |
15 | import * as Bluebird from 'bluebird' | 17 | import * as Bluebird from 'bluebird' |
16 | import { literal, Op } from 'sequelize' | 18 | import { literal, Op } from 'sequelize' |
19 | import { ThumbnailModel } from './thumbnail' | ||
20 | import { VideoChannelModel } from './video-channel' | ||
21 | import { ActorModel } from '../activitypub/actor' | ||
22 | import { 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 @@ | |||
1 | import { VideoAbuseModel } from '../../../models/video/video-abuse' | 1 | import { VideoAbuseModel } from '../../../models/video/video-abuse' |
2 | import { PickWith } from '../../utils' | 2 | import { PickWith } from '../../utils' |
3 | import { MVideo } from './video' | 3 | import { MVideoAccountLightBlacklistAllFiles } from './video' |
4 | import { MAccountDefault, MAccountFormattable } from '../account' | 4 | import { MAccountDefault, MAccountFormattable } from '../account' |
5 | 5 | ||
6 | type Use<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M> | 6 | type Use<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M> |
@@ -16,12 +16,12 @@ export type MVideoAbuseId = Pick<VideoAbuseModel, 'id'> | |||
16 | export type MVideoAbuseVideo = | 16 | export type MVideoAbuseVideo = |
17 | MVideoAbuse & | 17 | MVideoAbuse & |
18 | Pick<VideoAbuseModel, 'toActivityPubObject'> & | 18 | Pick<VideoAbuseModel, 'toActivityPubObject'> & |
19 | Use<'Video', MVideo> | 19 | Use<'Video', MVideoAccountLightBlacklistAllFiles> |
20 | 20 | ||
21 | export type MVideoAbuseAccountVideo = | 21 | export 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 = | |||
31 | export type MVideoAbuseFormattable = | 31 | export 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'>> | ||