|
@@ -1053,32 +1053,23 @@ module.exports = function(crowi) {
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- pageSchema.statics.updatePage = function(pageData, body, user, options) {
|
|
|
|
|
|
|
+ pageSchema.statics.updatePage = async function(pageData, body, user, options) {
|
|
|
var Page = this
|
|
var Page = this
|
|
|
, Revision = crowi.model('Revision')
|
|
, Revision = crowi.model('Revision')
|
|
|
, grant = options.grant || null
|
|
, grant = options.grant || null
|
|
|
, grantUserGroupId = options.grantUserGroupId || null
|
|
, grantUserGroupId = options.grantUserGroupId || null
|
|
|
;
|
|
;
|
|
|
// update existing page
|
|
// update existing page
|
|
|
- var newRevision = Revision.prepareRevision(pageData, body, user);
|
|
|
|
|
|
|
+ var newRevision = await Revision.prepareRevision(pageData, body, user);
|
|
|
|
|
|
|
|
- let savedPage = undefined;
|
|
|
|
|
- return Page.pushRevision(pageData, newRevision, user)
|
|
|
|
|
- .then((revision) => {
|
|
|
|
|
- // fetch Page
|
|
|
|
|
- return Page.findPageByPath(revision.path).populate('revision');
|
|
|
|
|
- })
|
|
|
|
|
- .then((page) => {
|
|
|
|
|
- savedPage = page;
|
|
|
|
|
- })
|
|
|
|
|
- .then(() => {
|
|
|
|
|
- return Page.updateGrant(savedPage, grant, user, grantUserGroupId);
|
|
|
|
|
- })
|
|
|
|
|
- .then((data) => {
|
|
|
|
|
- debug('Page grant update:', data);
|
|
|
|
|
- pageEvent.emit('update', savedPage, user);
|
|
|
|
|
- return savedPage;
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ const revision = await Page.pushRevision(pageData, newRevision, user);
|
|
|
|
|
+ const savedPage = await Page.findPageByPath(revision.path).populate('revision');
|
|
|
|
|
+ if (grant != null) {
|
|
|
|
|
+ const grantData = await Page.updateGrant(savedPage, grant, user, grantUserGroupId);
|
|
|
|
|
+ debug('Page grant update:', grantData);
|
|
|
|
|
+ }
|
|
|
|
|
+ pageEvent.emit('update', savedPage, user);
|
|
|
|
|
+ return savedPage;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
pageSchema.statics.deletePage = function(pageData, user, options) {
|
|
pageSchema.statics.deletePage = function(pageData, user, options) {
|