Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3179671
D12779.id42415.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.id42415.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,49 @@
return rawThreadInfo;
}
- const minimallyEncoded =
+ const minimallyEncodedRawThreadInfoWithMemberPermissions =
deprecatedMinimallyEncodeRawThreadInfo(rawThreadInfo);
- invariant(!minimallyEncoded.thick, 'ServerThreadInfo should be thin thread');
+ invariant(
+ !minimallyEncodedRawThreadInfoWithMemberPermissions.thick,
+ 'ServerThreadInfo should be thin thread',
+ );
if (shouldIncludeSpecialRoleFieldInRoles) {
- return minimallyEncoded;
+ return minimallyEncodedRawThreadInfoWithMemberPermissions;
}
const minimallyEncodedRolesWithoutSpecialRoleField = Object.fromEntries(
- entries(minimallyEncoded.roles).map(([key, role]) => [
- key,
- {
- ..._omit('specialRole')(role),
- isDefault: roleIsDefaultRole(role),
- },
- ]),
+ entries(minimallyEncodedRawThreadInfoWithMemberPermissions.roles).map(
+ ([key, role]) => [
+ key,
+ {
+ ..._omit('specialRole')(role),
+ isDefault: roleIsDefaultRole(role),
+ },
+ ],
+ ),
);
- return {
- ...minimallyEncoded,
- roles: minimallyEncodedRolesWithoutSpecialRoleField,
- };
+ if (!stripMemberPermissions) {
+ return {
+ ...minimallyEncodedRawThreadInfoWithMemberPermissions,
+ 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,
+ roles: minimallyEncodedRolesWithoutSpecialRoleField,
+ }: any);
+
+ return stripMemberPermissionsFromRawThreadInfo(
+ rawThreadInfoWithMemberPermissions,
+ );
}
function threadUIName(threadInfo: ThreadInfo): string | ThreadEntity {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 9, 3:25 AM (18 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2448170
Default Alt Text
D12779.id42415.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