|
@@ -65,6 +65,18 @@ type PaginatedPages = {
|
|
|
offset: number
|
|
offset: number
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+export type FindRecentUpdatedPagesOption = {
|
|
|
|
|
+ offset: number,
|
|
|
|
|
+ limit: number,
|
|
|
|
|
+ includeWipPage: boolean,
|
|
|
|
|
+ includeTrashed: boolean,
|
|
|
|
|
+ isRegExpEscapedFromPath: boolean,
|
|
|
|
|
+ sort: 'updatedAt'
|
|
|
|
|
+ desc: number
|
|
|
|
|
+ hideRestrictedByOwner: boolean,
|
|
|
|
|
+ hideRestrictedByGroup: boolean,
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export type CreateMethod = (path: string, body: string, user, options: IOptionsForCreate) => Promise<HydratedDocument<PageDocument>>
|
|
export type CreateMethod = (path: string, body: string, user, options: IOptionsForCreate) => Promise<HydratedDocument<PageDocument>>
|
|
|
|
|
|
|
|
export interface PageModel extends Model<PageDocument> {
|
|
export interface PageModel extends Model<PageDocument> {
|
|
@@ -79,7 +91,7 @@ export interface PageModel extends Model<PageDocument> {
|
|
|
countByPathAndViewer(path: string | null, user, userGroups?, includeEmpty?:boolean): Promise<number>
|
|
countByPathAndViewer(path: string | null, user, userGroups?, includeEmpty?:boolean): Promise<number>
|
|
|
findParentByPath(path: string | null): Promise<HydratedDocument<PageDocument> | null>
|
|
findParentByPath(path: string | null): Promise<HydratedDocument<PageDocument> | null>
|
|
|
findTargetAndAncestorsByPathOrId(pathOrId: string): Promise<TargetAndAncestorsResult>
|
|
findTargetAndAncestorsByPathOrId(pathOrId: string): Promise<TargetAndAncestorsResult>
|
|
|
- findRecentUpdatedPages(path: string, user, option, includeEmpty?: boolean): Promise<PaginatedPages>
|
|
|
|
|
|
|
+ findRecentUpdatedPages(path: string, user, option: FindRecentUpdatedPagesOption, includeEmpty?: boolean): Promise<PaginatedPages>
|
|
|
generateGrantCondition(
|
|
generateGrantCondition(
|
|
|
user, userGroups: ObjectIdLike[] | null, includeAnyoneWithTheLink?: boolean, showPagesRestrictedByOwner?: boolean, showPagesRestrictedByGroup?: boolean,
|
|
user, userGroups: ObjectIdLike[] | null, includeAnyoneWithTheLink?: boolean, showPagesRestrictedByOwner?: boolean, showPagesRestrictedByGroup?: boolean,
|
|
|
): { $or: any[] }
|
|
): { $or: any[] }
|
|
@@ -414,13 +426,19 @@ export class PageQueryBuilder {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// add viewer condition to PageQueryBuilder instance
|
|
// add viewer condition to PageQueryBuilder instance
|
|
|
- async addViewerCondition(user, userGroups = null, includeAnyoneWithTheLink = false): Promise<PageQueryBuilder> {
|
|
|
|
|
|
|
+ async addViewerCondition(
|
|
|
|
|
+ user,
|
|
|
|
|
+ userGroups = null,
|
|
|
|
|
+ includeAnyoneWithTheLink = false,
|
|
|
|
|
+ showPagesRestrictedByOwner = false,
|
|
|
|
|
+ showPagesRestrictedByGroup = false,
|
|
|
|
|
+ ): Promise<PageQueryBuilder> {
|
|
|
const relatedUserGroups = (user != null && userGroups == null) ? [
|
|
const relatedUserGroups = (user != null && userGroups == null) ? [
|
|
|
...(await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user)),
|
|
...(await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user)),
|
|
|
...(await ExternalUserGroupRelation.findAllUserGroupIdsRelatedToUser(user)),
|
|
...(await ExternalUserGroupRelation.findAllUserGroupIdsRelatedToUser(user)),
|
|
|
] : userGroups;
|
|
] : userGroups;
|
|
|
|
|
|
|
|
- this.addConditionToFilteringByViewer(user, relatedUserGroups, includeAnyoneWithTheLink);
|
|
|
|
|
|
|
+ this.addConditionToFilteringByViewer(user, relatedUserGroups, includeAnyoneWithTheLink, showPagesRestrictedByOwner, showPagesRestrictedByGroup);
|
|
|
return this;
|
|
return this;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -664,7 +682,7 @@ schema.statics.countByPathAndViewer = async function(path: string | null, user,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
schema.statics.findRecentUpdatedPages = async function(
|
|
schema.statics.findRecentUpdatedPages = async function(
|
|
|
- path: string, user, options, includeEmpty = false,
|
|
|
|
|
|
|
+ path: string, user, options: FindRecentUpdatedPagesOption, includeEmpty = false,
|
|
|
): Promise<PaginatedPages> {
|
|
): Promise<PaginatedPages> {
|
|
|
|
|
|
|
|
const sortOpt = {};
|
|
const sortOpt = {};
|
|
@@ -690,7 +708,7 @@ schema.statics.findRecentUpdatedPages = async function(
|
|
|
|
|
|
|
|
queryBuilder.addConditionToListWithDescendants(path, options);
|
|
queryBuilder.addConditionToListWithDescendants(path, options);
|
|
|
queryBuilder.populateDataToList(User.USER_FIELDS_EXCEPT_CONFIDENTIAL);
|
|
queryBuilder.populateDataToList(User.USER_FIELDS_EXCEPT_CONFIDENTIAL);
|
|
|
- await queryBuilder.addViewerCondition(user);
|
|
|
|
|
|
|
+ await queryBuilder.addViewerCondition(user, undefined, undefined, !options.hideRestrictedByOwner, !options.hideRestrictedByGroup);
|
|
|
const pages = await Page.paginate(queryBuilder.query.clone(), {
|
|
const pages = await Page.paginate(queryBuilder.query.clone(), {
|
|
|
lean: true, sort: sortOpt, offset: options.offset, limit: options.limit,
|
|
lean: true, sort: sortOpt, offset: options.offset, limit: options.limit,
|
|
|
});
|
|
});
|