Page MenuHomePhorge

D14703.1765222425.diff
No OneTemporary

Size
7 KB
Referenced Files
None
Subscribers
None

D14703.1765222425.diff

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
@@ -14,6 +14,7 @@
DMDeleteEntryOperation,
DMEditEntryOperation,
DMLeaveThreadOperation,
+ DMSendDeleteMessageOperation,
DMSendEditMessageOperation,
DMSendReactionMessageOperation,
DMThreadSettingsChanges,
@@ -90,6 +91,8 @@
ProtocolFetchMessageInput,
ProtocolCreatePendingThreadInput,
CreateRealThreadParameters,
+ DeleteMessageUtils,
+ ProtocolDeleteMessageInput,
} from '../thread-spec.js';
const dmThreadProtocol: ThreadProtocol<MinimallyEncodedThickMemberInfo> =
@@ -802,6 +805,35 @@
};
},
+ deleteMessage: async (
+ input: ProtocolDeleteMessageInput,
+ utils: DeleteMessageUtils,
+ ) => {
+ const { messageID, threadInfo, viewerID } = input;
+ invariant(viewerID, 'viewerID should be set');
+ const op: DMSendDeleteMessageOperation = {
+ type: 'send_delete_message',
+ threadID: threadInfo.id,
+ creatorID: viewerID,
+ time: Date.now(),
+ messageID: uuid.v4(),
+ targetMessageID: messageID,
+ };
+ const opSpecification: OutboundDMOperationSpecification = {
+ type: dmOperationSpecificationTypes.OUTBOUND,
+ op,
+ recipients: {
+ type: 'all_thread_members',
+ threadID:
+ threadInfo.type === thickThreadTypes.THICK_SIDEBAR &&
+ threadInfo.parentThreadID
+ ? threadInfo.parentThreadID
+ : threadInfo.id,
+ },
+ };
+ await utils.processAndSendDMOperation(opSpecification);
+ },
+
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
@@ -7,6 +7,7 @@
import {
fetchMessagesBeforeCursorActionTypes,
fetchMostRecentMessagesActionTypes,
+ sendDeleteMessageActionTypes,
sendEditMessageActionTypes,
sendReactionMessageActionTypes,
} from '../../../actions/message-actions.js';
@@ -107,6 +108,8 @@
ProtocolFetchMessageInput,
ProtocolCreatePendingThreadInput,
CreateRealThreadParameters,
+ DeleteMessageUtils,
+ ProtocolDeleteMessageInput,
} from '../thread-spec.js';
import { threadTypeIsSidebar } from '../thread-specs.js';
@@ -597,6 +600,17 @@
return getThinThreadPermissionsBlobs(thinThreadType);
},
+ deleteMessage: async (
+ input: ProtocolDeleteMessageInput,
+ utils: DeleteMessageUtils,
+ ) => {
+ const promise = utils.keyserverDeleteMessage({
+ targetMessageID: input.messageID,
+ });
+ void utils.dispatchActionPromise(sendDeleteMessageActionTypes, promise);
+ await promise;
+ },
+
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
@@ -49,6 +49,8 @@
SendEditMessageResult,
SendReactionMessageRequest,
FetchMessageInfosPayload,
+ DeleteMessageRequest,
+ DeleteMessageResponse,
} from '../../types/message-types.js';
import type { RawTextMessageInfo } from '../../types/messages/text.js';
import type {
@@ -255,6 +257,17 @@
+calendarQuery: CalendarQuery,
};
+export type ProtocolDeleteMessageInput = {
+ +messageID: string,
+ +threadInfo: RawThreadInfo,
+ +viewerID: ?string,
+};
+export type DeleteMessageUtils = {
+ +processAndSendDMOperation: OutboundDMOperationSpecification => Promise<void>,
+ +keyserverDeleteMessage: DeleteMessageRequest => Promise<DeleteMessageResponse>,
+ +dispatchActionPromise: DispatchActionPromise,
+};
+
export type ThreadProtocol<
RawThreadMemberType:
| MemberInfoSansPermissions
@@ -338,6 +351,10 @@
+threadType: ThreadType,
}>,
+getRolePermissionBlobs: (threadType: ThreadType) => RolePermissionBlobs,
+ +deleteMessage: (
+ input: ProtocolDeleteMessageInput,
+ utils: DeleteMessageUtils,
+ ) => Promise<void>,
+allowsDeletingSidebarSource: boolean,
+presentationDetails: {
+membershipChangesShownInThreadPreview: boolean,
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
@@ -2,25 +2,17 @@
import invariant from 'invariant';
import * as React from 'react';
-import uuid from 'uuid';
import { useDispatchActionPromise } from './redux-promise-utils.js';
import { useSelector } from './redux-utils.js';
-import { sendDeleteMessageActionTypes } from '../actions/message-actions.js';
import { useSendDeleteMessage } from '../hooks/message-hooks.js';
-import {
- dmOperationSpecificationTypes,
- type OutboundDMOperationSpecification,
-} 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 } from '../types/thread-types-enum.js';
const deletedMessageText = 'Deleted message';
@@ -38,36 +30,14 @@
const messageID = message.id;
invariant(messageID, 'Message ID should be set');
const threadInfo = threadInfos[message.threadID];
- if (threadInfo.thick) {
- invariant(viewerID, 'viewerID should be set');
- const op: DMSendDeleteMessageOperation = {
- type: 'send_delete_message',
- threadID: threadInfo.id,
- creatorID: viewerID,
- time: Date.now(),
- messageID: uuid.v4(),
- targetMessageID: messageID,
- };
- const opSpecification: OutboundDMOperationSpecification = {
- type: dmOperationSpecificationTypes.OUTBOUND,
- op,
- recipients: {
- type: 'all_thread_members',
- threadID:
- threadInfo.type === thickThreadTypes.THICK_SIDEBAR &&
- threadInfo.parentThreadID
- ? threadInfo.parentThreadID
- : threadInfo.id,
- },
- };
- await processAndSendDMOperation(opSpecification);
- } else {
- const promise = callDeleteMessage({
- targetMessageID: messageID,
- });
- void dispatchActionPromise(sendDeleteMessageActionTypes, promise);
- await promise;
- }
+ await threadSpecs[threadInfo.type].protocol.deleteMessage(
+ { messageID, viewerID, threadInfo },
+ {
+ keyserverDeleteMessage: callDeleteMessage,
+ dispatchActionPromise,
+ processAndSendDMOperation,
+ },
+ );
},
[
callDeleteMessage,

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 8, 7:33 PM (3 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5850194
Default Alt Text
D14703.1765222425.diff (7 KB)

Event Timeline