diff options
Diffstat (limited to 'server/controllers/api/video-channel.ts')
-rw-r--r-- | server/controllers/api/video-channel.ts | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index e65550a22..2454b1ec9 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { pickCommonVideoQuery } from '@server/helpers/query' | 2 | import { pickCommonVideoQuery } from '@server/helpers/query' |
3 | import { getBiggestActorImage } from '@server/lib/actor-image' | ||
3 | import { Hooks } from '@server/lib/plugins/hooks' | 4 | import { Hooks } from '@server/lib/plugins/hooks' |
4 | import { ActorFollowModel } from '@server/models/actor/actor-follow' | 5 | import { ActorFollowModel } from '@server/models/actor/actor-follow' |
5 | import { getServerActor } from '@server/models/application/application' | 6 | import { getServerActor } from '@server/models/application/application' |
@@ -11,12 +12,11 @@ import { resetSequelizeInstance } from '../../helpers/database-utils' | |||
11 | import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | 12 | import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' |
12 | import { logger } from '../../helpers/logger' | 13 | import { logger } from '../../helpers/logger' |
13 | import { getFormattedObjects } from '../../helpers/utils' | 14 | import { getFormattedObjects } from '../../helpers/utils' |
14 | import { CONFIG } from '../../initializers/config' | ||
15 | import { MIMETYPES } from '../../initializers/constants' | 15 | import { MIMETYPES } from '../../initializers/constants' |
16 | import { sequelizeTypescript } from '../../initializers/database' | 16 | import { sequelizeTypescript } from '../../initializers/database' |
17 | import { sendUpdateActor } from '../../lib/activitypub/send' | 17 | import { sendUpdateActor } from '../../lib/activitypub/send' |
18 | import { JobQueue } from '../../lib/job-queue' | 18 | import { JobQueue } from '../../lib/job-queue' |
19 | import { deleteLocalActorImageFile, updateLocalActorImageFile } from '../../lib/local-actor' | 19 | import { deleteLocalActorImageFile, updateLocalActorImageFiles } from '../../lib/local-actor' |
20 | import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel' | 20 | import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel' |
21 | import { | 21 | import { |
22 | asyncMiddleware, | 22 | asyncMiddleware, |
@@ -50,8 +50,8 @@ import { VideoChannelModel } from '../../models/video/video-channel' | |||
50 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 50 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
51 | 51 | ||
52 | const auditLogger = auditLoggerFactory('channels') | 52 | const auditLogger = auditLoggerFactory('channels') |
53 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) | 53 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT) |
54 | const reqBannerFile = createReqFiles([ 'bannerfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { bannerfile: CONFIG.STORAGE.TMP_DIR }) | 54 | const reqBannerFile = createReqFiles([ 'bannerfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT) |
55 | 55 | ||
56 | const videoChannelRouter = express.Router() | 56 | const videoChannelRouter = express.Router() |
57 | 57 | ||
@@ -186,11 +186,15 @@ async function updateVideoChannelBanner (req: express.Request, res: express.Resp | |||
186 | const videoChannel = res.locals.videoChannel | 186 | const videoChannel = res.locals.videoChannel |
187 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) | 187 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) |
188 | 188 | ||
189 | const banner = await updateLocalActorImageFile(videoChannel, bannerPhysicalFile, ActorImageType.BANNER) | 189 | const banners = await updateLocalActorImageFiles(videoChannel, bannerPhysicalFile, ActorImageType.BANNER) |
190 | 190 | ||
191 | auditLogger.update(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys) | 191 | auditLogger.update(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys) |
192 | 192 | ||
193 | return res.json({ banner: banner.toFormattedJSON() }) | 193 | return res.json({ |
194 | // TODO: remove, deprecated in 4.2 | ||
195 | banner: getBiggestActorImage(banners).toFormattedJSON(), | ||
196 | banners: banners.map(b => b.toFormattedJSON()) | ||
197 | }) | ||
194 | } | 198 | } |
195 | 199 | ||
196 | async function updateVideoChannelAvatar (req: express.Request, res: express.Response) { | 200 | async function updateVideoChannelAvatar (req: express.Request, res: express.Response) { |
@@ -198,11 +202,14 @@ async function updateVideoChannelAvatar (req: express.Request, res: express.Resp | |||
198 | const videoChannel = res.locals.videoChannel | 202 | const videoChannel = res.locals.videoChannel |
199 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) | 203 | const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON()) |
200 | 204 | ||
201 | const avatar = await updateLocalActorImageFile(videoChannel, avatarPhysicalFile, ActorImageType.AVATAR) | 205 | const avatars = await updateLocalActorImageFiles(videoChannel, avatarPhysicalFile, ActorImageType.AVATAR) |
202 | |||
203 | auditLogger.update(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys) | 206 | auditLogger.update(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys) |
204 | 207 | ||
205 | return res.json({ avatar: avatar.toFormattedJSON() }) | 208 | return res.json({ |
209 | // TODO: remove, deprecated in 4.2 | ||
210 | avatar: getBiggestActorImage(avatars).toFormattedJSON(), | ||
211 | avatars: avatars.map(a => a.toFormattedJSON()) | ||
212 | }) | ||
206 | } | 213 | } |
207 | 214 | ||
208 | async function deleteVideoChannelAvatar (req: express.Request, res: express.Response) { | 215 | async function deleteVideoChannelAvatar (req: express.Request, res: express.Response) { |