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 @@ -15,7 +15,7 @@ MinimallyEncodedThreadInfo, } from '../types/minimally-encoded-thread-permissions-types.js'; import { - memberInfoValidator, + legacyMemberInfoValidator, rawThreadInfoValidator, legacyRoleInfoValidator, threadCurrentUserInfoValidator, @@ -39,7 +39,7 @@ const minimallyEncodedMemberInfoValidator: TInterface = tShape({ - ...memberInfoValidator.meta.props, + ...legacyMemberInfoValidator.meta.props, minimallyEncoded: tBool(true), permissions: tHexEncodedPermissionsBitmask, }); 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 @@ -84,7 +84,7 @@ import { type RawThreadInfo, type ThreadInfo, - type MemberInfo, + type LegacyMemberInfo, type ServerThreadInfo, type RelativeMemberInfo, type ThreadCurrentUserInfo, @@ -278,7 +278,7 @@ function threadActualMembers( memberInfos: $ReadOnlyArray< - | MemberInfo + | LegacyMemberInfo | RelativeMemberInfo | MinimallyEncodedMemberInfo | MinimallyEncodedRelativeMemberInfo, @@ -291,7 +291,7 @@ function threadOtherMembers< T: - | MemberInfo + | LegacyMemberInfo | RelativeMemberInfo | MinimallyEncodedMemberInfo | MinimallyEncodedRelativeMemberInfo, @@ -1139,7 +1139,7 @@ function memberIsAdmin( memberInfo: | RelativeMemberInfo - | MemberInfo + | LegacyMemberInfo | MinimallyEncodedMemberInfo | MinimallyEncodedRelativeMemberInfo, threadInfo: @@ -1158,7 +1158,7 @@ function memberHasAdminPowers( memberInfo: | RelativeMemberInfo - | MemberInfo + | LegacyMemberInfo | ServerMemberInfo | MinimallyEncodedMemberInfo | MinimallyEncodedRelativeMemberInfo, 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 @@ -3,7 +3,7 @@ import _mapValues from 'lodash/fp/mapValues.js'; import type { - MemberInfo, + LegacyMemberInfo, RawThreadInfo, RelativeMemberInfo, LegacyRoleInfo, @@ -70,13 +70,13 @@ }; export type MinimallyEncodedMemberInfo = $ReadOnly<{ - ...MemberInfo, + ...LegacyMemberInfo, +minimallyEncoded: true, +permissions: string, }>; const minimallyEncodeMemberInfo = ( - memberInfo: MemberInfo, + memberInfo: LegacyMemberInfo, ): MinimallyEncodedMemberInfo => ({ ...memberInfo, minimallyEncoded: true, @@ -85,7 +85,7 @@ const decodeMinimallyEncodedMemberInfo = ( minimallyEncodedMemberInfo: MinimallyEncodedMemberInfo, -): MemberInfo => { +): LegacyMemberInfo => { const { minimallyEncoded, ...rest } = minimallyEncodedMemberInfo; return { ...rest, diff --git a/lib/types/thread-types.js b/lib/types/thread-types.js --- a/lib/types/thread-types.js +++ b/lib/types/thread-types.js @@ -39,26 +39,27 @@ } from '../utils/entity-text.js'; import { tID, tShape } from '../utils/validation-utils.js'; -export type MemberInfo = { +export type LegacyMemberInfo = { +id: string, +role: ?string, +permissions: ThreadPermissionsInfo, +isSender: boolean, }; -export const memberInfoValidator: TInterface = tShape({ - id: t.String, - role: t.maybe(tID), - permissions: threadPermissionsInfoValidator, - isSender: t.Boolean, -}); +export const legacyMemberInfoValidator: TInterface = + tShape({ + id: t.String, + role: t.maybe(tID), + permissions: threadPermissionsInfoValidator, + isSender: t.Boolean, + }); export type RelativeMemberInfo = $ReadOnly<{ - ...MemberInfo, + ...LegacyMemberInfo, +username: ?string, +isViewer: boolean, }>; const relativeMemberInfoValidator = tShape({ - ...memberInfoValidator.meta.props, + ...legacyMemberInfoValidator.meta.props, username: t.maybe(t.String), isViewer: t.Boolean, }); @@ -104,7 +105,7 @@ +parentThreadID: ?string, +containingThreadID: ?string, +community: ?string, - +members: $ReadOnlyArray, + +members: $ReadOnlyArray, +roles: { +[id: string]: LegacyRoleInfo }, +currentUser: ThreadCurrentUserInfo, +sourceMessageID?: string, @@ -126,7 +127,7 @@ parentThreadID: t.maybe(tID), containingThreadID: t.maybe(tID), community: t.maybe(tID), - members: t.list(memberInfoValidator), + members: t.list(legacyMemberInfoValidator), roles: t.dict(tID, legacyRoleInfoValidator), currentUser: threadCurrentUserInfoValidator, sourceMessageID: t.maybe(tID), diff --git a/native/redux/edit-thread-permission-migration.js b/native/redux/edit-thread-permission-migration.js --- a/native/redux/edit-thread-permission-migration.js +++ b/native/redux/edit-thread-permission-migration.js @@ -2,7 +2,7 @@ import { threadTypes } from 'lib/types/thread-types-enum.js'; import type { - MemberInfo, + LegacyMemberInfo, ThreadCurrentUserInfo, RawThreadInfo, LegacyRoleInfo, @@ -10,7 +10,7 @@ } from 'lib/types/thread-types.js'; function addDetailedThreadEditPermissionsToUser< - T: MemberInfo | ThreadCurrentUserInfo, + T: LegacyMemberInfo | ThreadCurrentUserInfo, >(threadInfo: RawThreadInfo, member: T, threadID: string): T { let newPermissions = null; if (threadInfo.type === threadTypes.PRIVATE) { diff --git a/native/redux/manage-pins-permission-migration.js b/native/redux/manage-pins-permission-migration.js --- a/native/redux/manage-pins-permission-migration.js +++ b/native/redux/manage-pins-permission-migration.js @@ -2,7 +2,7 @@ import type { RawThreadInfo, - MemberInfo, + LegacyMemberInfo, ThreadCurrentUserInfo, LegacyRoleInfo, RawThreadInfos, @@ -13,7 +13,7 @@ const adminRoleName = 'Admins'; function addManagePinsThreadPermissionToUser< - TargetMemberInfo: MemberInfo | ThreadCurrentUserInfo, + TargetMemberInfo: LegacyMemberInfo | ThreadCurrentUserInfo, >( threadInfo: RawThreadInfo, member: TargetMemberInfo, diff --git a/native/redux/update-roles-and-permissions.js b/native/redux/update-roles-and-permissions.js --- a/native/redux/update-roles-and-permissions.js +++ b/native/redux/update-roles-and-permissions.js @@ -10,7 +10,7 @@ import type { RawThreadInfo, ThreadStoreThreadInfos, - MemberInfo, + LegacyMemberInfo, } from 'lib/types/thread-types.js'; import { values } from 'lib/utils/objects.js'; @@ -84,7 +84,7 @@ const memberToThreadPermissionsForChildren: { [string]: ?ThreadPermissionsBlob, } = {}; - for (const member: MemberInfo of threadInfo.members) { + for (const member: LegacyMemberInfo of threadInfo.members) { const { id, role } = member; const rolePermissions = role ? threadInfo.roles[role].permissions : null;