|
|
@@ -4,6 +4,7 @@ import mongoose from 'mongoose';
|
|
|
import urljoin from 'url-join';
|
|
|
|
|
|
import { SupportedTargetModel, SupportedAction } from '~/interfaces/activity';
|
|
|
+import Activity from '~/server/models/activity';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
import { PathAlreadyExistsError } from '../models/errors';
|
|
|
@@ -411,8 +412,16 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
await addRenderVarsForPageTree(renderVars, portalPath, req.user);
|
|
|
|
|
|
- const parameters = { action: SupportedAction.ACTION_PAGE_VIEW };
|
|
|
- activityEvent.emit('update', res.locals.activity._id, parameters);
|
|
|
+ const parameters = {
|
|
|
+ ip: req.ip,
|
|
|
+ endpoint: req.originalUrl,
|
|
|
+ action: SupportedAction.ACTION_PAGE_VIEW,
|
|
|
+ user: req.user?._id,
|
|
|
+ snapshot: {
|
|
|
+ username: req.user?.username,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ crowi.activityService.createActivity(SupportedAction.ACTION_PAGE_VIEW, parameters);
|
|
|
|
|
|
return res.render(view, renderVars);
|
|
|
}
|
|
|
@@ -472,8 +481,16 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
await addRenderVarsForPageTree(renderVars, path, req.user);
|
|
|
|
|
|
- const parameters = { action: SupportedAction.ACTION_PAGE_VIEW };
|
|
|
- activityEvent.emit('update', res.locals.activity._id, parameters);
|
|
|
+ const parameters = {
|
|
|
+ ip: req.ip,
|
|
|
+ endpoint: req.originalUrl,
|
|
|
+ action: SupportedAction.ACTION_PAGE_VIEW,
|
|
|
+ user: req.user?._id,
|
|
|
+ snapshot: {
|
|
|
+ username: req.user?.username,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ crowi.activityService.createActivity(SupportedAction.ACTION_PAGE_VIEW, parameters);
|
|
|
|
|
|
return res.render(view, renderVars);
|
|
|
}
|
|
|
@@ -655,9 +672,16 @@ module.exports = function(crowi, app) {
|
|
|
actions.redirector = async function(req, res, next) {
|
|
|
const path = getPathFromRequest(req);
|
|
|
|
|
|
- const parameters = { action: SupportedAction.ACTION_PAGE_VIEW };
|
|
|
- activityEvent.emit('update', res.locals.activity._id, parameters);
|
|
|
-
|
|
|
+ const parameters = {
|
|
|
+ ip: req.ip,
|
|
|
+ endpoint: req.originalUrl,
|
|
|
+ action: SupportedAction.ACTION_PAGE_VIEW,
|
|
|
+ user: req.user?._id,
|
|
|
+ snapshot: {
|
|
|
+ username: req.user?.username,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ crowi.activityService.createActivity(SupportedAction.ACTION_PAGE_VIEW, parameters);
|
|
|
return redirector(req, res, next, path);
|
|
|
};
|
|
|
|
|
|
@@ -665,8 +689,16 @@ module.exports = function(crowi, app) {
|
|
|
const _path = getPathFromRequest(req);
|
|
|
const path = pathUtils.removeTrailingSlash(_path);
|
|
|
|
|
|
- const parameters = { action: SupportedAction.ACTION_PAGE_VIEW };
|
|
|
- activityEvent.emit('update', res.locals.activity._id, parameters);
|
|
|
+ const parameters = {
|
|
|
+ ip: req.ip,
|
|
|
+ endpoint: req.originalUrl,
|
|
|
+ action: SupportedAction.ACTION_PAGE_VIEW,
|
|
|
+ user: req.user?._id,
|
|
|
+ snapshot: {
|
|
|
+ username: req.user?.username,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ crowi.activityService.createActivity(SupportedAction.ACTION_PAGE_VIEW, parameters);
|
|
|
|
|
|
return redirector(req, res, next, path);
|
|
|
};
|