From 2760b454a761f6af3138b2fb5f34340772ab0d1e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 27 Oct 2021 14:37:04 +0200 Subject: Deprecate filter video query Introduce include and isLocal instead --- server/models/account/account.ts | 6 +- server/models/server/server.ts | 4 +- server/models/user/user-video-history.ts | 10 ++- .../models/video/formatter/video-format-utils.ts | 68 +++++++++++------ .../shared/abstract-videos-model-query-builder.ts | 28 +++++++ .../models/video/sql/shared/video-model-builder.ts | 72 +++++++++++++++--- server/models/video/sql/shared/video-tables.ts | 4 + .../video/sql/video-model-get-query-builder.ts | 6 +- .../video/sql/videos-id-list-query-builder.ts | 60 +++++++++------ .../video/sql/videos-model-list-query-builder.ts | 11 ++- server/models/video/video.ts | 86 ++++++++-------------- 11 files changed, 238 insertions(+), 117 deletions(-) (limited to 'server/models') diff --git a/server/models/account/account.ts b/server/models/account/account.ts index 37194a119..056ec6857 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -228,10 +228,10 @@ export class AccountModel extends Model>> { name: 'targetAccountId', allowNull: false }, - as: 'BlockedAccounts', + as: 'BlockedBy', onDelete: 'CASCADE' }) - BlockedAccounts: AccountBlocklistModel[] + BlockedBy: AccountBlocklistModel[] @BeforeDestroy static async sendDeleteIfOwned (instance: AccountModel, options) { @@ -457,6 +457,6 @@ export class AccountModel extends Model>> { } isBlocked () { - return this.BlockedAccounts && this.BlockedAccounts.length !== 0 + return this.BlockedBy && this.BlockedBy.length !== 0 } } diff --git a/server/models/server/server.ts b/server/models/server/server.ts index 0d3c092e0..edbe92f73 100644 --- a/server/models/server/server.ts +++ b/server/models/server/server.ts @@ -50,7 +50,7 @@ export class ServerModel extends Model>> { }, onDelete: 'CASCADE' }) - BlockedByAccounts: ServerBlocklistModel[] + BlockedBy: ServerBlocklistModel[] static load (id: number, transaction?: Transaction): Promise { const query = { @@ -81,7 +81,7 @@ export class ServerModel extends Model>> { } isBlocked () { - return this.BlockedByAccounts && this.BlockedByAccounts.length !== 0 + return this.BlockedBy && this.BlockedBy.length !== 0 } toFormattedJSON (this: MServerFormattable) { diff --git a/server/models/user/user-video-history.ts b/server/models/user/user-video-history.ts index e3dc4a062..d633cc9d5 100644 --- a/server/models/user/user-video-history.ts +++ b/server/models/user/user-video-history.ts @@ -4,6 +4,7 @@ import { MUserAccountId, MUserId } from '@server/types/models' import { AttributesOnly } from '@shared/core-utils' import { VideoModel } from '../video/video' import { UserModel } from './user' +import { getServerActor } from '../application/application' @Table({ tableName: 'userVideoHistory', @@ -56,14 +57,19 @@ export class UserVideoHistoryModel extends ModelAccount->AccountBlocklist" ' + + 'ON "VideoChannel->Account"."id" = "VideoChannel->Account->AccountBlocklist"."targetAccountId" ' + + 'AND "VideoChannel->Account->AccountBlocklist"."accountId" IN (' + inClause + ')' + ) + + this.addJoin( + 'LEFT JOIN "serverBlocklist" AS "VideoChannel->Account->Actor->Server->ServerBlocklist" ' + + 'ON "VideoChannel->Account->Actor->Server->ServerBlocklist"."targetServerId" = "VideoChannel->Account->Actor"."serverId" ' + + 'AND "VideoChannel->Account->Actor->Server->ServerBlocklist"."accountId" IN (' + inClause + ') ' + ) + + this.attributes = { + ...this.attributes, + + ...this.buildAttributesObject('VideoChannel->Account->AccountBlocklist', this.tables.getBlocklistAttributes()), + ...this.buildAttributesObject('VideoChannel->Account->Actor->Server->ServerBlocklist', this.tables.getBlocklistAttributes()) + } + } + protected includeScheduleUpdate () { this.addJoin( 'LEFT OUTER JOIN "scheduleVideoUpdate" AS "ScheduleVideoUpdate" ON "video"."id" = "ScheduleVideoUpdate"."videoId"' diff --git a/server/models/video/sql/shared/video-model-builder.ts b/server/models/video/sql/shared/video-model-builder.ts index 33a0181e9..0eac95661 100644 --- a/server/models/video/sql/shared/video-model-builder.ts +++ b/server/models/video/sql/shared/video-model-builder.ts @@ -1,11 +1,14 @@ import { AccountModel } from '@server/models/account/account' +import { AccountBlocklistModel } from '@server/models/account/account-blocklist' import { ActorModel } from '@server/models/actor/actor' import { ActorImageModel } from '@server/models/actor/actor-image' import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' import { ServerModel } from '@server/models/server/server' +import { ServerBlocklistModel } from '@server/models/server/server-blocklist' import { TrackerModel } from '@server/models/server/tracker' import { UserVideoHistoryModel } from '@server/models/user/user-video-history' +import { VideoInclude } from '@shared/models' import { ScheduleVideoUpdateModel } from '../../schedule-video-update' import { TagModel } from '../../tag' import { ThumbnailModel } from '../../thumbnail' @@ -33,6 +36,8 @@ export class VideoModelBuilder { private thumbnailsDone: Set private historyDone: Set private blacklistDone: Set + private accountBlocklistDone: Set + private serverBlocklistDone: Set private liveDone: Set private redundancyDone: Set private scheduleVideoUpdateDone: Set @@ -51,7 +56,14 @@ export class VideoModelBuilder { } - buildVideosFromRows (rows: SQLRow[], rowsWebTorrentFiles?: SQLRow[], rowsStreamingPlaylist?: SQLRow[]) { + buildVideosFromRows (options: { + rows: SQLRow[] + include?: VideoInclude + rowsWebTorrentFiles?: SQLRow[] + rowsStreamingPlaylist?: SQLRow[] + }) { + const { rows, rowsWebTorrentFiles, rowsStreamingPlaylist, include } = options + this.reinit() for (const row of rows) { @@ -77,6 +89,15 @@ export class VideoModelBuilder { this.setBlacklisted(row, videoModel) this.setScheduleVideoUpdate(row, videoModel) this.setLive(row, videoModel) + } else { + if (include & VideoInclude.BLACKLISTED) { + this.setBlacklisted(row, videoModel) + } + + if (include & VideoInclude.BLOCKED_OWNER) { + this.setBlockedOwner(row, videoModel) + this.setBlockedServer(row, videoModel) + } } } @@ -91,15 +112,18 @@ export class VideoModelBuilder { this.videoStreamingPlaylistMemo = {} this.videoFileMemo = {} - this.thumbnailsDone = new Set() - this.historyDone = new Set() - this.blacklistDone = new Set() - this.liveDone = new Set() - this.redundancyDone = new Set() - this.scheduleVideoUpdateDone = new Set() + this.thumbnailsDone = new Set() + this.historyDone = new Set() + this.blacklistDone = new Set() + this.liveDone = new Set() + this.redundancyDone = new Set() + this.scheduleVideoUpdateDone = new Set() + + this.accountBlocklistDone = new Set() + this.serverBlocklistDone = new Set() - this.trackersDone = new Set() - this.tagsDone = new Set() + this.trackersDone = new Set() + this.tagsDone = new Set() this.videos = [] } @@ -162,6 +186,8 @@ export class VideoModelBuilder { const accountModel = new AccountModel(this.grab(row, this.tables.getAccountAttributes(), 'VideoChannel.Account'), this.buildOpts) accountModel.Actor = this.buildActor(row, 'VideoChannel.Account') + accountModel.BlockedBy = [] + channelModel.Account = accountModel videoModel.VideoChannel = channelModel @@ -180,6 +206,8 @@ export class VideoModelBuilder { ? new ServerModel(this.grab(row, this.tables.getServerAttributes(), serverPrefix), this.buildOpts) : null + if (serverModel) serverModel.BlockedBy = [] + const actorModel = new ActorModel(this.grab(row, this.tables.getActorAttributes(), actorPrefix), this.buildOpts) actorModel.Avatar = avatarModel actorModel.Server = serverModel @@ -297,6 +325,32 @@ export class VideoModelBuilder { this.blacklistDone.add(id) } + private setBlockedOwner (row: SQLRow, videoModel: VideoModel) { + const id = row['VideoChannel.Account.AccountBlocklist.id'] + if (!id) return + + const key = `${videoModel.id}-${id}` + if (this.accountBlocklistDone.has(key)) return + + const attributes = this.grab(row, this.tables.getBlocklistAttributes(), 'VideoChannel.Account.AccountBlocklist') + videoModel.VideoChannel.Account.BlockedBy.push(new AccountBlocklistModel(attributes, this.buildOpts)) + + this.accountBlocklistDone.add(key) + } + + private setBlockedServer (row: SQLRow, videoModel: VideoModel) { + const id = row['VideoChannel.Account.Actor.Server.ServerBlocklist.id'] + if (!id || this.serverBlocklistDone.has(id)) return + + const key = `${videoModel.id}-${id}` + if (this.serverBlocklistDone.has(key)) return + + const attributes = this.grab(row, this.tables.getBlocklistAttributes(), 'VideoChannel.Account.Actor.Server.ServerBlocklist') + videoModel.VideoChannel.Account.Actor.Server.BlockedBy.push(new ServerBlocklistModel(attributes, this.buildOpts)) + + this.serverBlocklistDone.add(key) + } + private setScheduleVideoUpdate (row: SQLRow, videoModel: VideoModel) { const id = row['ScheduleVideoUpdate.id'] if (!id || this.scheduleVideoUpdateDone.has(id)) return diff --git a/server/models/video/sql/shared/video-tables.ts b/server/models/video/sql/shared/video-tables.ts index 75823864d..042b9d5da 100644 --- a/server/models/video/sql/shared/video-tables.ts +++ b/server/models/video/sql/shared/video-tables.ts @@ -139,6 +139,10 @@ export class VideoTables { return [ 'id', 'reason', 'unfederated' ] } + getBlocklistAttributes () { + return [ 'id' ] + } + getScheduleUpdateAttributes () { return [ 'id', diff --git a/server/models/video/sql/video-model-get-query-builder.ts b/server/models/video/sql/video-model-get-query-builder.ts index f234e8778..d18ddae67 100644 --- a/server/models/video/sql/video-model-get-query-builder.ts +++ b/server/models/video/sql/video-model-get-query-builder.ts @@ -62,7 +62,11 @@ export class VideosModelGetQueryBuilder { : Promise.resolve(undefined) ]) - const videos = this.videoModelBuilder.buildVideosFromRows(videoRows, webtorrentFilesRows, streamingPlaylistFilesRows) + const videos = this.videoModelBuilder.buildVideosFromRows({ + rows: videoRows, + rowsWebTorrentFiles: webtorrentFilesRows, + rowsStreamingPlaylist: streamingPlaylistFilesRows + }) if (videos.length > 1) { throw new Error('Video results is more than ') diff --git a/server/models/video/sql/videos-id-list-query-builder.ts b/server/models/video/sql/videos-id-list-query-builder.ts index 7625c003d..3eb547e75 100644 --- a/server/models/video/sql/videos-id-list-query-builder.ts +++ b/server/models/video/sql/videos-id-list-query-builder.ts @@ -4,7 +4,7 @@ import { exists } from '@server/helpers/custom-validators/misc' import { WEBSERVER } from '@server/initializers/constants' import { buildDirectionAndField, createSafeIn } from '@server/models/utils' import { MUserAccountId, MUserId } from '@server/types/models' -import { VideoFilter, VideoPrivacy, VideoState } from '@shared/models' +import { VideoInclude, VideoPrivacy, VideoState } from '@shared/models' import { AbstractVideosQueryBuilder } from './shared/abstract-videos-query-builder' /** @@ -13,21 +13,27 @@ import { AbstractVideosQueryBuilder } from './shared/abstract-videos-query-build * */ +export type DisplayOnlyForFollowerOptions = { + actorId: number + orLocalVideos: boolean +} + export type BuildVideosListQueryOptions = { attributes?: string[] - serverAccountId: number - followerActorId: number - includeLocalVideos: boolean + serverAccountIdForBlock: number + + displayOnlyForFollower: DisplayOnlyForFollowerOptions count: number start: number sort: string nsfw?: boolean - filter?: VideoFilter host?: string isLive?: boolean + isLocal?: boolean + include?: VideoInclude categoryOneOf?: number[] licenceOneOf?: number[] @@ -101,6 +107,7 @@ export class VideosIdListQueryBuilder extends AbstractVideosQueryBuilder { getIdsListQueryAndSort (options: BuildVideosListQueryOptions) { this.buildIdsListQuery(options) + return { query: this.query, sort: this.sort, replacements: this.replacements } } @@ -116,23 +123,30 @@ export class VideosIdListQueryBuilder extends AbstractVideosQueryBuilder { 'INNER JOIN "actor" "accountActor" ON "account"."actorId" = "accountActor"."id"' ]) - this.whereNotBlacklisted() + if (!(options.include & VideoInclude.BLACKLISTED)) { + this.whereNotBlacklisted() + } - if (options.serverAccountId) { - this.whereNotBlocked(options.serverAccountId, options.user) + if (options.serverAccountIdForBlock && !(options.include & VideoInclude.BLOCKED_OWNER)) { + this.whereNotBlocked(options.serverAccountIdForBlock, options.user) } - // Only list public/published videos - if (!options.filter || (options.filter !== 'all-local' && options.filter !== 'all')) { - this.whereStateAndPrivacyAvailable(options.user) + // Only list published videos + if (!(options.include & VideoInclude.NOT_PUBLISHED_STATE)) { + this.whereStateAvailable() + } + + // Only list videos with the appropriate priavcy + if (!(options.include & VideoInclude.HIDDEN_PRIVACY)) { + this.wherePrivacyAvailable(options.user) } if (options.videoPlaylistId) { this.joinPlaylist(options.videoPlaylistId) } - if (options.filter && (options.filter === 'local' || options.filter === 'all-local')) { - this.whereOnlyLocal() + if (exists(options.isLocal)) { + this.whereLocal(options.isLocal) } if (options.host) { @@ -147,8 +161,8 @@ export class VideosIdListQueryBuilder extends AbstractVideosQueryBuilder { this.whereChannelId(options.videoChannelId) } - if (options.followerActorId) { - this.whereFollowerActorId(options.followerActorId, options.includeLocalVideos) + if (options.displayOnlyForFollower) { + this.whereFollowerActorId(options.displayOnlyForFollower) } if (options.withFiles === true) { @@ -282,12 +296,14 @@ export class VideosIdListQueryBuilder extends AbstractVideosQueryBuilder { this.replacements.videoPlaylistId = playlistId } - private whereStateAndPrivacyAvailable (user?: MUserAccountId) { + private whereStateAvailable () { this.and.push( `("video"."state" = ${VideoState.PUBLISHED} OR ` + `("video"."state" = ${VideoState.TO_TRANSCODE} AND "video"."waitTranscoding" IS false))` ) + } + private wherePrivacyAvailable (user?: MUserAccountId) { if (user) { this.and.push( `("video"."privacy" = ${VideoPrivacy.PUBLIC} OR "video"."privacy" = ${VideoPrivacy.INTERNAL})` @@ -299,8 +315,10 @@ export class VideosIdListQueryBuilder extends AbstractVideosQueryBuilder { } } - private whereOnlyLocal () { - this.and.push('"video"."remote" IS FALSE') + private whereLocal (isLocal: boolean) { + const isRemote = isLocal ? 'FALSE' : 'TRUE' + + this.and.push('"video"."remote" IS ' + isRemote) } private whereHost (host: string) { @@ -326,7 +344,7 @@ export class VideosIdListQueryBuilder extends AbstractVideosQueryBuilder { this.replacements.videoChannelId = channelId } - private whereFollowerActorId (followerActorId: number, includeLocalVideos: boolean) { + private whereFollowerActorId (options: { actorId: number, orLocalVideos: boolean }) { let query = '(' + ' EXISTS (' + // Videos shared by actors we follow @@ -342,14 +360,14 @@ export class VideosIdListQueryBuilder extends AbstractVideosQueryBuilder { ' AND "actorFollow"."state" = \'accepted\'' + ' )' - if (includeLocalVideos) { + if (options.orLocalVideos) { query += ' OR "video"."remote" IS FALSE' } query += ')' this.and.push(query) - this.replacements.followerActorId = followerActorId + this.replacements.followerActorId = options.actorId } private whereFileExists () { diff --git a/server/models/video/sql/videos-model-list-query-builder.ts b/server/models/video/sql/videos-model-list-query-builder.ts index e61c51de8..ef92bd2b0 100644 --- a/server/models/video/sql/videos-model-list-query-builder.ts +++ b/server/models/video/sql/videos-model-list-query-builder.ts @@ -1,3 +1,4 @@ +import { VideoInclude } from '@shared/models' import { Sequelize } from 'sequelize' import { AbstractVideosModelQueryBuilder } from './shared/abstract-videos-model-query-builder' import { VideoModelBuilder } from './shared/video-model-builder' @@ -28,7 +29,7 @@ export class VideosModelListQueryBuilder extends AbstractVideosModelQueryBuilder this.buildListQueryFromIdsQuery(options) return this.runQuery() - .then(rows => this.videoModelBuilder.buildVideosFromRows(rows)) + .then(rows => this.videoModelBuilder.buildVideosFromRows({ rows, include: options.include })) } private buildInnerQuery (options: BuildVideosListQueryOptions) { @@ -64,6 +65,14 @@ export class VideosModelListQueryBuilder extends AbstractVideosModelQueryBuilder this.includePlaylist(options.videoPlaylistId) } + if (options.include & VideoInclude.BLACKLISTED) { + this.includeBlacklisted() + } + + if (options.include & VideoInclude.BLOCKED_OWNER) { + this.includeBlockedOwnerAndServer(options.serverAccountIdForBlock, options.user) + } + const select = this.buildSelect() this.query = `${select} FROM (${this.innerQuery}) AS "tmp" ${this.joins} ${this.innerSort}` diff --git a/server/models/video/video.ts b/server/models/video/video.ts index b5c46c86c..26be34329 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -34,12 +34,12 @@ import { VideoPathManager } from '@server/lib/video-path-manager' import { getServerActor } from '@server/models/application/application' import { ModelCache } from '@server/models/model-cache' import { AttributesOnly, buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils' +import { VideoInclude } from '@shared/models' import { VideoFile } from '@shared/models/videos/video-file.model' import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared' import { VideoObject } from '../../../shared/models/activitypub/objects' import { Video, VideoDetails, VideoRateType, VideoStorage } from '../../../shared/models/videos' import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type' -import { VideoFilter } from '../../../shared/models/videos/video-query.type' import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' import { peertubeTruncate } from '../../helpers/core-utils' import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' @@ -106,7 +106,7 @@ import { } from './formatter/video-format-utils' import { ScheduleVideoUpdateModel } from './schedule-video-update' import { VideosModelGetQueryBuilder } from './sql/video-model-get-query-builder' -import { BuildVideosListQueryOptions, VideosIdListQueryBuilder } from './sql/videos-id-list-query-builder' +import { BuildVideosListQueryOptions, DisplayOnlyForFollowerOptions, VideosIdListQueryBuilder } from './sql/videos-id-list-query-builder' import { VideosModelListQueryBuilder } from './sql/videos-model-list-query-builder' import { TagModel } from './tag' import { ThumbnailModel } from './thumbnail' @@ -145,35 +145,6 @@ export type ForAPIOptions = { withAccountBlockerIds?: number[] } -export type AvailableForListIDsOptions = { - serverAccountId: number - followerActorId: number - includeLocalVideos: boolean - - attributesType?: 'none' | 'id' | 'all' - - filter?: VideoFilter - categoryOneOf?: number[] - nsfw?: boolean - licenceOneOf?: number[] - languageOneOf?: string[] - tagsOneOf?: string[] - tagsAllOf?: string[] - - withFiles?: boolean - - accountId?: number - videoChannelId?: number - - videoPlaylistId?: number - - trendingDays?: number - user?: MUserAccountId - historyOfUser?: MUserId - - baseWhere?: WhereOptions[] -} - @Scopes(() => ({ [ScopeNames.WITH_IMMUTABLE_ATTRIBUTES]: { attributes: [ 'id', 'url', 'uuid', 'remote' ] @@ -1054,10 +1025,10 @@ export class VideoModel extends Model>> { sort: string nsfw: boolean - filter?: VideoFilter isLive?: boolean + isLocal?: boolean + include?: VideoInclude - includeLocalVideos: boolean withFiles: boolean categoryOneOf?: number[] @@ -1069,7 +1040,7 @@ export class VideoModel extends Model>> { accountId?: number videoChannelId?: number - followerActorId?: number + displayOnlyForFollower: DisplayOnlyForFollowerOptions | null videoPlaylistId?: number @@ -1082,7 +1053,7 @@ export class VideoModel extends Model>> { search?: string }) { - if ((options.filter === 'all-local' || options.filter === 'all') && !options.user.hasRight(UserRight.SEE_ALL_VIDEOS)) { + if (options.include && !options.user.hasRight(UserRight.SEE_ALL_VIDEOS)) { throw new Error('Try to filter all-local but no user has not the see all videos right') } @@ -1096,11 +1067,6 @@ export class VideoModel extends Model>> { const serverActor = await getServerActor() - // followerActorId === null has a meaning, so just check undefined - const followerActorId = options.followerActorId !== undefined - ? options.followerActorId - : serverActor.id - const queryOptions = { ...pick(options, [ 'start', @@ -1113,19 +1079,19 @@ export class VideoModel extends Model>> { 'languageOneOf', 'tagsOneOf', 'tagsAllOf', - 'filter', + 'isLocal', + 'include', + 'displayOnlyForFollower', 'withFiles', 'accountId', 'videoChannelId', 'videoPlaylistId', - 'includeLocalVideos', 'user', 'historyOfUser', 'search' ]), - followerActorId, - serverAccountId: serverActor.Account.id, + serverAccountIdForBlock: serverActor.Account.id, trendingDays, trendingAlgorithm } @@ -1137,7 +1103,6 @@ export class VideoModel extends Model>> { start: number count: number sort: string - includeLocalVideos: boolean search?: string host?: string startDate?: string // ISO 8601 @@ -1146,6 +1111,8 @@ export class VideoModel extends Model>> { originallyPublishedEndDate?: string nsfw?: boolean isLive?: boolean + isLocal?: boolean + include?: VideoInclude categoryOneOf?: number[] licenceOneOf?: number[] languageOneOf?: string[] @@ -1154,14 +1121,14 @@ export class VideoModel extends Model>> { durationMin?: number // seconds durationMax?: number // seconds user?: MUserAccountId - filter?: VideoFilter uuids?: string[] + displayOnlyForFollower: DisplayOnlyForFollowerOptions | null }) { const serverActor = await getServerActor() const queryOptions = { ...pick(options, [ - 'includeLocalVideos', + 'include', 'nsfw', 'isLive', 'categoryOneOf', @@ -1170,7 +1137,7 @@ export class VideoModel extends Model>> { 'tagsOneOf', 'tagsAllOf', 'user', - 'filter', + 'isLocal', 'host', 'start', 'count', @@ -1182,11 +1149,10 @@ export class VideoModel extends Model>> { 'durationMin', 'durationMax', 'uuids', - 'search' + 'search', + 'displayOnlyForFollower' ]), - - followerActorId: serverActor.id, - serverAccountId: serverActor.Account.id + serverAccountIdForBlock: serverActor.Account.id } return VideoModel.getAvailableForApi(queryOptions) @@ -1369,12 +1335,17 @@ export class VideoModel extends Model>> { // Sequelize could return null... if (!totalLocalVideoViews) totalLocalVideoViews = 0 + const serverActor = await getServerActor() + const { total: totalVideos } = await VideoModel.listForApi({ start: 0, count: 0, sort: '-publishedAt', nsfw: buildNSFWFilter(), - includeLocalVideos: true, + displayOnlyForFollower: { + actorId: serverActor.id, + orLocalVideos: true + }, withFiles: false }) @@ -1455,7 +1426,6 @@ export class VideoModel extends Model>> { // threshold corresponds to how many video the field should have to be returned static async getRandomFieldSamples (field: 'category' | 'channelId', threshold: number, count: number) { const serverActor = await getServerActor() - const followerActorId = serverActor.id const queryOptions: BuildVideosListQueryOptions = { attributes: [ `"${field}"` ], @@ -1464,9 +1434,11 @@ export class VideoModel extends Model>> { start: 0, sort: 'random', count, - serverAccountId: serverActor.Account.id, - followerActorId, - includeLocalVideos: true + serverAccountIdForBlock: serverActor.Account.id, + displayOnlyForFollower: { + actorId: serverActor.id, + orLocalVideos: true + } } const queryBuilder = new VideosIdListQueryBuilder(VideoModel.sequelize) -- cgit v1.2.3