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 @@ -12,13 +12,12 @@ import { 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 { RawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import type { ThinRawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadTypes, type ThreadType } from 'lib/types/thread-types-enum.js'; import { type ServerThreadInfo, - type MixedRawThreadInfos, - type LegacyRawThreadInfo, type ServerLegacyRoleInfo, + type LegacyThinRawThreadInfo, } from 'lib/types/thread-types.js'; import { ServerError } from 'lib/utils/errors.js'; @@ -249,7 +248,9 @@ } export type FetchThreadInfosResult = { - +threadInfos: MixedRawThreadInfos, + +threadInfos: { + +[id: string]: LegacyThinRawThreadInfo | ThinRawThreadInfo, + }, }; async function fetchThreadInfos( @@ -305,7 +306,7 @@ ); const threadInfos: { - [string]: LegacyRawThreadInfo | RawThreadInfo, + [string]: LegacyThinRawThreadInfo | ThinRawThreadInfo, } = {}; for (const threadID in serverResult.threadInfos) { const serverThreadInfo = serverResult.threadInfos[threadID]; 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 @@ -46,6 +46,7 @@ RoleInfo, ThreadInfo, MinimallyEncodedThickMemberInfo, + ThinRawThreadInfo, } from '../types/minimally-encoded-thread-permissions-types.js'; import { decodeMinimallyEncodedRoleInfo, @@ -85,6 +86,7 @@ UserProfileThreadInfo, MixedRawThreadInfos, LegacyMemberInfo, + LegacyThinRawThreadInfo, } from '../types/thread-types.js'; import { updateTypes } from '../types/update-types-enum.js'; import { type ClientUpdateInfo } from '../types/update-types.js'; @@ -710,7 +712,7 @@ serverThreadInfo: ServerThreadInfo, viewerID: string, options?: RawThreadInfoOptions, -): ?LegacyRawThreadInfo | ?RawThreadInfo { +): ?LegacyThinRawThreadInfo | ?ThinRawThreadInfo { const filterThreadEditAvatarPermission = options?.filterThreadEditAvatarPermission; const excludePinInfo = options?.excludePinInfo; @@ -861,6 +863,7 @@ } const minimallyEncoded = minimallyEncodeRawThreadInfo(rawThreadInfo); + invariant(!minimallyEncoded.thick, 'ServerThreadInfo should be thin thread'); if (shouldIncludeSpecialRoleFieldInRoles) { return minimallyEncoded; } 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 @@ -184,7 +184,7 @@ export type ServerThreadInfo = { +id: string, - +type: ThreadType, + +type: ThinThreadType, +name: ?string, +avatar?: AvatarDBContent, +description: ?string,