import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
import { customConfigUpdateValidator } from '../../middlewares/validators/config'
import { ClientHtml } from '../../lib/client-html'
-import { auditLoggerFactory, CustomConfigAuditView } from '../../helpers/audit-logger'
+import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '../../helpers/audit-logger'
import { remove, writeJSON } from 'fs-extra'
const packageJSON = require('../../../../package.json')
async function deleteCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
await remove(CONFIG.CUSTOM_FILE)
- auditLogger.delete(
- res.locals.oauth.token.User.Account.Actor.getIdentifier(),
- new CustomConfigAuditView(customConfig())
- )
+ auditLogger.delete(getAuditIdFromRes(res), new CustomConfigAuditView(customConfig()))
reloadConfig()
ClientHtml.invalidCache()
const data = customConfig()
auditLogger.update(
- res.locals.oauth.token.User.Account.Actor.getIdentifier(),
+ getAuditIdFromRes(res),
new CustomConfigAuditView(data),
oldCustomConfigAuditKeys
)
usersUpdateValidator
} from '../../../middlewares'
import {
- usersAskResetPasswordValidator, usersBlockingValidator, usersResetPasswordValidator,
- usersAskSendVerifyEmailValidator, usersVerifyEmailValidator
+ usersAskResetPasswordValidator,
+ usersAskSendVerifyEmailValidator,
+ usersBlockingValidator,
+ usersResetPasswordValidator,
+ usersVerifyEmailValidator
} from '../../../middlewares/validators'
import { UserModel } from '../../../models/account/user'
import { OAuthTokenModel } from '../../../models/oauth/oauth-token'
-import { auditLoggerFactory, UserAuditView } from '../../../helpers/audit-logger'
+import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'
import { meRouter } from './me'
const auditLogger = auditLoggerFactory('users')
const { user, account } = await createUserAccountAndChannel(userToCreate)
- auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new UserAuditView(user.toFormattedJSON()))
+ auditLogger.create(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON()))
logger.info('User %s with its channel and account created.', body.username)
return res.json({
await user.destroy()
- auditLogger.delete(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new UserAuditView(user.toFormattedJSON()))
+ auditLogger.delete(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON()))
return res.sendStatus(204)
}
}
auditLogger.update(
- res.locals.oauth.token.User.Account.Actor.getIdentifier(),
+ getAuditIdFromRes(res),
new UserAuditView(user.toFormattedJSON()),
oldUserAuditView
)
await Emailer.Instance.addUserBlockJob(user, block, reason)
auditLogger.update(
- res.locals.oauth.token.User.Account.Actor.getIdentifier(),
+ getAuditIdFromRes(res),
new UserAuditView(user.toFormattedJSON()),
oldUserAuditView
)
import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../../initializers'
import { sendUpdateActor } from '../../../lib/activitypub/send'
import {
- asyncMiddleware, asyncRetryTransactionMiddleware,
+ asyncMiddleware,
+ asyncRetryTransactionMiddleware,
authenticate,
commonVideosFiltersValidator,
paginationValidator,
usersVideoRatingValidator
} from '../../../middlewares'
import {
+ areSubscriptionsExistValidator,
deleteMeValidator,
userSubscriptionsSortValidator,
videoImportsSortValidator,
- videosSortValidator,
- areSubscriptionsExistValidator
+ videosSortValidator
} from '../../../middlewares/validators'
import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
import { UserModel } from '../../../models/account/user'
import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model'
import { updateAvatarValidator } from '../../../middlewares/validators/avatar'
import { updateActorAvatarFile } from '../../../lib/avatar'
-import { auditLoggerFactory, UserAuditView } from '../../../helpers/audit-logger'
+import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'
import { VideoImportModel } from '../../../models/video/video-import'
import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
await user.destroy()
- auditLogger.delete(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new UserAuditView(user.toFormattedJSON()))
+ auditLogger.delete(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON()))
return res.sendStatus(204)
}
await sendUpdateActor(user.Account, t)
auditLogger.update(
- res.locals.oauth.token.User.Account.Actor.getIdentifier(),
+ getAuditIdFromRes(res),
new UserAuditView(user.toFormattedJSON()),
oldUserAuditView
)
const avatar = await updateActorAvatarFile(avatarPhysicalFile, account.Actor, account)
auditLogger.update(
- res.locals.oauth.token.User.Account.Actor.getIdentifier(),
+ getAuditIdFromRes(res),
new UserAuditView(user.toFormattedJSON()),
oldUserAuditView
)
import { VideoModel } from '../../models/video/video'
import { updateAvatarValidator } from '../../middlewares/validators/avatar'
import { updateActorAvatarFile } from '../../lib/avatar'
-import { auditLoggerFactory, VideoChannelAuditView } from '../../helpers/audit-logger'
+import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger'
import { resetSequelizeInstance } from '../../helpers/database-utils'
const auditLogger = auditLoggerFactory('channels')
const avatar = await updateActorAvatarFile(avatarPhysicalFile, videoChannel.Actor, videoChannel)
auditLogger.update(
- res.locals.oauth.token.User.Account.Actor.getIdentifier(),
+ getAuditIdFromRes(res),
new VideoChannelAuditView(videoChannel.toFormattedJSON()),
oldVideoChannelAuditKeys
)
.catch(err => logger.error('Cannot set async actor keys for account %s.', videoChannelCreated.Actor.uuid, { err }))
auditLogger.create(
- res.locals.oauth.token.User.Account.Actor.getIdentifier(),
+ getAuditIdFromRes(res),
new VideoChannelAuditView(videoChannelCreated.toFormattedJSON())
)
logger.info('Video channel with uuid %s created.', videoChannelCreated.Actor.uuid)
await sendUpdateActor(videoChannelInstanceUpdated, t)
auditLogger.update(
- res.locals.oauth.token.User.Account.Actor.getIdentifier(),
+ getAuditIdFromRes(res),
new VideoChannelAuditView(videoChannelInstanceUpdated.toFormattedJSON()),
oldVideoChannelAuditKeys
)
await sequelizeTypescript.transaction(async t => {
await videoChannelInstance.destroy({ transaction: t })
- auditLogger.delete(
- res.locals.oauth.token.User.Account.Actor.getIdentifier(),
- new VideoChannelAuditView(videoChannelInstance.toFormattedJSON())
- )
+ auditLogger.delete(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannelInstance.toFormattedJSON()))
logger.info('Video channel with name %s and uuid %s deleted.', videoChannelInstance.name, videoChannelInstance.Actor.uuid)
})
} from '../../../middlewares/validators/video-comments'
import { VideoModel } from '../../../models/video/video'
import { VideoCommentModel } from '../../../models/video/video-comment'
-import { auditLoggerFactory, CommentAuditView } from '../../../helpers/audit-logger'
+import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger'
const auditLogger = auditLoggerFactory('comments')
const videoCommentRouter = express.Router()
}, t)
})
- auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new CommentAuditView(comment.toFormattedJSON()))
+ auditLogger.create(getAuditIdFromRes(res), new CommentAuditView(comment.toFormattedJSON()))
return res.json({
comment: comment.toFormattedJSON()
}, t)
})
- auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new CommentAuditView(comment.toFormattedJSON()))
+ auditLogger.create(getAuditIdFromRes(res), new CommentAuditView(comment.toFormattedJSON()))
return res.json({
comment: comment.toFormattedJSON()
})
auditLogger.delete(
- res.locals.oauth.token.User.Account.Actor.getIdentifier(),
+ getAuditIdFromRes(res),
new CommentAuditView(videoCommentInstance.toFormattedJSON())
)
logger.info('Video comment %d deleted.', videoCommentInstance.id)
import * as express from 'express'
import * as magnetUtil from 'magnet-uri'
import 'multer'
-import { auditLoggerFactory, VideoImportAuditView } from '../../../helpers/audit-logger'
+import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger'
import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares'
import {
CONFIG,
}
await JobQueue.Instance.createJob({ type: 'video-import', payload })
- auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new VideoImportAuditView(videoImport.toFormattedJSON()))
+ auditLogger.create(getAuditIdFromRes(res), new VideoImportAuditView(videoImport.toFormattedJSON()))
return res.json(videoImport.toFormattedJSON()).end()
}
}
await JobQueue.Instance.createJob({ type: 'video-import', payload })
- auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new VideoImportAuditView(videoImport.toFormattedJSON()))
+ auditLogger.create(getAuditIdFromRes(res), new VideoImportAuditView(videoImport.toFormattedJSON()))
return res.json(videoImport.toFormattedJSON()).end()
}
import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
import { processImage } from '../../../helpers/image-utils'
import { logger } from '../../../helpers/logger'
-import { auditLoggerFactory, VideoAuditView } from '../../../helpers/audit-logger'
+import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
import { getFormattedObjects, getServerActor } from '../../../helpers/utils'
import {
CONFIG,
await federateVideoIfNeeded(video, true, t)
- auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new VideoAuditView(videoCreated.toFormattedDetailsJSON()))
+ auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON()))
logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid)
return videoCreated
await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t)
auditLogger.update(
- res.locals.oauth.token.User.Account.Actor.getIdentifier(),
+ getAuditIdFromRes(res),
new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()),
oldVideoAuditView
)
await videoInstance.destroy({ transaction: t })
})
- auditLogger.delete(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new VideoAuditView(videoInstance.toFormattedDetailsJSON()))
+ auditLogger.delete(getAuditIdFromRes(res), new VideoAuditView(videoInstance.toFormattedDetailsJSON()))
logger.info('Video with name %s and uuid %s deleted.', videoInstance.name, videoInstance.uuid)
return res.type('json').status(204).end()
import * as path from 'path'
+import * as express from 'express'
import { diff } from 'deep-object-diff'
import { chain } from 'lodash'
import * as flatten from 'flat'
import { VideoDetails, User, VideoChannel, VideoAbuse, VideoImport } from '../../shared'
import { VideoComment } from '../../shared/models/videos/video-comment.model'
import { CustomConfig } from '../../shared/models/server/custom-config.model'
+import { UserModel } from '../models/account/user'
+
+function getAuditIdFromRes (res: express.Response) {
+ return (res.locals.oauth.token.User as UserModel).username
+}
enum AUDIT_TYPE {
CREATE = 'create',
}
export {
+ getAuditIdFromRes,
+
auditLoggerFactory,
VideoImportAuditView,
VideoChannelAuditView,
import {
doubleFollow,
flushAndRunMultipleServers,
- flushTests,
getFollowingListPaginationAndSort,
getVideo,
+ immutableAssign,
killallServers,
+ root,
ServerInfo,
setAccessTokensToServers,
uploadVideo,
- wait,
- root, viewVideo, immutableAssign
+ viewVideo,
+ wait
} from '../../utils'
import { waitJobs } from '../../utils/server/jobs'
import * as magnetUtil from 'magnet-uri'
async function runServers (strategy: VideoRedundancyStrategy, additionalParams: any = {}) {
const config = {
redundancy: {
- videos: [
- immutableAssign({
- strategy: strategy,
- size: '100KB'
- }, additionalParams)
- ]
+ videos: {
+ check_interval: '5 seconds',
+ strategies: [
+ immutableAssign({
+ strategy: strategy,
+ size: '100KB'
+ }, additionalParams)
+ ]
+ }
}
}
servers = await flushAndRunMultipleServers(3, config)