Page MenuHomePhabricator

D11253.id38204.diff
No OneTemporary

D11253.id38204.diff

diff --git a/lib/permissions/minimally-encoded-raw-thread-info-validators.js b/lib/permissions/minimally-encoded-raw-thread-info-validators.js
--- a/lib/permissions/minimally-encoded-raw-thread-info-validators.js
+++ b/lib/permissions/minimally-encoded-raw-thread-info-validators.js
@@ -17,7 +17,6 @@
type LegacyRawThreadInfo,
legacyMemberInfoValidator,
legacyRawThreadInfoValidator,
- clientLegacyRoleInfoValidator,
legacyThreadCurrentUserInfoValidator,
} from '../types/thread-types.js';
import { tBool, tID, tShape } from '../utils/validation-utils.js';
@@ -30,7 +29,8 @@
});
const roleInfoValidator: TInterface<RoleInfo> = tShape<RoleInfo>({
- ...clientLegacyRoleInfoValidator.meta.props,
+ id: tID,
+ name: t.String,
minimallyEncoded: tBool(true),
permissions: t.list(tHexEncodedRolePermission),
specialRole: t.maybe(specialRoleValidator),
diff --git a/lib/permissions/minimally-encoded-thread-permissions-test-data.js b/lib/permissions/minimally-encoded-thread-permissions-test-data.js
--- a/lib/permissions/minimally-encoded-thread-permissions-test-data.js
+++ b/lib/permissions/minimally-encoded-thread-permissions-test-data.js
@@ -351,7 +351,6 @@
'015',
'0a9',
],
- isDefault: true,
},
},
currentUser: {
diff --git a/lib/permissions/minimally-encoded-thread-permissions.test.js b/lib/permissions/minimally-encoded-thread-permissions.test.js
--- a/lib/permissions/minimally-encoded-thread-permissions.test.js
+++ b/lib/permissions/minimally-encoded-thread-permissions.test.js
@@ -347,7 +347,6 @@
id: 'roleID',
name: 'roleName',
permissions: ['abc', 'def'],
- isDefault: true,
specialRole: specialRoles.DEFAULT_ROLE,
}),
).toBe(true);
diff --git a/lib/permissions/special-roles.test.js b/lib/permissions/special-roles.test.js
--- a/lib/permissions/special-roles.test.js
+++ b/lib/permissions/special-roles.test.js
@@ -16,7 +16,7 @@
id: 'roleID',
name: 'roleName',
permissions: ['abc', 'def'],
- isDefault: true,
+ specialRole: specialRoles.DEFAULT_ROLE,
};
const patchedRole = patchRoleInfoWithSpecialRole(role);
expect(patchedRole.specialRole).toBe(specialRoles.DEFAULT_ROLE);
@@ -28,7 +28,6 @@
id: 'roleID',
name: 'Admins',
permissions: ['abc', 'def'],
- isDefault: false,
};
const patchedRole = patchRoleInfoWithSpecialRole(role);
expect(patchedRole.specialRole).toBe(specialRoles.ADMIN_ROLE);
@@ -40,7 +39,6 @@
id: 'roleID',
name: 'BLAH',
permissions: ['abc', 'def'],
- isDefault: false,
};
const patchedRole = patchRoleInfoWithSpecialRole(role);
expect(patchedRole.specialRole).toBe(undefined);
@@ -81,8 +79,8 @@
id: '256|83795',
name: 'Members',
permissions: ['000', '010', '005', '015', '0a7'],
- isDefault: true,
minimallyEncoded: true,
+ specialRole: specialRoles.DEFAULT_ROLE,
},
'256|83796': {
id: '256|83796',
@@ -127,7 +125,6 @@
'134',
'156',
],
- isDefault: false,
minimallyEncoded: true,
},
},
@@ -192,7 +189,6 @@
'015',
'0a9',
],
- isDefault: false,
minimallyEncoded: true,
},
},
diff --git a/lib/reducers/calendar-filters-reducer.test.js b/lib/reducers/calendar-filters-reducer.test.js
--- a/lib/reducers/calendar-filters-reducer.test.js
+++ b/lib/reducers/calendar-filters-reducer.test.js
@@ -48,14 +48,12 @@
id: '256|83795',
name: 'Members',
permissions: ['000', '010', '005', '015', '0a7'],
- isDefault: true,
minimallyEncoded: true,
},
'256|83796': {
id: '256|83796',
name: 'Admins',
permissions: ['000', '010', '005', '015', '0a7'],
- isDefault: false,
minimallyEncoded: true,
},
},
@@ -105,7 +103,6 @@
id: '256|83816',
name: 'Members',
permissions: ['000', '010', '005', '015', '0a7'],
- isDefault: true,
minimallyEncoded: true,
},
},
diff --git a/lib/shared/thread-utils.test.js b/lib/shared/thread-utils.test.js
--- a/lib/shared/thread-utils.test.js
+++ b/lib/shared/thread-utils.test.js
@@ -107,7 +107,6 @@
id: '83795',
name: 'Members',
permissions: ['000', '010', '005', '015', '0a7'],
- isDefault: true,
minimallyEncoded: true,
},
'83796': {
@@ -153,7 +152,6 @@
'134',
'156',
],
- isDefault: false,
minimallyEncoded: true,
},
},
diff --git a/lib/types/minimally-encoded-thread-permissions-types.js b/lib/types/minimally-encoded-thread-permissions-types.js
--- a/lib/types/minimally-encoded-thread-permissions-types.js
+++ b/lib/types/minimally-encoded-thread-permissions-types.js
@@ -18,10 +18,13 @@
threadRolePermissionsBlobToBitmaskArray,
} from '../permissions/minimally-encoded-thread-permissions.js';
import type { SpecialRole } from '../permissions/special-roles.js';
+import { specialRoles } from '../permissions/special-roles.js';
+import { roleIsAdminRole, roleIsDefaultRole } from '../shared/thread-utils.js';
import type { ThreadEntity } from '../utils/entity-text.js';
export type RoleInfo = $ReadOnly<{
- ...ClientLegacyRoleInfo,
+ +id: string,
+ +name: string,
+minimallyEncoded: true,
+permissions: $ReadOnlyArray<string>,
+specialRole?: ?SpecialRole,
@@ -32,10 +35,18 @@
!('minimallyEncoded' in roleInfo),
'roleInfo is already minimally encoded.',
);
+ let specialRole: ?SpecialRole;
+ if (roleIsDefaultRole(roleInfo)) {
+ specialRole = specialRoles.DEFAULT_ROLE;
+ } else if (roleIsAdminRole(roleInfo)) {
+ specialRole = specialRoles.ADMIN_ROLE;
+ }
+ const { isDefault, ...rest } = roleInfo;
return {
- ...roleInfo,
+ ...rest,
minimallyEncoded: true,
permissions: threadRolePermissionsBlobToBitmaskArray(roleInfo.permissions),
+ specialRole,
};
};
@@ -48,6 +59,7 @@
permissions: decodeThreadRolePermissionsBitmaskArray(
minimallyEncodedRoleInfo.permissions,
),
+ isDefault: roleIsDefaultRole(minimallyEncodedRoleInfo),
};
};

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 7:02 AM (18 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2569547
Default Alt Text
D11253.id38204.diff (6 KB)

Event Timeline