diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-05-03 16:16:10 +0200 |
---|---|---|
committer | Rigel Kent <par@rigelk.eu> | 2020-05-04 15:01:44 +0200 |
commit | 9b1fa49b6032c149d8a848da086f60e52bd4b82a (patch) | |
tree | 04495fe9c15e32c85d52f5cc621cb18662101335 /server/models/video/video-abuse.ts | |
parent | 7f979fd8aa76bd930d601d33b61eae39b8f5d90d (diff) | |
download | PeerTube-9b1fa49b6032c149d8a848da086f60e52bd4b82a.tar.gz PeerTube-9b1fa49b6032c149d8a848da086f60e52bd4b82a.tar.zst PeerTube-9b1fa49b6032c149d8a848da086f60e52bd4b82a.zip |
Support is:blacklisted as video-abuse-list filter
Diffstat (limited to 'server/models/video/video-abuse.ts')
-rw-r--r-- | server/models/video/video-abuse.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/server/models/video/video-abuse.ts b/server/models/video/video-abuse.ts index b1f8fed90..f6b546825 100644 --- a/server/models/video/video-abuse.ts +++ b/server/models/video/video-abuse.ts | |||
@@ -90,10 +90,13 @@ export enum ScopeNames { | |||
90 | }) | 90 | }) |
91 | } | 91 | } |
92 | 92 | ||
93 | if (options.is) { | 93 | let onlyBlacklisted = false |
94 | if (options.is === "deleted") { | ||
94 | where = Object.assign(where, { | 95 | where = Object.assign(where, { |
95 | ...options.is | 96 | deletedVideo: { [Op.not]: null } |
96 | }) | 97 | }) |
98 | } else if (options.is === "blacklisted") { | ||
99 | onlyBlacklisted = true | ||
97 | } | 100 | } |
98 | 101 | ||
99 | return { | 102 | return { |
@@ -184,7 +187,7 @@ export enum ScopeNames { | |||
184 | }, | 187 | }, |
185 | { | 188 | { |
186 | model: VideoModel, | 189 | model: VideoModel, |
187 | required: false, | 190 | required: onlyBlacklisted, |
188 | where: searchAttribute(options.searchVideo, 'name'), | 191 | where: searchAttribute(options.searchVideo, 'name'), |
189 | include: [ | 192 | include: [ |
190 | { | 193 | { |
@@ -202,7 +205,8 @@ export enum ScopeNames { | |||
202 | }, | 205 | }, |
203 | { | 206 | { |
204 | attributes: [ 'id', 'reason', 'unfederated' ], | 207 | attributes: [ 'id', 'reason', 'unfederated' ], |
205 | model: VideoBlacklistModel | 208 | model: VideoBlacklistModel, |
209 | required: onlyBlacklisted | ||
206 | } | 210 | } |
207 | ] | 211 | ] |
208 | } | 212 | } |
@@ -328,7 +332,8 @@ export class VideoAbuseModel extends Model<VideoAbuseModel> { | |||
328 | is: { | 332 | is: { |
329 | prefix: 'is:', | 333 | prefix: 'is:', |
330 | handler: v => { | 334 | handler: v => { |
331 | if (v === "deleted") return { deletedVideo: { [Op.not]: null } } | 335 | if (v === "deleted") return v |
336 | if (v === "blacklisted") return v | ||
332 | return undefined | 337 | return undefined |
333 | } | 338 | } |
334 | }, | 339 | }, |