diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/config.ts | 9 | ||||
-rw-r--r-- | server/controllers/api/users/index.ts | 17 | ||||
-rw-r--r-- | server/controllers/api/users/me.ts | 15 | ||||
-rw-r--r-- | server/controllers/api/video-channel.ts | 13 | ||||
-rw-r--r-- | server/controllers/api/videos/comment.ts | 8 | ||||
-rw-r--r-- | server/controllers/api/videos/import.ts | 6 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 8 | ||||
-rw-r--r-- | server/helpers/audit-logger.ts | 8 | ||||
-rw-r--r-- | server/tests/api/server/redundancy.ts | 22 |
9 files changed, 58 insertions, 48 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 6edbe4820..95549b724 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -8,7 +8,7 @@ import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers' | |||
8 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' | 8 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' |
9 | import { customConfigUpdateValidator } from '../../middlewares/validators/config' | 9 | import { customConfigUpdateValidator } from '../../middlewares/validators/config' |
10 | import { ClientHtml } from '../../lib/client-html' | 10 | import { ClientHtml } from '../../lib/client-html' |
11 | import { auditLoggerFactory, CustomConfigAuditView } from '../../helpers/audit-logger' | 11 | import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '../../helpers/audit-logger' |
12 | import { remove, writeJSON } from 'fs-extra' | 12 | import { remove, writeJSON } from 'fs-extra' |
13 | 13 | ||
14 | const packageJSON = require('../../../../package.json') | 14 | const packageJSON = require('../../../../package.json') |
@@ -134,10 +134,7 @@ async function getCustomConfig (req: express.Request, res: express.Response, nex | |||
134 | async function deleteCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) { | 134 | async function deleteCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) { |
135 | await remove(CONFIG.CUSTOM_FILE) | 135 | await remove(CONFIG.CUSTOM_FILE) |
136 | 136 | ||
137 | auditLogger.delete( | 137 | auditLogger.delete(getAuditIdFromRes(res), new CustomConfigAuditView(customConfig())) |
138 | res.locals.oauth.token.User.Account.Actor.getIdentifier(), | ||
139 | new CustomConfigAuditView(customConfig()) | ||
140 | ) | ||
141 | 138 | ||
142 | reloadConfig() | 139 | reloadConfig() |
143 | ClientHtml.invalidCache() | 140 | ClientHtml.invalidCache() |
@@ -183,7 +180,7 @@ async function updateCustomConfig (req: express.Request, res: express.Response, | |||
183 | const data = customConfig() | 180 | const data = customConfig() |
184 | 181 | ||
185 | auditLogger.update( | 182 | auditLogger.update( |
186 | res.locals.oauth.token.User.Account.Actor.getIdentifier(), | 183 | getAuditIdFromRes(res), |
187 | new CustomConfigAuditView(data), | 184 | new CustomConfigAuditView(data), |
188 | oldCustomConfigAuditKeys | 185 | oldCustomConfigAuditKeys |
189 | ) | 186 | ) |
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index 07edf3727..a299167e8 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts | |||
@@ -27,12 +27,15 @@ import { | |||
27 | usersUpdateValidator | 27 | usersUpdateValidator |
28 | } from '../../../middlewares' | 28 | } from '../../../middlewares' |
29 | import { | 29 | import { |
30 | usersAskResetPasswordValidator, usersBlockingValidator, usersResetPasswordValidator, | 30 | usersAskResetPasswordValidator, |
31 | usersAskSendVerifyEmailValidator, usersVerifyEmailValidator | 31 | usersAskSendVerifyEmailValidator, |
32 | usersBlockingValidator, | ||
33 | usersResetPasswordValidator, | ||
34 | usersVerifyEmailValidator | ||
32 | } from '../../../middlewares/validators' | 35 | } from '../../../middlewares/validators' |
33 | import { UserModel } from '../../../models/account/user' | 36 | import { UserModel } from '../../../models/account/user' |
34 | import { OAuthTokenModel } from '../../../models/oauth/oauth-token' | 37 | import { OAuthTokenModel } from '../../../models/oauth/oauth-token' |
35 | import { auditLoggerFactory, UserAuditView } from '../../../helpers/audit-logger' | 38 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger' |
36 | import { meRouter } from './me' | 39 | import { meRouter } from './me' |
37 | 40 | ||
38 | const auditLogger = auditLoggerFactory('users') | 41 | const auditLogger = auditLoggerFactory('users') |
@@ -166,7 +169,7 @@ async function createUser (req: express.Request, res: express.Response) { | |||
166 | 169 | ||
167 | const { user, account } = await createUserAccountAndChannel(userToCreate) | 170 | const { user, account } = await createUserAccountAndChannel(userToCreate) |
168 | 171 | ||
169 | auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new UserAuditView(user.toFormattedJSON())) | 172 | auditLogger.create(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON())) |
170 | logger.info('User %s with its channel and account created.', body.username) | 173 | logger.info('User %s with its channel and account created.', body.username) |
171 | 174 | ||
172 | return res.json({ | 175 | return res.json({ |
@@ -245,7 +248,7 @@ async function removeUser (req: express.Request, res: express.Response, next: ex | |||
245 | 248 | ||
246 | await user.destroy() | 249 | await user.destroy() |
247 | 250 | ||
248 | auditLogger.delete(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new UserAuditView(user.toFormattedJSON())) | 251 | auditLogger.delete(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON())) |
249 | 252 | ||
250 | return res.sendStatus(204) | 253 | return res.sendStatus(204) |
251 | } | 254 | } |
@@ -269,7 +272,7 @@ async function updateUser (req: express.Request, res: express.Response, next: ex | |||
269 | } | 272 | } |
270 | 273 | ||
271 | auditLogger.update( | 274 | auditLogger.update( |
272 | res.locals.oauth.token.User.Account.Actor.getIdentifier(), | 275 | getAuditIdFromRes(res), |
273 | new UserAuditView(user.toFormattedJSON()), | 276 | new UserAuditView(user.toFormattedJSON()), |
274 | oldUserAuditView | 277 | oldUserAuditView |
275 | ) | 278 | ) |
@@ -341,7 +344,7 @@ async function changeUserBlock (res: express.Response, user: UserModel, block: b | |||
341 | await Emailer.Instance.addUserBlockJob(user, block, reason) | 344 | await Emailer.Instance.addUserBlockJob(user, block, reason) |
342 | 345 | ||
343 | auditLogger.update( | 346 | auditLogger.update( |
344 | res.locals.oauth.token.User.Account.Actor.getIdentifier(), | 347 | getAuditIdFromRes(res), |
345 | new UserAuditView(user.toFormattedJSON()), | 348 | new UserAuditView(user.toFormattedJSON()), |
346 | oldUserAuditView | 349 | oldUserAuditView |
347 | ) | 350 | ) |
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' | |||
5 | import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../../initializers' | 5 | import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../../initializers' |
6 | import { sendUpdateActor } from '../../../lib/activitypub/send' | 6 | import { sendUpdateActor } from '../../../lib/activitypub/send' |
7 | import { | 7 | import { |
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' |
19 | import { | 20 | import { |
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' |
26 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | 27 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
27 | import { UserModel } from '../../../models/account/user' | 28 | import { UserModel } from '../../../models/account/user' |
@@ -31,7 +32,7 @@ import { buildNSFWFilter, createReqFiles } from '../../../helpers/express-utils' | |||
31 | import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model' | 32 | import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model' |
32 | import { updateAvatarValidator } from '../../../middlewares/validators/avatar' | 33 | import { updateAvatarValidator } from '../../../middlewares/validators/avatar' |
33 | import { updateActorAvatarFile } from '../../../lib/avatar' | 34 | import { updateActorAvatarFile } from '../../../lib/avatar' |
34 | import { auditLoggerFactory, UserAuditView } from '../../../helpers/audit-logger' | 35 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger' |
35 | import { VideoImportModel } from '../../../models/video/video-import' | 36 | import { VideoImportModel } from '../../../models/video/video-import' |
36 | import { VideoFilter } from '../../../../shared/models/videos/video-query.type' | 37 | import { VideoFilter } from '../../../../shared/models/videos/video-query.type' |
37 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 38 | import { 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 | ) |
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' | |||
27 | import { VideoModel } from '../../models/video/video' | 27 | import { VideoModel } from '../../models/video/video' |
28 | import { updateAvatarValidator } from '../../middlewares/validators/avatar' | 28 | import { updateAvatarValidator } from '../../middlewares/validators/avatar' |
29 | import { updateActorAvatarFile } from '../../lib/avatar' | 29 | import { updateActorAvatarFile } from '../../lib/avatar' |
30 | import { auditLoggerFactory, 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 | 32 | ||
33 | const auditLogger = auditLoggerFactory('channels') | 33 | const 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 | ||
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts index 8d0692b2b..40ad54d09 100644 --- a/server/controllers/api/videos/comment.ts +++ b/server/controllers/api/videos/comment.ts | |||
@@ -23,7 +23,7 @@ import { | |||
23 | } from '../../../middlewares/validators/video-comments' | 23 | } from '../../../middlewares/validators/video-comments' |
24 | import { VideoModel } from '../../../models/video/video' | 24 | import { VideoModel } from '../../../models/video/video' |
25 | import { VideoCommentModel } from '../../../models/video/video-comment' | 25 | import { VideoCommentModel } from '../../../models/video/video-comment' |
26 | import { auditLoggerFactory, CommentAuditView } from '../../../helpers/audit-logger' | 26 | import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' |
27 | 27 | ||
28 | const auditLogger = auditLoggerFactory('comments') | 28 | const auditLogger = auditLoggerFactory('comments') |
29 | const videoCommentRouter = express.Router() | 29 | const videoCommentRouter = express.Router() |
@@ -109,7 +109,7 @@ async function addVideoCommentThread (req: express.Request, res: express.Respons | |||
109 | }, t) | 109 | }, t) |
110 | }) | 110 | }) |
111 | 111 | ||
112 | auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new CommentAuditView(comment.toFormattedJSON())) | 112 | auditLogger.create(getAuditIdFromRes(res), new CommentAuditView(comment.toFormattedJSON())) |
113 | 113 | ||
114 | return res.json({ | 114 | return res.json({ |
115 | comment: comment.toFormattedJSON() | 115 | comment: comment.toFormattedJSON() |
@@ -128,7 +128,7 @@ async function addVideoCommentReply (req: express.Request, res: express.Response | |||
128 | }, t) | 128 | }, t) |
129 | }) | 129 | }) |
130 | 130 | ||
131 | auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new CommentAuditView(comment.toFormattedJSON())) | 131 | auditLogger.create(getAuditIdFromRes(res), new CommentAuditView(comment.toFormattedJSON())) |
132 | 132 | ||
133 | return res.json({ | 133 | return res.json({ |
134 | comment: comment.toFormattedJSON() | 134 | comment: comment.toFormattedJSON() |
@@ -143,7 +143,7 @@ async function removeVideoComment (req: express.Request, res: express.Response) | |||
143 | }) | 143 | }) |
144 | 144 | ||
145 | auditLogger.delete( | 145 | auditLogger.delete( |
146 | res.locals.oauth.token.User.Account.Actor.getIdentifier(), | 146 | getAuditIdFromRes(res), |
147 | new CommentAuditView(videoCommentInstance.toFormattedJSON()) | 147 | new CommentAuditView(videoCommentInstance.toFormattedJSON()) |
148 | ) | 148 | ) |
149 | logger.info('Video comment %d deleted.', videoCommentInstance.id) | 149 | logger.info('Video comment %d deleted.', videoCommentInstance.id) |
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 44f15ef74..398fd5a7f 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import * as magnetUtil from 'magnet-uri' | 2 | import * as magnetUtil from 'magnet-uri' |
3 | import 'multer' | 3 | import 'multer' |
4 | import { auditLoggerFactory, VideoImportAuditView } from '../../../helpers/audit-logger' | 4 | import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' |
5 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares' | 5 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares' |
6 | import { | 6 | import { |
7 | CONFIG, | 7 | CONFIG, |
@@ -114,7 +114,7 @@ async function addTorrentImport (req: express.Request, res: express.Response, to | |||
114 | } | 114 | } |
115 | await JobQueue.Instance.createJob({ type: 'video-import', payload }) | 115 | await JobQueue.Instance.createJob({ type: 'video-import', payload }) |
116 | 116 | ||
117 | auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new VideoImportAuditView(videoImport.toFormattedJSON())) | 117 | auditLogger.create(getAuditIdFromRes(res), new VideoImportAuditView(videoImport.toFormattedJSON())) |
118 | 118 | ||
119 | return res.json(videoImport.toFormattedJSON()).end() | 119 | return res.json(videoImport.toFormattedJSON()).end() |
120 | } | 120 | } |
@@ -158,7 +158,7 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response) | |||
158 | } | 158 | } |
159 | await JobQueue.Instance.createJob({ type: 'video-import', payload }) | 159 | await JobQueue.Instance.createJob({ type: 'video-import', payload }) |
160 | 160 | ||
161 | auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new VideoImportAuditView(videoImport.toFormattedJSON())) | 161 | auditLogger.create(getAuditIdFromRes(res), new VideoImportAuditView(videoImport.toFormattedJSON())) |
162 | 162 | ||
163 | return res.json(videoImport.toFormattedJSON()).end() | 163 | return res.json(videoImport.toFormattedJSON()).end() |
164 | } | 164 | } |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 8353a649a..581046782 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -4,7 +4,7 @@ import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../ | |||
4 | import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' | 4 | import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' |
5 | import { processImage } from '../../../helpers/image-utils' | 5 | import { processImage } from '../../../helpers/image-utils' |
6 | import { logger } from '../../../helpers/logger' | 6 | import { logger } from '../../../helpers/logger' |
7 | import { auditLoggerFactory, VideoAuditView } from '../../../helpers/audit-logger' | 7 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
8 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' | 8 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' |
9 | import { | 9 | import { |
10 | CONFIG, | 10 | CONFIG, |
@@ -253,7 +253,7 @@ async function addVideo (req: express.Request, res: express.Response) { | |||
253 | 253 | ||
254 | await federateVideoIfNeeded(video, true, t) | 254 | await federateVideoIfNeeded(video, true, t) |
255 | 255 | ||
256 | auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new VideoAuditView(videoCreated.toFormattedDetailsJSON())) | 256 | auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON())) |
257 | logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid) | 257 | logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid) |
258 | 258 | ||
259 | return videoCreated | 259 | return videoCreated |
@@ -354,7 +354,7 @@ async function updateVideo (req: express.Request, res: express.Response) { | |||
354 | await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t) | 354 | await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t) |
355 | 355 | ||
356 | auditLogger.update( | 356 | auditLogger.update( |
357 | res.locals.oauth.token.User.Account.Actor.getIdentifier(), | 357 | getAuditIdFromRes(res), |
358 | new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()), | 358 | new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()), |
359 | oldVideoAuditView | 359 | oldVideoAuditView |
360 | ) | 360 | ) |
@@ -439,7 +439,7 @@ async function removeVideo (req: express.Request, res: express.Response) { | |||
439 | await videoInstance.destroy({ transaction: t }) | 439 | await videoInstance.destroy({ transaction: t }) |
440 | }) | 440 | }) |
441 | 441 | ||
442 | auditLogger.delete(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new VideoAuditView(videoInstance.toFormattedDetailsJSON())) | 442 | auditLogger.delete(getAuditIdFromRes(res), new VideoAuditView(videoInstance.toFormattedDetailsJSON())) |
443 | logger.info('Video with name %s and uuid %s deleted.', videoInstance.name, videoInstance.uuid) | 443 | logger.info('Video with name %s and uuid %s deleted.', videoInstance.name, videoInstance.uuid) |
444 | 444 | ||
445 | return res.type('json').status(204).end() | 445 | return res.type('json').status(204).end() |
diff --git a/server/helpers/audit-logger.ts b/server/helpers/audit-logger.ts index 7db72b69c..00311fce1 100644 --- a/server/helpers/audit-logger.ts +++ b/server/helpers/audit-logger.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import * as path from 'path' | 1 | import * as path from 'path' |
2 | import * as express from 'express' | ||
2 | import { diff } from 'deep-object-diff' | 3 | import { diff } from 'deep-object-diff' |
3 | import { chain } from 'lodash' | 4 | import { chain } from 'lodash' |
4 | import * as flatten from 'flat' | 5 | import * as flatten from 'flat' |
@@ -8,6 +9,11 @@ import { jsonLoggerFormat, labelFormatter } from './logger' | |||
8 | import { VideoDetails, User, VideoChannel, VideoAbuse, VideoImport } from '../../shared' | 9 | import { VideoDetails, User, VideoChannel, VideoAbuse, VideoImport } from '../../shared' |
9 | import { VideoComment } from '../../shared/models/videos/video-comment.model' | 10 | import { VideoComment } from '../../shared/models/videos/video-comment.model' |
10 | import { CustomConfig } from '../../shared/models/server/custom-config.model' | 11 | import { CustomConfig } from '../../shared/models/server/custom-config.model' |
12 | import { UserModel } from '../models/account/user' | ||
13 | |||
14 | function getAuditIdFromRes (res: express.Response) { | ||
15 | return (res.locals.oauth.token.User as UserModel).username | ||
16 | } | ||
11 | 17 | ||
12 | enum AUDIT_TYPE { | 18 | enum AUDIT_TYPE { |
13 | CREATE = 'create', | 19 | CREATE = 'create', |
@@ -255,6 +261,8 @@ class CustomConfigAuditView extends EntityAuditView { | |||
255 | } | 261 | } |
256 | 262 | ||
257 | export { | 263 | export { |
264 | getAuditIdFromRes, | ||
265 | |||
258 | auditLoggerFactory, | 266 | auditLoggerFactory, |
259 | VideoImportAuditView, | 267 | VideoImportAuditView, |
260 | VideoChannelAuditView, | 268 | VideoChannelAuditView, |
diff --git a/server/tests/api/server/redundancy.ts b/server/tests/api/server/redundancy.ts index c0ab251e6..6ce4b9dd1 100644 --- a/server/tests/api/server/redundancy.ts +++ b/server/tests/api/server/redundancy.ts | |||
@@ -6,15 +6,16 @@ import { VideoDetails } from '../../../../shared/models/videos' | |||
6 | import { | 6 | import { |
7 | doubleFollow, | 7 | doubleFollow, |
8 | flushAndRunMultipleServers, | 8 | flushAndRunMultipleServers, |
9 | flushTests, | ||
10 | getFollowingListPaginationAndSort, | 9 | getFollowingListPaginationAndSort, |
11 | getVideo, | 10 | getVideo, |
11 | immutableAssign, | ||
12 | killallServers, | 12 | killallServers, |
13 | root, | ||
13 | ServerInfo, | 14 | ServerInfo, |
14 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
15 | uploadVideo, | 16 | uploadVideo, |
16 | wait, | 17 | viewVideo, |
17 | root, viewVideo, immutableAssign | 18 | wait |
18 | } from '../../utils' | 19 | } from '../../utils' |
19 | import { waitJobs } from '../../utils/server/jobs' | 20 | import { waitJobs } from '../../utils/server/jobs' |
20 | import * as magnetUtil from 'magnet-uri' | 21 | import * as magnetUtil from 'magnet-uri' |
@@ -44,12 +45,15 @@ function checkMagnetWebseeds (file: { magnetUri: string, resolution: { id: numbe | |||
44 | async function runServers (strategy: VideoRedundancyStrategy, additionalParams: any = {}) { | 45 | async function runServers (strategy: VideoRedundancyStrategy, additionalParams: any = {}) { |
45 | const config = { | 46 | const config = { |
46 | redundancy: { | 47 | redundancy: { |
47 | videos: [ | 48 | videos: { |
48 | immutableAssign({ | 49 | check_interval: '5 seconds', |
49 | strategy: strategy, | 50 | strategies: [ |
50 | size: '100KB' | 51 | immutableAssign({ |
51 | }, additionalParams) | 52 | strategy: strategy, |
52 | ] | 53 | size: '100KB' |
54 | }, additionalParams) | ||
55 | ] | ||
56 | } | ||
53 | } | 57 | } |
54 | } | 58 | } |
55 | servers = await flushAndRunMultipleServers(3, config) | 59 | servers = await flushAndRunMultipleServers(3, config) |