Procházet zdrojové kódy

Implementing canOverwriteDescendants WIP

Taichi Masuyama před 3 roky
rodič
revize
a3b271f559
1 změnil soubory, kde provedl 9 přidání a 3 odebrání
  1. 9 3
      packages/app/src/server/service/page-grant.ts

+ 9 - 3
packages/app/src/server/service/page-grant.ts

@@ -508,15 +508,21 @@ class PageGrantService {
   /**
   /**
    * see: https://dev.growi.org/635a314eac6bcd85cbf359fc
    * see: https://dev.growi.org/635a314eac6bcd85cbf359fc
    * @param operator
    * @param operator
-   * @param updateGrantInfo
+   * @param {UpdateGrantInfo} updateGrantInfo
    * @returns {Promise<boolean>}
    * @returns {Promise<boolean>}
    */
    */
-  async canOverwriteDescendants(operator, updateGrantInfo: UpdateGrantInfo): Promise<boolean> {
+  async canOverwriteDescendants(operator: { _id: ObjectIdLike }, updateGrantInfo: UpdateGrantInfo): Promise<boolean> {
+    const UserGroupRelationModel = mongoose.model('UserGroupRelation') as any; // TODO: TypeScriptize model
 
 
+    // TODO: impl
+    const relations = await UserGroupRelationModel.findAllRelationForUser(operator);
     const operatorGrantInfo = {
     const operatorGrantInfo = {
       userId: operator._id,
       userId: operator._id,
-      userGroupIds: new Set([]),
+      userGroupIds: new Set<ObjectIdLike>(relations.map(r => r.relatedGroup._id)),
     };
     };
+    // TODO:
+    //   - find all descendant pages
+    //   - merge grant info of them
     const descendantPagesGrantInfo = {
     const descendantPagesGrantInfo = {
       grantSet: new Set([1, 4, 5]),
       grantSet: new Set([1, 4, 5]),
       grantedUserIds: new Set(['', '']), // only me users
       grantedUserIds: new Set(['', '']), // only me users