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 @@ -431,6 +431,8 @@ }, membershipChangesShownInThreadPreview: true, + + allowsDeletingSidebarSource: false, }); export { dmThreadProtocol }; 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 @@ -214,6 +214,8 @@ }, membershipChangesShownInThreadPreview: false, + + allowsDeletingSidebarSource: true, }); function mediaIDIsKeyserverID(mediaID: string): boolean { 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 @@ -185,6 +185,7 @@ utils: SetThreadUnreadStatusUtils, ) => Promise, +membershipChangesShownInThreadPreview: boolean, + +allowsDeletingSidebarSource: boolean, }; export type ThreadSpec = { diff --git a/lib/utils/delete-message-utils.js b/lib/utils/delete-message-utils.js --- a/lib/utils/delete-message-utils.js +++ b/lib/utils/delete-message-utils.js @@ -14,15 +14,13 @@ } from '../shared/dm-ops/dm-op-types.js'; import { useProcessAndSendDMOperation } from '../shared/dm-ops/process-dm-ops.js'; import { useThreadHasPermission } from '../shared/thread-utils.js'; +import { threadSpecs } from '../shared/threads/thread-specs.js'; import type { DMSendDeleteMessageOperation } from '../types/dm-ops.js'; import type { MessageInfo } from '../types/message-types.js'; import { isComposableMessageType } from '../types/message-types.js'; import type { ThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; import { threadPermissions } from '../types/thread-permission-types.js'; -import { - thickThreadTypes, - threadTypeIsThick, -} from '../types/thread-types-enum.js'; +import { thickThreadTypes } from '../types/thread-types-enum.js'; const deletedMessageText = 'Deleted message'; @@ -108,12 +106,8 @@ return false; } - if (canDeleteAllMessages) { - return true; - } - if ( - threadTypeIsThick(threadInfo.type) && + !threadSpecs[threadInfo.type].protocol.allowsDeletingSidebarSource && (targetMessageInfo.time < threadInfo.creationTime || threadCreatedFromMessage) ) { @@ -123,6 +117,10 @@ return false; } + if (canDeleteAllMessages) { + return true; + } + return ( currentUserInfo.id === targetMessageInfo.creator.id && canDeleteOwnMessages );