Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3386375
D13145.id43645.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D13145.id43645.diff
View Options
diff --git a/lib/shared/dm-ops/dm-op-utils.js b/lib/shared/dm-ops/dm-op-utils.js
--- a/lib/shared/dm-ops/dm-op-utils.js
+++ b/lib/shared/dm-ops/dm-op-utils.js
@@ -2,6 +2,7 @@
import uuid from 'uuid';
+import type { MessageSourceMetadata } from '../../types/db-ops-types.js';
import type { DMOperation } from '../../types/dm-ops.js';
import {
outboundP2PMessageStatuses,
@@ -44,7 +45,15 @@
return outboundP2PMessages;
}
-export type DMOperationSpecification = {
+export const dmOperationSpecificationTypes = Object.freeze({
+ OUTBOUND: 'OutboundDMOperationSpecification',
+ INBOUND: 'InboundDMOperationSpecification',
+});
+
+// The operation generated on the sending client, causes changes to
+// the state and broadcasting information to peers.
+export type OutboundDMOperationSpecification = {
+ +type: 'OutboundDMOperationSpecification',
+op: DMOperation,
+supportsAutoRetry: boolean,
+recipients:
@@ -52,8 +61,20 @@
| { +type: 'some_users', +userIDs: $ReadOnlyArray<string> },
};
+// The operation received from other peers, causes changes to
+// the state and after processing, sends confirmation to the sender.
+export type InboundDMOperationSpecification = {
+ +type: 'InboundDMOperationSpecification',
+ +op: DMOperation,
+ +metadata: ?MessageSourceMetadata,
+};
+
+export type DMOperationSpecification =
+ | OutboundDMOperationSpecification
+ | InboundDMOperationSpecification;
+
async function createMessagesToPeersFromDMOp(
- operation: DMOperationSpecification,
+ operation: OutboundDMOperationSpecification,
allPeerUserIDAndDeviceIDs: $ReadOnlyArray<{
+userID: string,
+deviceID: string,
diff --git a/lib/shared/dm-ops/process-dm-ops.js b/lib/shared/dm-ops/process-dm-ops.js
--- a/lib/shared/dm-ops/process-dm-ops.js
+++ b/lib/shared/dm-ops/process-dm-ops.js
@@ -5,7 +5,7 @@
import uuid from 'uuid';
import { dmOpSpecs } from './dm-op-specs.js';
-import type { DMOperationSpecification } from './dm-op-utils.js';
+import type { OutboundDMOperationSpecification } from './dm-op-utils.js';
import { useLoggedInUserInfo } from '../../hooks/account-hooks.js';
import { useGetLatestMessageEdit } from '../../hooks/latest-message-edit.js';
import { useDispatchWithMessageSource } from '../../hooks/ops-hooks.js';
@@ -156,13 +156,13 @@
}
function useProcessAndSendDMOperation(): (
- dmOperationSpecification: DMOperationSpecification,
+ dmOperationSpecification: OutboundDMOperationSpecification,
) => Promise<void> {
const processDMOps = useProcessDMOperation();
const { sendDMOperation } = usePeerToPeerCommunication();
return React.useCallback(
- async (dmOperationSpecification: DMOperationSpecification) => {
+ async (dmOperationSpecification: OutboundDMOperationSpecification) => {
await processDMOps(dmOperationSpecification.op);
await sendDMOperation(dmOperationSpecification);
},
diff --git a/lib/tunnelbroker/peer-to-peer-context.js b/lib/tunnelbroker/peer-to-peer-context.js
--- a/lib/tunnelbroker/peer-to-peer-context.js
+++ b/lib/tunnelbroker/peer-to-peer-context.js
@@ -12,7 +12,7 @@
import { getAllPeerUserIDAndDeviceIDs } from '../selectors/user-selectors.js';
import {
createMessagesToPeersFromDMOp,
- type DMOperationSpecification,
+ type OutboundDMOperationSpecification,
} from '../shared/dm-ops/dm-op-utils.js';
import {
type AuthMetadata,
@@ -38,7 +38,7 @@
outboundMessageIDs: ?$ReadOnlyArray<string>,
dmOpID: ?string,
) => void,
- +sendDMOperation: (op: DMOperationSpecification) => Promise<void>,
+ +sendDMOperation: (op: OutboundDMOperationSpecification) => Promise<void>,
+broadcastEphemeralMessage: (
contentPayload: string,
recipients: $ReadOnlyArray<{ +userID: string, +deviceID: string }>,
@@ -179,7 +179,7 @@
const currentUserInfo = useSelector(state => state.currentUserInfo);
const sendDMOperation = React.useCallback(
- async (op: DMOperationSpecification) => {
+ async (op: OutboundDMOperationSpecification) => {
const dmOpID = uuid.v4();
const promise = new Promise<void>((resolve, reject) => {
dmOpsSendingPromiseResolvers.current.set(dmOpID, { resolve, reject });
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 4:22 AM (20 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2599265
Default Alt Text
D13145.id43645.diff (4 KB)
Attached To
Mode
D13145: [lib] distinguish between Inbound and Outbound `DMOperationSpecification`
Attached
Detach File
Event Timeline
Log In to Comment