|
@@ -26,6 +26,7 @@ import RestoreManager from './RestoreManager.mjs'
|
|
|
import { prepareZipAttachment } from '../../infrastructure/Response.mjs'
|
|
import { prepareZipAttachment } from '../../infrastructure/Response.mjs'
|
|
|
import Features from '../../infrastructure/Features.mjs'
|
|
import Features from '../../infrastructure/Features.mjs'
|
|
|
import { z, zz, validateReq } from '../../infrastructure/Validation.mjs'
|
|
import { z, zz, validateReq } from '../../infrastructure/Validation.mjs'
|
|
|
|
|
+import ProjectAuditLogHandler from '../Project/ProjectAuditLogHandler.mjs'
|
|
|
|
|
|
|
|
// Number of seconds after which the browser should send a request to revalidate
|
|
// Number of seconds after which the browser should send a request to revalidate
|
|
|
// blobs
|
|
// blobs
|
|
@@ -192,6 +193,19 @@ async function restoreFileFromV2(req, res, next) {
|
|
|
pathname
|
|
pathname
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ ProjectAuditLogHandler.addEntryIfManagedInBackground(
|
|
|
|
|
+ projectId,
|
|
|
|
|
+ 'project-history-version-restored',
|
|
|
|
|
+ userId,
|
|
|
|
|
+ req.ip,
|
|
|
|
|
+ {
|
|
|
|
|
+ version,
|
|
|
|
|
+ scope: 'file',
|
|
|
|
|
+ pathname,
|
|
|
|
|
+ restoredEntityId: entity._id,
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
res.json({
|
|
res.json({
|
|
|
type: entity.type,
|
|
type: entity.type,
|
|
|
id: entity._id,
|
|
id: entity._id,
|
|
@@ -211,6 +225,19 @@ async function revertFile(req, res, next) {
|
|
|
{}
|
|
{}
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ ProjectAuditLogHandler.addEntryIfManagedInBackground(
|
|
|
|
|
+ projectId,
|
|
|
|
|
+ 'project-history-version-restored',
|
|
|
|
|
+ userId,
|
|
|
|
|
+ req.ip,
|
|
|
|
|
+ {
|
|
|
|
|
+ version,
|
|
|
|
|
+ scope: 'file',
|
|
|
|
|
+ pathname,
|
|
|
|
|
+ restoredEntityId: entity._id,
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
res.json({
|
|
res.json({
|
|
|
type: entity.type,
|
|
type: entity.type,
|
|
|
id: entity._id,
|
|
id: entity._id,
|
|
@@ -228,6 +255,18 @@ async function revertProject(req, res, next) {
|
|
|
version
|
|
version
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ ProjectAuditLogHandler.addEntryIfManagedInBackground(
|
|
|
|
|
+ projectId,
|
|
|
|
|
+ 'project-history-version-restored',
|
|
|
|
|
+ userId,
|
|
|
|
|
+ req.ip,
|
|
|
|
|
+ {
|
|
|
|
|
+ version,
|
|
|
|
|
+ scope: 'project',
|
|
|
|
|
+ restoredEntities: reverted,
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
res.json(reverted)
|
|
res.json(reverted)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -346,6 +385,7 @@ async function deleteLabel(req, res, next) {
|
|
|
|
|
|
|
|
async function downloadZipOfVersion(req, res, next) {
|
|
async function downloadZipOfVersion(req, res, next) {
|
|
|
const { project_id: projectId, version } = req.params
|
|
const { project_id: projectId, version } = req.params
|
|
|
|
|
+ const userId = SessionManager.getLoggedInUserId(req.session)
|
|
|
|
|
|
|
|
const project = await ProjectDetailsHandler.promises.getDetails(projectId)
|
|
const project = await ProjectDetailsHandler.promises.getDetails(projectId)
|
|
|
const v1Id =
|
|
const v1Id =
|
|
@@ -366,6 +406,17 @@ async function downloadZipOfVersion(req, res, next) {
|
|
|
req,
|
|
req,
|
|
|
res
|
|
res
|
|
|
)
|
|
)
|
|
|
|
|
+
|
|
|
|
|
+ ProjectAuditLogHandler.addEntryIfManagedInBackground(
|
|
|
|
|
+ projectId,
|
|
|
|
|
+ 'project-history-version-downloaded',
|
|
|
|
|
+ userId,
|
|
|
|
|
+ req.ip,
|
|
|
|
|
+ {
|
|
|
|
|
+ version,
|
|
|
|
|
+ projectName: project.name,
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function _pipeHistoryZipToResponse(v1ProjectId, version, name, req, res) {
|
|
async function _pipeHistoryZipToResponse(v1ProjectId, version, name, req, res) {
|