diff --git a/lib/permissions/thread-permissions.js b/lib/permissions/thread-permissions.js --- a/lib/permissions/thread-permissions.js +++ b/lib/permissions/thread-permissions.js @@ -2,17 +2,16 @@ import invariant from 'invariant'; -import { getThickThreadRolePermissionsBlob } from './dm-permissions.js'; -import { - type RolePermissionBlobs, - getThinThreadPermissionsBlobs, -} from './keyserver-permissions.js'; +import { type RolePermissionBlobs } from './keyserver-permissions.js'; import { parseThreadPermissionString, constructThreadPermissionString, includeThreadPermissionForThreadType, } from './prefixes.js'; -import { threadTypeIsAnnouncementThread } from '../shared/threads/thread-specs.js'; +import { + threadSpecs, + threadTypeIsAnnouncementThread, +} from '../shared/threads/thread-specs.js'; import { threadPermissionPropagationPrefixes, threadPermissions, @@ -26,13 +25,7 @@ ThreadPermissionsInfo, ThreadRolePermissionsBlob, } from '../types/thread-permission-types.js'; -import { - type ThreadType, - threadTypes, - threadTypeIsThick, - assertThickThreadType, - assertThinThreadType, -} from '../types/thread-types-enum.js'; +import { type ThreadType, threadTypes } from '../types/thread-types-enum.js'; function permissionLookup( permissions: ?ThreadPermissionsBlob | ?ThreadPermissionsInfo, @@ -201,17 +194,7 @@ } function getRolePermissionBlobs(threadType: ThreadType): RolePermissionBlobs { - if (threadTypeIsThick(threadType)) { - const thickThreadType = assertThickThreadType(threadType); - const memberPermissions = - getThickThreadRolePermissionsBlob(thickThreadType); - return { - Members: memberPermissions, - }; - } - - const thinThreadType = assertThinThreadType(threadType); - return getThinThreadPermissionsBlobs(thinThreadType); + return threadSpecs[threadType].protocol.getRolePermissionBlobs(threadType); } export { diff --git a/lib/shared/threads/protocols/dm-thread-protocol.js b/lib/shared/threads/protocols/dm-thread-protocol.js --- a/lib/shared/threads/protocols/dm-thread-protocol.js +++ b/lib/shared/threads/protocols/dm-thread-protocol.js @@ -4,6 +4,7 @@ import uuid from 'uuid'; import { fetchMessagesBeforeCursorActionTypes } from '../../../actions/message-actions.js'; +import { getThickThreadRolePermissionsBlob } from '../../../permissions/dm-permissions.js'; import type { TunnelbrokerSocketState } from '../../../tunnelbroker/tunnelbroker-context.js'; import type { DMChangeThreadReadStatusOperation, @@ -33,6 +34,7 @@ assertThickThreadType, thickThreadTypes, threadTypes, + type ThreadType, } from '../../../types/thread-types-enum.js'; import type { ChangeThreadSettingsPayload, @@ -791,6 +793,15 @@ }; }, + getRolePermissionBlobs: (threadType: ThreadType) => { + const thickThreadType = assertThickThreadType(threadType); + const memberPermissions = + getThickThreadRolePermissionsBlob(thickThreadType); + return { + Members: memberPermissions, + }; + }, + allowsDeletingSidebarSource: false, presentationDetails: { diff --git a/lib/shared/threads/protocols/keyserver-thread-protocol.js b/lib/shared/threads/protocols/keyserver-thread-protocol.js --- a/lib/shared/threads/protocols/keyserver-thread-protocol.js +++ b/lib/shared/threads/protocols/keyserver-thread-protocol.js @@ -24,6 +24,7 @@ encryptedMediaBlobURI, encryptedVideoThumbnailBlobURI, } from '../../../media/media-utils.js'; +import { getThinThreadPermissionsBlobs } from '../../../permissions/keyserver-permissions.js'; import type { TunnelbrokerSocketState } from '../../../tunnelbroker/tunnelbroker-context.js'; import type { BlobOperation } from '../../../types/holder-types.js'; import { @@ -55,6 +56,7 @@ assertThinThreadType, thinThreadTypes, threadTypes, + type ThreadType, } from '../../../types/thread-types-enum.js'; import type { ClientDBThreadInfo } from '../../../types/thread-types.js'; import { @@ -590,6 +592,11 @@ }; }, + getRolePermissionBlobs: (threadType: ThreadType) => { + const thinThreadType = assertThinThreadType(threadType); + return getThinThreadPermissionsBlobs(thinThreadType); + }, + allowsDeletingSidebarSource: true, presentationDetails: { diff --git a/lib/shared/threads/thread-spec.js b/lib/shared/threads/thread-spec.js --- a/lib/shared/threads/thread-spec.js +++ b/lib/shared/threads/thread-spec.js @@ -23,6 +23,7 @@ LeaveThreadInput, LeaveThreadResult, } from '../../hooks/thread-hooks.js'; +import type { RolePermissionBlobs } from '../../permissions/keyserver-permissions.js'; import type { ProcessOutboundP2PMessagesResult } from '../../tunnelbroker/peer-to-peer-context.js'; import type { TunnelbrokerSocketState } from '../../tunnelbroker/tunnelbroker-context.js'; import type { @@ -336,6 +337,7 @@ +threadID: string, +threadType: ThreadType, }>, + +getRolePermissionBlobs: (threadType: ThreadType) => RolePermissionBlobs, +allowsDeletingSidebarSource: boolean, +presentationDetails: { +membershipChangesShownInThreadPreview: boolean,