aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users/me.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/users/me.ts
parent606c946e74211c4123b16087288902226306198d (diff)
downloadPeerTube-993cef4b6e000ee425087e5195dfe40cd0840243.tar.gz
PeerTube-993cef4b6e000ee425087e5195dfe40cd0840243.tar.zst
PeerTube-993cef4b6e000ee425087e5195dfe40cd0840243.zip
Refractor audit user identifier
Diffstat (limited to 'server/controllers/api/users/me.ts')
-rw-r--r--server/controllers/api/users/me.ts15
1 files changed, 8 insertions, 7 deletions
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts
index 113563c39..d4b7e3715 100644
--- a/server/controllers/api/users/me.ts
+++ b/server/controllers/api/users/me.ts
@@ -5,7 +5,8 @@ import { getFormattedObjects } from '../../../helpers/utils'
5import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../../initializers' 5import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../../initializers'
6import { sendUpdateActor } from '../../../lib/activitypub/send' 6import { sendUpdateActor } from '../../../lib/activitypub/send'
7import { 7import {
8 asyncMiddleware, asyncRetryTransactionMiddleware, 8 asyncMiddleware,
9 asyncRetryTransactionMiddleware,
9 authenticate, 10 authenticate,
10 commonVideosFiltersValidator, 11 commonVideosFiltersValidator,
11 paginationValidator, 12 paginationValidator,
@@ -17,11 +18,11 @@ import {
17 usersVideoRatingValidator 18 usersVideoRatingValidator
18} from '../../../middlewares' 19} from '../../../middlewares'
19import { 20import {
21 areSubscriptionsExistValidator,
20 deleteMeValidator, 22 deleteMeValidator,
21 userSubscriptionsSortValidator, 23 userSubscriptionsSortValidator,
22 videoImportsSortValidator, 24 videoImportsSortValidator,
23 videosSortValidator, 25 videosSortValidator
24 areSubscriptionsExistValidator
25} from '../../../middlewares/validators' 26} from '../../../middlewares/validators'
26import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 27import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
27import { UserModel } from '../../../models/account/user' 28import { UserModel } from '../../../models/account/user'
@@ -31,7 +32,7 @@ import { buildNSFWFilter, createReqFiles } from '../../../helpers/express-utils'
31import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model' 32import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model'
32import { updateAvatarValidator } from '../../../middlewares/validators/avatar' 33import { updateAvatarValidator } from '../../../middlewares/validators/avatar'
33import { updateActorAvatarFile } from '../../../lib/avatar' 34import { updateActorAvatarFile } from '../../../lib/avatar'
34import { auditLoggerFactory, UserAuditView } from '../../../helpers/audit-logger' 35import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'
35import { VideoImportModel } from '../../../models/video/video-import' 36import { VideoImportModel } from '../../../models/video/video-import'
36import { VideoFilter } from '../../../../shared/models/videos/video-query.type' 37import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
37import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 38import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
@@ -311,7 +312,7 @@ async function deleteMe (req: express.Request, res: express.Response) {
311 312
312 await user.destroy() 313 await user.destroy()
313 314
314 auditLogger.delete(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new UserAuditView(user.toFormattedJSON())) 315 auditLogger.delete(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON()))
315 316
316 return res.sendStatus(204) 317 return res.sendStatus(204)
317} 318}
@@ -337,7 +338,7 @@ async function updateMe (req: express.Request, res: express.Response, next: expr
337 await sendUpdateActor(user.Account, t) 338 await sendUpdateActor(user.Account, t)
338 339
339 auditLogger.update( 340 auditLogger.update(
340 res.locals.oauth.token.User.Account.Actor.getIdentifier(), 341 getAuditIdFromRes(res),
341 new UserAuditView(user.toFormattedJSON()), 342 new UserAuditView(user.toFormattedJSON()),
342 oldUserAuditView 343 oldUserAuditView
343 ) 344 )
@@ -355,7 +356,7 @@ async function updateMyAvatar (req: express.Request, res: express.Response, next
355 const avatar = await updateActorAvatarFile(avatarPhysicalFile, account.Actor, account) 356 const avatar = await updateActorAvatarFile(avatarPhysicalFile, account.Actor, account)
356 357
357 auditLogger.update( 358 auditLogger.update(
358 res.locals.oauth.token.User.Account.Actor.getIdentifier(), 359 getAuditIdFromRes(res),
359 new UserAuditView(user.toFormattedJSON()), 360 new UserAuditView(user.toFormattedJSON()),
360 oldUserAuditView 361 oldUserAuditView
361 ) 362 )