Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3373274
D12779.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D12779.diff
View Options
diff --git a/keyserver/src/fetchers/thread-fetchers.js b/keyserver/src/fetchers/thread-fetchers.js
--- a/keyserver/src/fetchers/thread-fetchers.js
+++ b/keyserver/src/fetchers/thread-fetchers.js
@@ -10,7 +10,10 @@
getContainingThreadID,
getCommunity,
} from 'lib/shared/thread-utils.js';
-import { hasMinCodeVersion } from 'lib/shared/version-utils.js';
+import {
+ FUTURE_CODE_VERSION,
+ hasMinCodeVersion,
+} from 'lib/shared/version-utils.js';
import type { AvatarDBContent, ClientAvatar } from 'lib/types/avatar-types.js';
import type { RawMessageInfo, MessageInfo } from 'lib/types/message-types.js';
import type { ThinRawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
@@ -305,6 +308,10 @@
web: 88,
},
);
+ const stripMemberPermissions = hasMinCodeVersion(viewer.platformDetails, {
+ native: FUTURE_CODE_VERSION,
+ web: FUTURE_CODE_VERSION,
+ });
const threadInfos: {
[string]: LegacyThinRawThreadInfo | ThinRawThreadInfo,
@@ -324,6 +331,7 @@
allowAddingUsersToCommunityRoot: addingUsersToCommunityRootSupported,
filterManageFarcasterChannelTagsPermission:
manageFarcasterChannelTagsPermissionUnsupported,
+ stripMemberPermissions: stripMemberPermissions,
},
);
if (threadInfo) {
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
@@ -101,6 +101,10 @@
type ThreadEntity,
type UserEntity,
} from '../utils/entity-text.js';
+import {
+ stripMemberPermissionsFromRawThreadInfo,
+ type ThinRawThreadInfoWithPermissions,
+} from '../utils/member-info-utils.js';
import { entries, values } from '../utils/objects.js';
import { useSelector } from '../utils/redux-utils.js';
import { usingOlmViaTunnelbrokerForDMs } from '../utils/services-utils.js';
@@ -703,6 +707,7 @@
+includeSpecialRoleFieldInRoles?: boolean,
+allowAddingUsersToCommunityRoot?: boolean,
+filterManageFarcasterChannelTagsPermission?: boolean,
+ +stripMemberPermissions?: boolean,
};
function rawThreadInfoFromServerThreadInfo(
@@ -724,6 +729,7 @@
options?.allowAddingUsersToCommunityRoot;
const filterManageFarcasterChannelTagsPermission =
options?.filterManageFarcasterChannelTagsPermission;
+ const stripMemberPermissions = options?.stripMemberPermissions;
const filterThreadPermissions = (
innerThreadPermissions: ThreadPermissionsInfo,
@@ -859,27 +865,46 @@
return rawThreadInfo;
}
- const minimallyEncoded =
+ const minimallyEncodedRawThreadInfoWithMemberPermissions =
deprecatedMinimallyEncodeRawThreadInfo(rawThreadInfo);
- invariant(!minimallyEncoded.thick, 'ServerThreadInfo should be thin thread');
- if (shouldIncludeSpecialRoleFieldInRoles) {
- return minimallyEncoded;
+ invariant(
+ !minimallyEncodedRawThreadInfoWithMemberPermissions.thick,
+ 'ServerThreadInfo should be thin thread',
+ );
+
+ if (!shouldIncludeSpecialRoleFieldInRoles) {
+ const minimallyEncodedRolesWithoutSpecialRoleField = Object.fromEntries(
+ entries(minimallyEncodedRawThreadInfoWithMemberPermissions.roles).map(
+ ([key, role]) => [
+ key,
+ {
+ ..._omit('specialRole')(role),
+ isDefault: roleIsDefaultRole(role),
+ },
+ ],
+ ),
+ );
+ return {
+ ...minimallyEncodedRawThreadInfoWithMemberPermissions,
+ roles: minimallyEncodedRolesWithoutSpecialRoleField,
+ };
}
- const minimallyEncodedRolesWithoutSpecialRoleField = Object.fromEntries(
- entries(minimallyEncoded.roles).map(([key, role]) => [
- key,
- {
- ..._omit('specialRole')(role),
- isDefault: roleIsDefaultRole(role),
- },
- ]),
- );
+ if (!stripMemberPermissions) {
+ return minimallyEncodedRawThreadInfoWithMemberPermissions;
+ }
- return {
- ...minimallyEncoded,
- roles: minimallyEncodedRolesWithoutSpecialRoleField,
- };
+ // The return value of `deprecatedMinimallyEncodeRawThreadInfo` is typed
+ // as `RawThreadInfo`, but still includes thread member permissions.
+ // This was to prevent introducing "Legacy" types that would need to be
+ // maintained going forward. This `any`-cast allows us to more precisely
+ // type the obj being passed to `stripMemberPermissionsFromRawThreadInfo`.
+ const rawThreadInfoWithMemberPermissions: ThinRawThreadInfoWithPermissions =
+ (minimallyEncodedRawThreadInfoWithMemberPermissions: any);
+
+ return stripMemberPermissionsFromRawThreadInfo(
+ rawThreadInfoWithMemberPermissions,
+ );
}
function threadUIName(threadInfo: ThreadInfo): string | ThreadEntity {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 8:43 AM (11 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2589925
Default Alt Text
D12779.diff (4 KB)
Attached To
Mode
D12779: [keyserver] Strip `member.permissions` for `FUTURE_CODE_VERSION` clients
Attached
Detach File
Event Timeline
Log In to Comment