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 @@ -11,6 +11,7 @@ DMAddMembersOperation, DMAddViewerToThreadMembersOperation, DMOperation, + ComposableDMOperation, } from '../../types/dm-ops.js'; import type { ThickRawThreadInfo, @@ -68,18 +69,30 @@ INBOUND: 'InboundDMOperationSpecification', }); +type OutboundDMOperationSpecificationRecipients = + | { +type: 'all_peer_devices' | 'self_devices' } + | { +type: 'some_users', +userIDs: $ReadOnlyArray } + | { +type: 'all_thread_members', +threadID: string }; + // The operation generated on the sending client, causes changes to // the state and broadcasting information to peers. export type OutboundDMOperationSpecification = { +type: 'OutboundDMOperationSpecification', +op: DMOperation, - +recipients: - | { +type: 'all_peer_devices' | 'self_devices' } - | { +type: 'some_users', +userIDs: $ReadOnlyArray } - | { +type: 'all_thread_members', +threadID: string }, + +recipients: OutboundDMOperationSpecificationRecipients, +sendOnly?: boolean, }; +export type OutboundComposableDMOperationSpecification = { + +type: 'OutboundDMOperationSpecification', + +op: ComposableDMOperation, + +recipients: OutboundDMOperationSpecificationRecipients, + // Composable DM Ops are created only to be sent, locally we use + // dedicated mechanism for updating the store. + +sendOnly: true, + +composableMessageID: string, +}; + // The operation received from other peers, causes changes to // the state and after processing, sends confirmation to the sender. export type InboundDMOperationSpecification = { diff --git a/lib/types/dm-ops.js b/lib/types/dm-ops.js --- a/lib/types/dm-ops.js +++ b/lib/types/dm-ops.js @@ -366,6 +366,10 @@ unread: t.Boolean, }); +export type ComposableDMOperation = + | DMSendTextMessageOperation + | DMSendMultimediaMessageOperation; + export type DMOperation = | DMCreateThreadOperation | DMCreateSidebarOperation