diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-20 10:13:13 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-09-20 11:45:59 +0200 |
commit | 91411dba928678c15a5e99d9795ae061909e397d (patch) | |
tree | 7ba6e340cc9eb6f993051fcac74eefd652cb0ffd /server/controllers/api/video-channel.ts | |
parent | fcc7c060374c3a547257d96af847352c14d6144b (diff) | |
download | PeerTube-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.ts | 9 |
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' | |||
29 | import { updateActorAvatarFile } from '../../lib/avatar' | 29 | import { updateActorAvatarFile } from '../../lib/avatar' |
30 | import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' | 30 | import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' |
31 | import { resetSequelizeInstance } from '../../helpers/database-utils' | 31 | import { resetSequelizeInstance } from '../../helpers/database-utils' |
32 | import { UserModel } from '../../models/account/user' | ||
32 | 33 | ||
33 | const auditLogger = auditLoggerFactory('channels') | 34 | const auditLogger = auditLoggerFactory('channels') |
34 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR }) | 35 | const 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 | ||
124 | async function addVideoChannel (req: express.Request, res: express.Response) { | 125 | async 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({ |