aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/video-channel.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/video-channel.ts')
-rw-r--r--server/controllers/api/video-channel.ts25
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 @@
1import express from 'express' 1import express from 'express'
2import { pickCommonVideoQuery } from '@server/helpers/query' 2import { pickCommonVideoQuery } from '@server/helpers/query'
3import { getBiggestActorImage } from '@server/lib/actor-image'
3import { Hooks } from '@server/lib/plugins/hooks' 4import { Hooks } from '@server/lib/plugins/hooks'
4import { ActorFollowModel } from '@server/models/actor/actor-follow' 5import { ActorFollowModel } from '@server/models/actor/actor-follow'
5import { getServerActor } from '@server/models/application/application' 6import { getServerActor } from '@server/models/application/application'
@@ -11,12 +12,11 @@ import { resetSequelizeInstance } from '../../helpers/database-utils'
11import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' 12import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
12import { logger } from '../../helpers/logger' 13import { logger } from '../../helpers/logger'
13import { getFormattedObjects } from '../../helpers/utils' 14import { getFormattedObjects } from '../../helpers/utils'
14import { CONFIG } from '../../initializers/config'
15import { MIMETYPES } from '../../initializers/constants' 15import { MIMETYPES } from '../../initializers/constants'
16import { sequelizeTypescript } from '../../initializers/database' 16import { sequelizeTypescript } from '../../initializers/database'
17import { sendUpdateActor } from '../../lib/activitypub/send' 17import { sendUpdateActor } from '../../lib/activitypub/send'
18import { JobQueue } from '../../lib/job-queue' 18import { JobQueue } from '../../lib/job-queue'
19import { deleteLocalActorImageFile, updateLocalActorImageFile } from '../../lib/local-actor' 19import { deleteLocalActorImageFile, updateLocalActorImageFiles } from '../../lib/local-actor'
20import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel' 20import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel'
21import { 21import {
22 asyncMiddleware, 22 asyncMiddleware,
@@ -50,8 +50,8 @@ import { VideoChannelModel } from '../../models/video/video-channel'
50import { VideoPlaylistModel } from '../../models/video/video-playlist' 50import { VideoPlaylistModel } from '../../models/video/video-playlist'
51 51
52const auditLogger = auditLoggerFactory('channels') 52const auditLogger = auditLoggerFactory('channels')
53const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) 53const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT)
54const reqBannerFile = createReqFiles([ 'bannerfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { bannerfile: CONFIG.STORAGE.TMP_DIR }) 54const reqBannerFile = createReqFiles([ 'bannerfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT)
55 55
56const videoChannelRouter = express.Router() 56const 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
196async function updateVideoChannelAvatar (req: express.Request, res: express.Response) { 200async 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
208async function deleteVideoChannelAvatar (req: express.Request, res: express.Response) { 215async function deleteVideoChannelAvatar (req: express.Request, res: express.Response) {