diff options
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"' |