From f479685678406a5df864d89615b33d29085ebfc6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Apr 2021 11:35:56 +0200 Subject: Agnostic actor image storage --- server/models/video/video-channel.ts | 5 +++-- server/models/video/video-query-builder.ts | 5 +++-- server/models/video/video.ts | 10 ++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'server/models/video') diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 178878c55..815fb16c0 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -36,9 +36,9 @@ import { MChannelSummaryFormattable } from '../../types/models/video' import { AccountModel, ScopeNames as AccountModelScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account' +import { ActorImageModel } from '../account/actor-image' import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' import { ActorFollowModel } from '../activitypub/actor-follow' -import { AvatarModel } from '../avatar/avatar' import { ServerModel } from '../server/server' import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' import { VideoModel } from './video' @@ -130,7 +130,8 @@ export type SummaryOptions = { required: false }, { - model: AvatarModel.unscoped(), + model: ActorImageModel.unscoped(), + as: 'Avatar', required: false } ] diff --git a/server/models/video/video-query-builder.ts b/server/models/video/video-query-builder.ts index 96df0a7f8..4d95ddee2 100644 --- a/server/models/video/video-query-builder.ts +++ b/server/models/video/video-query-builder.ts @@ -490,12 +490,13 @@ function wrapForAPIResults (baseQuery: string, replacements: any, options: Build 'INNER JOIN "actor" AS "VideoChannel->Account->Actor" ON "VideoChannel->Account"."actorId" = "VideoChannel->Account->Actor"."id"', 'LEFT OUTER JOIN "server" AS "VideoChannel->Actor->Server" ON "VideoChannel->Actor"."serverId" = "VideoChannel->Actor->Server"."id"', - 'LEFT OUTER JOIN "avatar" AS "VideoChannel->Actor->Avatar" ON "VideoChannel->Actor"."avatarId" = "VideoChannel->Actor->Avatar"."id"', + 'LEFT OUTER JOIN "actorImage" AS "VideoChannel->Actor->Avatar" ' + + 'ON "VideoChannel->Actor"."avatarId" = "VideoChannel->Actor->Avatar"."id"', 'LEFT OUTER JOIN "server" AS "VideoChannel->Account->Actor->Server" ' + 'ON "VideoChannel->Account->Actor"."serverId" = "VideoChannel->Account->Actor->Server"."id"', - 'LEFT OUTER JOIN "avatar" AS "VideoChannel->Account->Actor->Avatar" ' + + 'LEFT OUTER JOIN "actorImage" AS "VideoChannel->Account->Actor->Avatar" ' + 'ON "VideoChannel->Account->Actor"."avatarId" = "VideoChannel->Account->Actor->Avatar"."id"', 'LEFT OUTER JOIN "thumbnail" AS "Thumbnails" ON "video"."id" = "Thumbnails"."videoId"' diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 9d89efa5b..086269921 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -100,10 +100,10 @@ import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../types/models import { VideoAbuseModel } from '../abuse/video-abuse' import { AccountModel } from '../account/account' import { AccountVideoRateModel } from '../account/account-video-rate' +import { ActorImageModel } from '../account/actor-image' import { UserModel } from '../account/user' import { UserVideoHistoryModel } from '../account/user-video-history' import { ActorModel } from '../activitypub/actor' -import { AvatarModel } from '../avatar/avatar' import { VideoRedundancyModel } from '../redundancy/video-redundancy' import { ServerModel } from '../server/server' import { TrackerModel } from '../server/tracker' @@ -286,7 +286,8 @@ export type AvailableForListIDsOptions = { required: false }, { - model: AvatarModel.unscoped(), + model: ActorImageModel.unscoped(), + as: 'Avatar', required: false } ] @@ -308,7 +309,8 @@ export type AvailableForListIDsOptions = { required: false }, { - model: AvatarModel.unscoped(), + model: ActorImageModel.unscoped(), + as: 'Avatar', required: false } ] @@ -1703,7 +1705,7 @@ export class VideoModel extends Model { function buildActor (rowActor: any) { const avatarModel = rowActor.Avatar.id !== null - ? new AvatarModel(pick(rowActor.Avatar, avatarKeys), buildOpts) + ? new ActorImageModel(pick(rowActor.Avatar, avatarKeys), buildOpts) : null const serverModel = rowActor.Server.id !== null -- cgit v1.2.3