|
|
@@ -1,6 +1,8 @@
|
|
|
import { pagePathUtils } from '@growi/core';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
+import Subscription, { STATUS_SUBSCRIBE } from '~/server/models/subscription';
|
|
|
+
|
|
|
const logger = loggerFactory('growi:routes:apiv3:pages'); // eslint-disable-line no-unused-vars
|
|
|
const express = require('express');
|
|
|
const pathUtils = require('growi-commons').pathUtils;
|
|
|
@@ -293,6 +295,8 @@ module.exports = (crowi) => {
|
|
|
Page.applyScopesToDescendantsAsyncronously(createdPage, req.user);
|
|
|
}
|
|
|
|
|
|
+ res.apiv3(result, 201);
|
|
|
+
|
|
|
try {
|
|
|
// global notification
|
|
|
await globalNotificationService.fire(GlobalNotificationSetting.EVENT.PAGE_CREATE, createdPage, req.user);
|
|
|
@@ -316,7 +320,13 @@ module.exports = (crowi) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return res.apiv3(result, 201);
|
|
|
+ // create subscription
|
|
|
+ try {
|
|
|
+ await Subscription.subscribeByPageId(req.user._id, createdPage._id, STATUS_SUBSCRIBE);
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ logger.error('Failed to create subscription document', err);
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
|