|
|
@@ -80,7 +80,7 @@ export const updatePageHandlersFactory: UpdatePageHandlersFactory = (crowi) => {
|
|
|
];
|
|
|
|
|
|
|
|
|
- async function postAction(req: UpdatePageRequest, res: ApiV3Response, updatedPage: PageDocument) {
|
|
|
+ async function postAction(req: UpdatePageRequest, res: ApiV3Response, updatedPage: PageDocument, previousRevision: IRevisionHasId | null) {
|
|
|
// Reflect the updates in ydoc
|
|
|
const origin = req.body.origin;
|
|
|
if (origin === Origin.View || origin === undefined) {
|
|
|
@@ -111,10 +111,10 @@ export const updatePageHandlersFactory: UpdatePageHandlersFactory = (crowi) => {
|
|
|
}
|
|
|
|
|
|
// user notification
|
|
|
- const { revisionId, isSlackEnabled, slackChannels } = req.body;
|
|
|
+ const { isSlackEnabled, slackChannels } = req.body;
|
|
|
if (isSlackEnabled) {
|
|
|
try {
|
|
|
- const option = revisionId != null ? { previousRevision: revisionId } : undefined;
|
|
|
+ const option = previousRevision != null ? { previousRevision } : undefined;
|
|
|
const results = await crowi.userNotificationService.fire(updatedPage, req.user, slackChannels, 'update', option);
|
|
|
results.forEach((result) => {
|
|
|
if (result.status === 'rejected') {
|
|
|
@@ -159,6 +159,7 @@ export const updatePageHandlersFactory: UpdatePageHandlersFactory = (crowi) => {
|
|
|
}
|
|
|
|
|
|
let updatedPage: PageDocument;
|
|
|
+ let previousRevision: IRevisionHasId | null;
|
|
|
try {
|
|
|
const {
|
|
|
grant, userRelatedGrantUserGroupIds, overwriteScopesOfDescendants, wip,
|
|
|
@@ -168,7 +169,7 @@ export const updatePageHandlersFactory: UpdatePageHandlersFactory = (crowi) => {
|
|
|
options.grant = grant;
|
|
|
options.userRelatedGrantUserGroupIds = userRelatedGrantUserGroupIds;
|
|
|
}
|
|
|
- const previousRevision = await Revision.findById(revisionId);
|
|
|
+ previousRevision = await Revision.findById<IRevisionHasId>(revisionId);
|
|
|
updatedPage = await crowi.pageService.updatePage(currentPage, body, previousRevision?.body ?? null, req.user, options);
|
|
|
}
|
|
|
catch (err) {
|
|
|
@@ -183,7 +184,7 @@ export const updatePageHandlersFactory: UpdatePageHandlersFactory = (crowi) => {
|
|
|
|
|
|
res.apiv3(result, 201);
|
|
|
|
|
|
- postAction(req, res, updatedPage);
|
|
|
+ postAction(req, res, updatedPage, previousRevision);
|
|
|
},
|
|
|
];
|
|
|
};
|