diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-27 14:37:04 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-10-29 11:48:21 +0200 |
commit | 2760b454a761f6af3138b2fb5f34340772ab0d1e (patch) | |
tree | 2b3a2d81478f8b432eb54cce4caa5a760c494627 /server/models/video/sql/shared/abstract-videos-model-query-builder.ts | |
parent | e4611b54910d8e7f2b4f8a97ee2d9cc8e1054127 (diff) | |
download | PeerTube-2760b454a761f6af3138b2fb5f34340772ab0d1e.tar.gz PeerTube-2760b454a761f6af3138b2fb5f34340772ab0d1e.tar.zst PeerTube-2760b454a761f6af3138b2fb5f34340772ab0d1e.zip |
Deprecate filter video query
Introduce include and isLocal instead
Diffstat (limited to 'server/models/video/sql/shared/abstract-videos-model-query-builder.ts')
-rw-r--r-- | server/models/video/sql/shared/abstract-videos-model-query-builder.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/server/models/video/sql/shared/abstract-videos-model-query-builder.ts b/server/models/video/sql/shared/abstract-videos-model-query-builder.ts index 0d7e64574..29827db2a 100644 --- a/server/models/video/sql/shared/abstract-videos-model-query-builder.ts +++ b/server/models/video/sql/shared/abstract-videos-model-query-builder.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | import { createSafeIn } from '@server/models/utils' | ||
2 | import { MUserAccountId } from '@server/types/models' | ||
1 | import validator from 'validator' | 3 | import validator from 'validator' |
2 | import { AbstractVideosQueryBuilder } from './abstract-videos-query-builder' | 4 | import { AbstractVideosQueryBuilder } from './abstract-videos-query-builder' |
3 | import { VideoTables } from './video-tables' | 5 | import { VideoTables } from './video-tables' |
@@ -188,6 +190,32 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder | |||
188 | } | 190 | } |
189 | } | 191 | } |
190 | 192 | ||
193 | protected includeBlockedOwnerAndServer (serverAccountId: number, user?: MUserAccountId) { | ||
194 | const blockerIds = [ serverAccountId ] | ||
195 | if (user) blockerIds.push(user.Account.id) | ||
196 | |||
197 | const inClause = createSafeIn(this.sequelize, blockerIds) | ||
198 | |||
199 | this.addJoin( | ||
200 | 'LEFT JOIN "accountBlocklist" AS "VideoChannel->Account->AccountBlocklist" ' + | ||
201 | 'ON "VideoChannel->Account"."id" = "VideoChannel->Account->AccountBlocklist"."targetAccountId" ' + | ||
202 | 'AND "VideoChannel->Account->AccountBlocklist"."accountId" IN (' + inClause + ')' | ||
203 | ) | ||
204 | |||
205 | this.addJoin( | ||
206 | 'LEFT JOIN "serverBlocklist" AS "VideoChannel->Account->Actor->Server->ServerBlocklist" ' + | ||
207 | 'ON "VideoChannel->Account->Actor->Server->ServerBlocklist"."targetServerId" = "VideoChannel->Account->Actor"."serverId" ' + | ||
208 | 'AND "VideoChannel->Account->Actor->Server->ServerBlocklist"."accountId" IN (' + inClause + ') ' | ||
209 | ) | ||
210 | |||
211 | this.attributes = { | ||
212 | ...this.attributes, | ||
213 | |||
214 | ...this.buildAttributesObject('VideoChannel->Account->AccountBlocklist', this.tables.getBlocklistAttributes()), | ||
215 | ...this.buildAttributesObject('VideoChannel->Account->Actor->Server->ServerBlocklist', this.tables.getBlocklistAttributes()) | ||
216 | } | ||
217 | } | ||
218 | |||
191 | protected includeScheduleUpdate () { | 219 | protected includeScheduleUpdate () { |
192 | this.addJoin( | 220 | this.addJoin( |
193 | 'LEFT OUTER JOIN "scheduleVideoUpdate" AS "ScheduleVideoUpdate" ON "video"."id" = "ScheduleVideoUpdate"."videoId"' | 221 | 'LEFT OUTER JOIN "scheduleVideoUpdate" AS "ScheduleVideoUpdate" ON "video"."id" = "ScheduleVideoUpdate"."videoId"' |