|
@@ -20,7 +20,7 @@ import {
|
|
|
} from '~/stores/context';
|
|
} from '~/stores/context';
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
- CommonProps, getServerSideCommonProps, useCustomTitle, getNextI18NextConfig, addActivity,
|
|
|
|
|
|
|
+ CommonProps, getServerSideCommonProps, useCustomTitle, getNextI18NextConfig,
|
|
|
} from '../utils/commons';
|
|
} from '../utils/commons';
|
|
|
|
|
|
|
|
const ShareLinkAlert = dynamic(() => import('~/components/Page/ShareLinkAlert'), { ssr: false });
|
|
const ShareLinkAlert = dynamic(() => import('~/components/Page/ShareLinkAlert'), { ssr: false });
|
|
@@ -131,6 +131,22 @@ async function injectNextI18NextConfigurations(context: GetServerSidePropsContex
|
|
|
props._nextI18Next = nextI18NextConfig._nextI18Next;
|
|
props._nextI18Next = nextI18NextConfig._nextI18Next;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+async function addActivity(context: GetServerSidePropsContext, action: SupportedActionType): Promise<void> {
|
|
|
|
|
+ const req: CrowiRequest = context.req as CrowiRequest;
|
|
|
|
|
+
|
|
|
|
|
+ const parameters = {
|
|
|
|
|
+ ip: req.ip,
|
|
|
|
|
+ endpoint: req.originalUrl,
|
|
|
|
|
+ action,
|
|
|
|
|
+ user: req.user?._id,
|
|
|
|
|
+ snapshot: {
|
|
|
|
|
+ username: req.user?.username,
|
|
|
|
|
+ },
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ await req.crowi.activityService.createActivity(parameters);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export const getServerSideProps: GetServerSideProps = async(context: GetServerSidePropsContext) => {
|
|
export const getServerSideProps: GetServerSideProps = async(context: GetServerSidePropsContext) => {
|
|
|
const req = context.req as CrowiRequest<IUserHasId & any>;
|
|
const req = context.req as CrowiRequest<IUserHasId & any>;
|
|
|
const { user, crowi } = req;
|
|
const { user, crowi } = req;
|
|
@@ -159,7 +175,6 @@ export const getServerSideProps: GetServerSideProps = async(context: GetServerSi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
injectServerConfigurations(context, props);
|
|
injectServerConfigurations(context, props);
|
|
|
- // await injectUserUISettings(context, props);
|
|
|
|
|
await injectNextI18NextConfigurations(context, props);
|
|
await injectNextI18NextConfigurations(context, props);
|
|
|
|
|
|
|
|
let action: SupportedActionType;
|
|
let action: SupportedActionType;
|
|
@@ -172,7 +187,6 @@ export const getServerSideProps: GetServerSideProps = async(context: GetServerSi
|
|
|
else {
|
|
else {
|
|
|
action = SupportedAction.ACTION_SHARE_LINK_PAGE_VIEW;
|
|
action = SupportedAction.ACTION_SHARE_LINK_PAGE_VIEW;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
await addActivity(context, action);
|
|
await addActivity(context, action);
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
@@ -180,4 +194,5 @@ export const getServerSideProps: GetServerSideProps = async(context: GetServerSi
|
|
|
};
|
|
};
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+
|
|
|
export default SharedPage;
|
|
export default SharedPage;
|