diff options
author | Josh Morel <morel.josh@hotmail.com> | 2019-04-02 05:26:47 -0400 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-04-02 11:26:47 +0200 |
commit | 7ccddd7b5250bd25a917a6e77e58b87b9484a2a4 (patch) | |
tree | e75dc991369c1768804fefa114eb2a832881087f /server/models | |
parent | 12fed49ebab0c414713d57ea316b6488ae6bef99 (diff) | |
download | PeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.tar.gz PeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.tar.zst PeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.zip |
add quarantine videos feature (#1637)
* add quarantine videos feature
* increase Notification settings test timeout
to 20000ms. was completing 7000 locally but timing out
after 10000 on travis
* fix quarantine video test issues
-propagate misspelling
-remove skip from server/tests/client.ts
* WIP use blacklist for moderator video approval
instead of video.quarantine boolean
* finish auto-blacklist feature
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/account/user-notification-setting.ts | 10 | ||||
-rw-r--r-- | server/models/video/schedule-video-update.ts | 3 | ||||
-rw-r--r-- | server/models/video/video-blacklist.ts | 56 |
3 files changed, 49 insertions, 20 deletions
diff --git a/server/models/account/user-notification-setting.ts b/server/models/account/user-notification-setting.ts index f1c3ac223..ba7f739b9 100644 --- a/server/models/account/user-notification-setting.ts +++ b/server/models/account/user-notification-setting.ts | |||
@@ -59,6 +59,15 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM | |||
59 | @AllowNull(false) | 59 | @AllowNull(false) |
60 | @Default(null) | 60 | @Default(null) |
61 | @Is( | 61 | @Is( |
62 | 'UserNotificationSettingVideoAutoBlacklistAsModerator', | ||
63 | value => throwIfNotValid(value, isUserNotificationSettingValid, 'videoAutoBlacklistAsModerator') | ||
64 | ) | ||
65 | @Column | ||
66 | videoAutoBlacklistAsModerator: UserNotificationSettingValue | ||
67 | |||
68 | @AllowNull(false) | ||
69 | @Default(null) | ||
70 | @Is( | ||
62 | 'UserNotificationSettingBlacklistOnMyVideo', | 71 | 'UserNotificationSettingBlacklistOnMyVideo', |
63 | value => throwIfNotValid(value, isUserNotificationSettingValid, 'blacklistOnMyVideo') | 72 | value => throwIfNotValid(value, isUserNotificationSettingValid, 'blacklistOnMyVideo') |
64 | ) | 73 | ) |
@@ -139,6 +148,7 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM | |||
139 | newCommentOnMyVideo: this.newCommentOnMyVideo, | 148 | newCommentOnMyVideo: this.newCommentOnMyVideo, |
140 | newVideoFromSubscription: this.newVideoFromSubscription, | 149 | newVideoFromSubscription: this.newVideoFromSubscription, |
141 | videoAbuseAsModerator: this.videoAbuseAsModerator, | 150 | videoAbuseAsModerator: this.videoAbuseAsModerator, |
151 | videoAutoBlacklistAsModerator: this.videoAutoBlacklistAsModerator, | ||
142 | blacklistOnMyVideo: this.blacklistOnMyVideo, | 152 | blacklistOnMyVideo: this.blacklistOnMyVideo, |
143 | myVideoPublished: this.myVideoPublished, | 153 | myVideoPublished: this.myVideoPublished, |
144 | myVideoImportFinished: this.myVideoImportFinished, | 154 | myVideoImportFinished: this.myVideoImportFinished, |
diff --git a/server/models/video/schedule-video-update.ts b/server/models/video/schedule-video-update.ts index 1e56562e1..abddc1111 100644 --- a/server/models/video/schedule-video-update.ts +++ b/server/models/video/schedule-video-update.ts | |||
@@ -72,7 +72,8 @@ export class ScheduleVideoUpdateModel extends Model<ScheduleVideoUpdateModel> { | |||
72 | model: VideoModel.scope( | 72 | model: VideoModel.scope( |
73 | [ | 73 | [ |
74 | VideoScopeNames.WITH_FILES, | 74 | VideoScopeNames.WITH_FILES, |
75 | VideoScopeNames.WITH_ACCOUNT_DETAILS | 75 | VideoScopeNames.WITH_ACCOUNT_DETAILS, |
76 | VideoScopeNames.WITH_BLACKLISTED | ||
76 | ] | 77 | ] |
77 | ) | 78 | ) |
78 | } | 79 | } |
diff --git a/server/models/video/video-blacklist.ts b/server/models/video/video-blacklist.ts index 3b567e488..86b1f6acb 100644 --- a/server/models/video/video-blacklist.ts +++ b/server/models/video/video-blacklist.ts | |||
@@ -1,8 +1,21 @@ | |||
1 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' | 1 | import { |
2 | AllowNull, | ||
3 | BelongsTo, | ||
4 | Column, | ||
5 | CreatedAt, | ||
6 | DataType, | ||
7 | Default, | ||
8 | ForeignKey, | ||
9 | Is, Model, | ||
10 | Table, | ||
11 | UpdatedAt, | ||
12 | IFindOptions | ||
13 | } from 'sequelize-typescript' | ||
2 | import { getSortOnModel, SortType, throwIfNotValid } from '../utils' | 14 | import { getSortOnModel, SortType, throwIfNotValid } from '../utils' |
3 | import { VideoModel } from './video' | 15 | import { VideoModel } from './video' |
4 | import { isVideoBlacklistReasonValid } from '../../helpers/custom-validators/video-blacklist' | 16 | import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel' |
5 | import { VideoBlacklist } from '../../../shared/models/videos' | 17 | import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist' |
18 | import { VideoBlacklist, VideoBlacklistType } from '../../../shared/models/videos' | ||
6 | import { CONSTRAINTS_FIELDS } from '../../initializers' | 19 | import { CONSTRAINTS_FIELDS } from '../../initializers' |
7 | 20 | ||
8 | @Table({ | 21 | @Table({ |
@@ -25,6 +38,12 @@ export class VideoBlacklistModel extends Model<VideoBlacklistModel> { | |||
25 | @Column | 38 | @Column |
26 | unfederated: boolean | 39 | unfederated: boolean |
27 | 40 | ||
41 | @AllowNull(false) | ||
42 | @Default(null) | ||
43 | @Is('VideoBlacklistType', value => throwIfNotValid(value, isVideoBlacklistTypeValid, 'type')) | ||
44 | @Column | ||
45 | type: VideoBlacklistType | ||
46 | |||
28 | @CreatedAt | 47 | @CreatedAt |
29 | createdAt: Date | 48 | createdAt: Date |
30 | 49 | ||
@@ -43,19 +62,29 @@ export class VideoBlacklistModel extends Model<VideoBlacklistModel> { | |||
43 | }) | 62 | }) |
44 | Video: VideoModel | 63 | Video: VideoModel |
45 | 64 | ||
46 | static listForApi (start: number, count: number, sort: SortType) { | 65 | static listForApi (start: number, count: number, sort: SortType, type?: VideoBlacklistType) { |
47 | const query = { | 66 | const query: IFindOptions<VideoBlacklistModel> = { |
48 | offset: start, | 67 | offset: start, |
49 | limit: count, | 68 | limit: count, |
50 | order: getSortOnModel(sort.sortModel, sort.sortValue), | 69 | order: getSortOnModel(sort.sortModel, sort.sortValue), |
51 | include: [ | 70 | include: [ |
52 | { | 71 | { |
53 | model: VideoModel, | 72 | model: VideoModel, |
54 | required: true | 73 | required: true, |
74 | include: [ | ||
75 | { | ||
76 | model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, true ] }), | ||
77 | required: true | ||
78 | } | ||
79 | ] | ||
55 | } | 80 | } |
56 | ] | 81 | ] |
57 | } | 82 | } |
58 | 83 | ||
84 | if (type) { | ||
85 | query.where = { type } | ||
86 | } | ||
87 | |||
59 | return VideoBlacklistModel.findAndCountAll(query) | 88 | return VideoBlacklistModel.findAndCountAll(query) |
60 | .then(({ rows, count }) => { | 89 | .then(({ rows, count }) => { |
61 | return { | 90 | return { |
@@ -76,26 +105,15 @@ export class VideoBlacklistModel extends Model<VideoBlacklistModel> { | |||
76 | } | 105 | } |
77 | 106 | ||
78 | toFormattedJSON (): VideoBlacklist { | 107 | toFormattedJSON (): VideoBlacklist { |
79 | const video = this.Video | ||
80 | |||
81 | return { | 108 | return { |
82 | id: this.id, | 109 | id: this.id, |
83 | createdAt: this.createdAt, | 110 | createdAt: this.createdAt, |
84 | updatedAt: this.updatedAt, | 111 | updatedAt: this.updatedAt, |
85 | reason: this.reason, | 112 | reason: this.reason, |
86 | unfederated: this.unfederated, | 113 | unfederated: this.unfederated, |
114 | type: this.type, | ||
87 | 115 | ||
88 | video: { | 116 | video: this.Video.toFormattedJSON() |
89 | id: video.id, | ||
90 | name: video.name, | ||
91 | uuid: video.uuid, | ||
92 | description: video.description, | ||
93 | duration: video.duration, | ||
94 | views: video.views, | ||
95 | likes: video.likes, | ||
96 | dislikes: video.dislikes, | ||
97 | nsfw: video.nsfw | ||
98 | } | ||
99 | } | 117 | } |
100 | } | 118 | } |
101 | } | 119 | } |