aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/video-channel.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-19 17:02:16 +0200
committerChocobozzz <me@florianbigard.com>2018-09-19 17:02:27 +0200
commit993cef4b6e000ee425087e5195dfe40cd0840243 (patch)
tree9bddf4a2f4fad0ac8cbb9d79445c1c1ec36bd305 /server/controllers/api/video-channel.ts
parent606c946e74211c4123b16087288902226306198d (diff)
downloadPeerTube-993cef4b6e000ee425087e5195dfe40cd0840243.tar.gz
PeerTube-993cef4b6e000ee425087e5195dfe40cd0840243.tar.zst
PeerTube-993cef4b6e000ee425087e5195dfe40cd0840243.zip
Refractor audit user identifier
Diffstat (limited to 'server/controllers/api/video-channel.ts')
-rw-r--r--server/controllers/api/video-channel.ts13
1 files changed, 5 insertions, 8 deletions
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index a7a36080b..50dc44f7c 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -27,7 +27,7 @@ import { logger } from '../../helpers/logger'
27import { VideoModel } from '../../models/video/video' 27import { VideoModel } from '../../models/video/video'
28import { updateAvatarValidator } from '../../middlewares/validators/avatar' 28import { updateAvatarValidator } from '../../middlewares/validators/avatar'
29import { updateActorAvatarFile } from '../../lib/avatar' 29import { updateActorAvatarFile } from '../../lib/avatar'
30import { auditLoggerFactory, 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'
32 32
33const auditLogger = auditLoggerFactory('channels') 33const auditLogger = auditLoggerFactory('channels')
@@ -109,7 +109,7 @@ async function updateVideoChannelAvatar (req: express.Request, res: express.Resp
109 const avatar = await updateActorAvatarFile(avatarPhysicalFile, videoChannel.Actor, videoChannel) 109 const avatar = await updateActorAvatarFile(avatarPhysicalFile, videoChannel.Actor, videoChannel)
110 110
111 auditLogger.update( 111 auditLogger.update(
112 res.locals.oauth.token.User.Account.Actor.getIdentifier(), 112 getAuditIdFromRes(res),
113 new VideoChannelAuditView(videoChannel.toFormattedJSON()), 113 new VideoChannelAuditView(videoChannel.toFormattedJSON()),
114 oldVideoChannelAuditKeys 114 oldVideoChannelAuditKeys
115 ) 115 )
@@ -133,7 +133,7 @@ async function addVideoChannel (req: express.Request, res: express.Response) {
133 .catch(err => logger.error('Cannot set async actor keys for account %s.', videoChannelCreated.Actor.uuid, { err })) 133 .catch(err => logger.error('Cannot set async actor keys for account %s.', videoChannelCreated.Actor.uuid, { err }))
134 134
135 auditLogger.create( 135 auditLogger.create(
136 res.locals.oauth.token.User.Account.Actor.getIdentifier(), 136 getAuditIdFromRes(res),
137 new VideoChannelAuditView(videoChannelCreated.toFormattedJSON()) 137 new VideoChannelAuditView(videoChannelCreated.toFormattedJSON())
138 ) 138 )
139 logger.info('Video channel with uuid %s created.', videoChannelCreated.Actor.uuid) 139 logger.info('Video channel with uuid %s created.', videoChannelCreated.Actor.uuid)
@@ -166,7 +166,7 @@ async function updateVideoChannel (req: express.Request, res: express.Response)
166 await sendUpdateActor(videoChannelInstanceUpdated, t) 166 await sendUpdateActor(videoChannelInstanceUpdated, t)
167 167
168 auditLogger.update( 168 auditLogger.update(
169 res.locals.oauth.token.User.Account.Actor.getIdentifier(), 169 getAuditIdFromRes(res),
170 new VideoChannelAuditView(videoChannelInstanceUpdated.toFormattedJSON()), 170 new VideoChannelAuditView(videoChannelInstanceUpdated.toFormattedJSON()),
171 oldVideoChannelAuditKeys 171 oldVideoChannelAuditKeys
172 ) 172 )
@@ -192,10 +192,7 @@ async function removeVideoChannel (req: express.Request, res: express.Response)
192 await sequelizeTypescript.transaction(async t => { 192 await sequelizeTypescript.transaction(async t => {
193 await videoChannelInstance.destroy({ transaction: t }) 193 await videoChannelInstance.destroy({ transaction: t })
194 194
195 auditLogger.delete( 195 auditLogger.delete(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelInstance.toFormattedJSON()))
196 res.locals.oauth.token.User.Account.Actor.getIdentifier(),
197 new VideoChannelAuditView(videoChannelInstance.toFormattedJSON())
198 )
199 logger.info('Video channel with name %s and uuid %s deleted.', videoChannelInstance.name, videoChannelInstance.Actor.uuid) 196 logger.info('Video channel with name %s and uuid %s deleted.', videoChannelInstance.name, videoChannelInstance.Actor.uuid)
200 }) 197 })
201 198