Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3376973
D12265.id41258.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D12265.id41258.diff
View Options
diff --git a/lib/permissions/minimally-encoded-thread-permissions-validators.js b/lib/permissions/minimally-encoded-thread-permissions-validators.js
--- a/lib/permissions/minimally-encoded-thread-permissions-validators.js
+++ b/lib/permissions/minimally-encoded-thread-permissions-validators.js
@@ -5,7 +5,6 @@
import {
roleInfoValidator,
threadCurrentUserInfoValidator,
- memberInfoValidator,
} from './minimally-encoded-raw-thread-info-validators.js';
import { clientAvatarValidator } from '../types/avatar-types.js';
import type {
@@ -14,11 +13,14 @@
} from '../types/minimally-encoded-thread-permissions-types.js';
import { threadTypeValidator } from '../types/thread-types-enum.js';
import { threadEntityValidator } from '../utils/entity-text.js';
-import { tBool, tID, tShape } from '../utils/validation-utils.js';
+import { tBool, tID, tShape, tUserID } from '../utils/validation-utils.js';
const relativeMemberInfoValidator: TInterface<RelativeMemberInfo> =
tShape<RelativeMemberInfo>({
- ...memberInfoValidator.meta.props,
+ id: tUserID,
+ role: t.maybe(tID),
+ minimallyEncoded: tBool(true),
+ isSender: t.Boolean,
username: t.maybe(t.String),
isViewer: t.Boolean,
});
diff --git a/lib/selectors/user-selectors.js b/lib/selectors/user-selectors.js
--- a/lib/selectors/user-selectors.js
+++ b/lib/selectors/user-selectors.js
@@ -65,15 +65,16 @@
const username = userInfos[memberInfo.id]
? userInfos[memberInfo.id].username
: null;
+ const { permissions, ...memberInfoSansPermissions } = memberInfo;
if (memberInfo.id === currentUserID) {
relativeMemberInfos.unshift({
- ...memberInfo,
+ ...memberInfoSansPermissions,
username,
isViewer: true,
});
} else {
relativeMemberInfos.push({
- ...memberInfo,
+ ...memberInfoSansPermissions,
username,
isViewer: false,
});
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -971,6 +971,10 @@
| ServerMemberInfo,
): boolean {
if (memberInfo.minimallyEncoded) {
+ invariant(
+ memberInfo.permissions,
+ 'memberInfo must have permissions field in memberHasAdminPowers',
+ );
return hasPermission(memberInfo.permissions, threadPermissions.CHANGE_ROLE);
}
return !!memberInfo.permissions[threadPermissions.CHANGE_ROLE]?.value;
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
@@ -132,7 +132,10 @@
};
export type RelativeMemberInfo = $ReadOnly<{
- ...MemberInfo,
+ +id: string,
+ +role: ?string,
+ +isSender: boolean,
+ +minimallyEncoded: true,
+username: ?string,
+isViewer: boolean,
}>;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 3:09 AM (21 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2592562
Default Alt Text
D12265.id41258.diff (2 KB)
Attached To
Mode
D12265: [lib] Remove `permissions` field from `ThreadInfo.members[memberID].permissions`
Attached
Detach File
Event Timeline
Log In to Comment