aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/video-channel.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-20 10:13:13 +0200
committerChocobozzz <me@florianbigard.com>2018-09-20 11:45:59 +0200
commit91411dba928678c15a5e99d9795ae061909e397d (patch)
tree7ba6e340cc9eb6f993051fcac74eefd652cb0ffd /server/controllers/api/video-channel.ts
parentfcc7c060374c3a547257d96af847352c14d6144b (diff)
downloadPeerTube-91411dba928678c15a5e99d9795ae061909e397d.tar.gz
PeerTube-91411dba928678c15a5e99d9795ae061909e397d.tar.zst
PeerTube-91411dba928678c15a5e99d9795ae061909e397d.zip
Limit associations fetch when loading token
Diffstat (limited to 'server/controllers/api/video-channel.ts')
-rw-r--r--server/controllers/api/video-channel.ts9
1 files changed, 4 insertions, 5 deletions
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index 50dc44f7c..8fc340224 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -29,6 +29,7 @@ import { updateAvatarValidator } from '../../middlewares/validators/avatar'
29import { updateActorAvatarFile } from '../../lib/avatar' 29import { updateActorAvatarFile } from '../../lib/avatar'
30import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' 30import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger'
31import { resetSequelizeInstance } from '../../helpers/database-utils' 31import { resetSequelizeInstance } from '../../helpers/database-utils'
32import { UserModel } from '../../models/account/user'
32 33
33const auditLogger = auditLoggerFactory('channels') 34const auditLogger = auditLoggerFactory('channels')
34const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR }) 35const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR })
@@ -123,19 +124,17 @@ async function updateVideoChannelAvatar (req: express.Request, res: express.Resp
123 124
124async function addVideoChannel (req: express.Request, res: express.Response) { 125async function addVideoChannel (req: express.Request, res: express.Response) {
125 const videoChannelInfo: VideoChannelCreate = req.body 126 const videoChannelInfo: VideoChannelCreate = req.body
126 const account: AccountModel = res.locals.oauth.token.User.Account
127 127
128 const videoChannelCreated: VideoChannelModel = await sequelizeTypescript.transaction(async t => { 128 const videoChannelCreated: VideoChannelModel = await sequelizeTypescript.transaction(async t => {
129 const account = await AccountModel.load((res.locals.oauth.token.User as UserModel).Account.id, t)
130
129 return createVideoChannel(videoChannelInfo, account, t) 131 return createVideoChannel(videoChannelInfo, account, t)
130 }) 132 })
131 133
132 setAsyncActorKeys(videoChannelCreated.Actor) 134 setAsyncActorKeys(videoChannelCreated.Actor)
133 .catch(err => logger.error('Cannot set async actor keys for account %s.', videoChannelCreated.Actor.uuid, { err })) 135 .catch(err => logger.error('Cannot set async actor keys for account %s.', videoChannelCreated.Actor.uuid, { err }))
134 136
135 auditLogger.create( 137 auditLogger.create(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelCreated.toFormattedJSON()))
136 getAuditIdFromRes(res),
137 new VideoChannelAuditView(videoChannelCreated.toFormattedJSON())
138 )
139 logger.info('Video channel with uuid %s created.', videoChannelCreated.Actor.uuid) 138 logger.info('Video channel with uuid %s created.', videoChannelCreated.Actor.uuid)
140 139
141 return res.json({ 140 return res.json({