|
|
@@ -309,16 +309,20 @@ module.exports = function(crowi, app) {
|
|
|
const pathOrId = req.params.id || path;
|
|
|
|
|
|
let view;
|
|
|
+ let action;
|
|
|
const renderVars = { path };
|
|
|
|
|
|
if (!isCreatablePage(path)) {
|
|
|
view = 'layout-growi/not_creatable';
|
|
|
+ action = SupportedAction.ACTION_PAGE_NOT_CREATABLE;
|
|
|
}
|
|
|
else if (req.isForbidden) {
|
|
|
view = 'layout-growi/forbidden';
|
|
|
+ action = SupportedAction.ACTION_PAGE_FORBIDDEN;
|
|
|
}
|
|
|
else {
|
|
|
view = 'layout-growi/not_found';
|
|
|
+ action = SupportedAction.ACTION_PAGE_NOT_FOUND;
|
|
|
|
|
|
// retrieve templates
|
|
|
if (req.user != null) {
|
|
|
@@ -345,6 +349,18 @@ module.exports = function(crowi, app) {
|
|
|
await addRenderVarsForPageTree(renderVars, pathOrId, req.user);
|
|
|
await addRenderVarsWhenNotFound(renderVars, pathOrId);
|
|
|
await addRenderVarsWhenEmptyPage(renderVars, req.isEmpty, req.pageId);
|
|
|
+
|
|
|
+ const parameters = {
|
|
|
+ ip: req.ip,
|
|
|
+ endpoint: req.originalUrl,
|
|
|
+ action,
|
|
|
+ user: req.user?._id,
|
|
|
+ snapshot: {
|
|
|
+ username: req.user?.username,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ crowi.activityService.createActivity(parameters);
|
|
|
+
|
|
|
return res.render(view, renderVars);
|
|
|
}
|
|
|
|
|
|
@@ -421,7 +437,7 @@ module.exports = function(crowi, app) {
|
|
|
username: req.user?.username,
|
|
|
},
|
|
|
};
|
|
|
- crowi.activityService.createActivity(SupportedAction.ACTION_PAGE_VIEW, parameters);
|
|
|
+ crowi.activityService.createActivity(parameters);
|
|
|
|
|
|
return res.render(view, renderVars);
|
|
|
}
|
|
|
@@ -484,13 +500,13 @@ module.exports = function(crowi, app) {
|
|
|
const parameters = {
|
|
|
ip: req.ip,
|
|
|
endpoint: req.originalUrl,
|
|
|
- action: SupportedAction.ACTION_PAGE_VIEW,
|
|
|
+ action: isUsersHomePage(path) ? SupportedAction.ACTION_PAGE_USER_HOME_VIEW : SupportedAction.ACTION_PAGE_VIEW,
|
|
|
user: req.user?._id,
|
|
|
snapshot: {
|
|
|
username: req.user?.username,
|
|
|
},
|
|
|
};
|
|
|
- crowi.activityService.createActivity(SupportedAction.ACTION_PAGE_VIEW, parameters);
|
|
|
+ crowi.activityService.createActivity(parameters);
|
|
|
|
|
|
return res.render(view, renderVars);
|
|
|
}
|
|
|
@@ -525,13 +541,30 @@ module.exports = function(crowi, app) {
|
|
|
const revisionId = req.query.revision;
|
|
|
const renderVars = {};
|
|
|
|
|
|
+ const parameters = {
|
|
|
+ ip: req.ip,
|
|
|
+ endpoint: req.originalUrl,
|
|
|
+ user: req.user?._id,
|
|
|
+ snapshot: {
|
|
|
+ username: req.user?.username,
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
const shareLink = await ShareLink.findOne({ _id: linkId }).populate('relatedPage');
|
|
|
|
|
|
if (shareLink == null || shareLink.relatedPage == null || shareLink.relatedPage.isEmpty) {
|
|
|
+
|
|
|
+ Object.assign(parameters, { action: SupportedAction.ACTION_SHARE_LINK_NOT_FOUND });
|
|
|
+ crowi.activityService.createActivity(parameters);
|
|
|
+
|
|
|
// page or sharelink are not found (or page is empty: abnormaly)
|
|
|
return res.render('layout-growi/not_found_shared_page');
|
|
|
}
|
|
|
if (crowi.configManager.getConfig('crowi', 'security:disableLinkSharing')) {
|
|
|
+
|
|
|
+ Object.assign(parameters, { action: SupportedAction.ACTION_SHARE_LINK_NOT_FOUND });
|
|
|
+ crowi.activityService.createActivity(parameters);
|
|
|
+
|
|
|
return res.render('layout-growi/forbidden');
|
|
|
}
|
|
|
|
|
|
@@ -539,6 +572,9 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
// check if share link is expired
|
|
|
if (shareLink.isExpired()) {
|
|
|
+ Object.assign(parameters, { action: SupportedAction.ACTION_SHARE_LINK_EXPIRED_PAGE_VIEW });
|
|
|
+ crowi.activityService.createActivity(parameters);
|
|
|
+
|
|
|
// page is not found
|
|
|
return res.render('layout-growi/expired_shared_page', renderVars);
|
|
|
}
|
|
|
@@ -561,6 +597,9 @@ module.exports = function(crowi, app) {
|
|
|
addRenderVarsForPage(renderVars, page);
|
|
|
addRenderVarsForScope(renderVars, page);
|
|
|
|
|
|
+ Object.assign(parameters, { action: SupportedAction.ACTION_SHARE_LINK_PAGE_VIEW });
|
|
|
+ crowi.activityService.createActivity(parameters);
|
|
|
+
|
|
|
return res.render('layout-growi/shared_page', renderVars);
|
|
|
};
|
|
|
|
|
|
@@ -681,7 +720,7 @@ module.exports = function(crowi, app) {
|
|
|
username: req.user?.username,
|
|
|
},
|
|
|
};
|
|
|
- crowi.activityService.createActivity(SupportedAction.ACTION_PAGE_VIEW, parameters);
|
|
|
+ crowi.activityService.createActivity(parameters);
|
|
|
return redirector(req, res, next, path);
|
|
|
};
|
|
|
|
|
|
@@ -698,7 +737,7 @@ module.exports = function(crowi, app) {
|
|
|
username: req.user?.username,
|
|
|
},
|
|
|
};
|
|
|
- crowi.activityService.createActivity(SupportedAction.ACTION_PAGE_VIEW, parameters);
|
|
|
+ crowi.activityService.createActivity(parameters);
|
|
|
|
|
|
return redirector(req, res, next, path);
|
|
|
};
|