|
|
@@ -37,8 +37,6 @@ module.exports = function(crowi) {
|
|
|
grant: { type: Number, default: GRANT_PUBLIC, index: true },
|
|
|
grantedUsers: [{ type: ObjectId, ref: 'User' }],
|
|
|
creator: { type: ObjectId, ref: 'User', index: true },
|
|
|
- // lastUpdateUser: this schema is from 1.5.x (by deletion feature), and null is default.
|
|
|
- // the last update user on the screen is by revesion.author for B.C.
|
|
|
lastUpdateUser: { type: ObjectId, ref: 'User', index: true },
|
|
|
liker: [{ type: ObjectId, ref: 'User', index: true }],
|
|
|
seenUsers: [{ type: ObjectId, ref: 'User', index: true }],
|
|
|
@@ -263,8 +261,8 @@ module.exports = function(crowi) {
|
|
|
};
|
|
|
|
|
|
pageSchema.statics.populatePageData = function(pageData, revisionId) {
|
|
|
- var Page = crowi.model('Page');
|
|
|
- var User = crowi.model('User');
|
|
|
+ const Page = crowi.model('Page');
|
|
|
+ const User = crowi.model('User');
|
|
|
|
|
|
pageData.latestRevision = pageData.revision;
|
|
|
if (revisionId) {
|
|
|
@@ -491,8 +489,8 @@ module.exports = function(crowi) {
|
|
|
|
|
|
// find page and check if granted user
|
|
|
pageSchema.statics.findPage = function(path, userData, revisionId, ignoreNotFound) {
|
|
|
- var self = this;
|
|
|
- var PageGroupRelation = crowi.model('PageGroupRelation');
|
|
|
+ const self = this;
|
|
|
+ const PageGroupRelation = crowi.model('PageGroupRelation');
|
|
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
self.findOne({path: path}, function(err, pageData) {
|
|
|
@@ -505,7 +503,7 @@ module.exports = function(crowi) {
|
|
|
return resolve(null);
|
|
|
}
|
|
|
|
|
|
- var pageNotFoundError = new Error('Page Not Found');
|
|
|
+ const pageNotFoundError = new Error('Page Not Found');
|
|
|
pageNotFoundError.name = 'Crowi:Page:NotFound';
|
|
|
return reject(pageNotFoundError);
|
|
|
}
|
|
|
@@ -641,12 +639,12 @@ module.exports = function(crowi) {
|
|
|
};
|
|
|
|
|
|
pageSchema.statics.findListByPageIds = function(ids, options) {
|
|
|
- var Page = this;
|
|
|
- var User = crowi.model('User');
|
|
|
- var options = options || {}
|
|
|
- , limit = options.limit || 50
|
|
|
+ const Page = this;
|
|
|
+ const User = crowi.model('User');
|
|
|
+ const limit = options.limit || 50
|
|
|
, offset = options.skip || 0
|
|
|
;
|
|
|
+ options = options || {};
|
|
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
Page
|
|
|
@@ -663,7 +661,7 @@ module.exports = function(crowi) {
|
|
|
return reject(err);
|
|
|
}
|
|
|
|
|
|
- Page.populate(pages, {path: 'revision.author', model: 'User', select: User.USER_PUBLIC_FIELDS}, function(err, data) {
|
|
|
+ Page.populate(pages, {path: 'lastUpdateUser', model: 'User', select: User.USER_PUBLIC_FIELDS}, function(err, data) {
|
|
|
if (err) {
|
|
|
return reject(err);
|
|
|
}
|
|
|
@@ -715,7 +713,7 @@ module.exports = function(crowi) {
|
|
|
.populate('revision')
|
|
|
.exec()
|
|
|
.then(function(pages) {
|
|
|
- return Page.populate(pages, {path: 'revision.author', model: 'User', select: User.USER_PUBLIC_FIELDS}).then(resolve);
|
|
|
+ return Page.populate(pages, {path: 'lastUpdateUser', model: 'User', select: User.USER_PUBLIC_FIELDS}).then(resolve);
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
@@ -796,7 +794,7 @@ module.exports = function(crowi) {
|
|
|
|
|
|
q.exec()
|
|
|
.then(function(pages) {
|
|
|
- Page.populate(pages, {path: 'revision.author', model: 'User', select: User.USER_PUBLIC_FIELDS})
|
|
|
+ Page.populate(pages, {path: 'lastUpdateUser', model: 'User', select: User.USER_PUBLIC_FIELDS})
|
|
|
.then(resolve)
|
|
|
.catch(reject);
|
|
|
});
|