diff --git a/lib/actions/activity-actions.js b/lib/actions/activity-actions.js --- a/lib/actions/activity-actions.js +++ b/lib/actions/activity-actions.js @@ -9,8 +9,10 @@ } from '../keyserver-conn/keyserver-call-utils.js'; import { useKeyserverCall } from '../keyserver-conn/keyserver-call.js'; import type { CallKeyserverEndpoint } from '../keyserver-conn/keyserver-conn-types.js'; -import type { OutboundDMOperationSpecification } from '../shared/dm-ops/dm-op-utils.js'; -import { dmOperationSpecificationTypes } from '../shared/dm-ops/dm-op-utils.js'; +import { + type OutboundDMOperationSpecification, + dmOperationSpecificationTypes, +} from '../shared/dm-ops/dm-op-types.js'; import { useProcessAndSendDMOperation } from '../shared/dm-ops/process-dm-ops.js'; import type { ActivityUpdate, diff --git a/lib/actions/entry-actions.js b/lib/actions/entry-actions.js --- a/lib/actions/entry-actions.js +++ b/lib/actions/entry-actions.js @@ -13,7 +13,7 @@ import { dmOperationSpecificationTypes, type OutboundDMOperationSpecification, -} from '../shared/dm-ops/dm-op-utils.js'; +} from '../shared/dm-ops/dm-op-types.js'; import { useProcessAndSendDMOperation } from '../shared/dm-ops/process-dm-ops.js'; import { getNextLocalID } from '../shared/message-utils.js'; import { diff --git a/lib/actions/thread-actions.js b/lib/actions/thread-actions.js --- a/lib/actions/thread-actions.js +++ b/lib/actions/thread-actions.js @@ -11,8 +11,8 @@ import { type OutboundDMOperationSpecification, dmOperationSpecificationTypes, - getCreateThickRawThreadInfoInputFromThreadInfo, -} from '../shared/dm-ops/dm-op-utils.js'; +} from '../shared/dm-ops/dm-op-types.js'; +import { getCreateThickRawThreadInfoInputFromThreadInfo } from '../shared/dm-ops/dm-op-utils.js'; import { useProcessAndSendDMOperation } from '../shared/dm-ops/process-dm-ops.js'; import { permissionsAndAuthRelatedRequestTimeout } from '../shared/timeouts.js'; import type { diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js --- a/lib/actions/user-actions.js +++ b/lib/actions/user-actions.js @@ -31,8 +31,10 @@ getPrekeyValueFromBlob, } from '../shared/crypto-utils.js'; import { fetchLatestDeviceList } from '../shared/device-list-utils.js'; -import type { OutboundDMOperationSpecification } from '../shared/dm-ops/dm-op-utils'; -import { dmOperationSpecificationTypes } from '../shared/dm-ops/dm-op-utils.js'; +import { + type OutboundDMOperationSpecification, + dmOperationSpecificationTypes, +} from '../shared/dm-ops/dm-op-types.js'; import { useProcessAndSendDMOperation } from '../shared/dm-ops/process-dm-ops.js'; import { IdentityClientContext } from '../shared/identity-client-context.js'; import threadWatcher from '../shared/thread-watcher.js'; diff --git a/lib/handlers/dm-activity-handler.js b/lib/handlers/dm-activity-handler.js --- a/lib/handlers/dm-activity-handler.js +++ b/lib/handlers/dm-activity-handler.js @@ -6,7 +6,7 @@ import { type OutboundDMOperationSpecification, dmOperationSpecificationTypes, -} from '../shared/dm-ops/dm-op-utils.js'; +} from '../shared/dm-ops/dm-op-types.js'; import { useProcessAndSendDMOperation } from '../shared/dm-ops/process-dm-ops.js'; import { getMostRecentNonLocalMessageID } from '../shared/message-utils.js'; import { threadIsPending } from '../shared/thread-utils.js'; diff --git a/lib/handlers/initial-state-sharing-handler.react.js b/lib/handlers/initial-state-sharing-handler.react.js --- a/lib/handlers/initial-state-sharing-handler.react.js +++ b/lib/handlers/initial-state-sharing-handler.react.js @@ -5,10 +5,8 @@ import { useIsLoggedInToIdentityAndAuthoritativeKeyserver } from '../hooks/account-hooks.js'; import { getOwnPeerDevices } from '../selectors/user-selectors.js'; -import { - dmOperationSpecificationTypes, - getCreateThickRawThreadInfoInputFromThreadInfo, -} from '../shared/dm-ops/dm-op-utils.js'; +import { dmOperationSpecificationTypes } from '../shared/dm-ops/dm-op-types.js'; +import { getCreateThickRawThreadInfoInputFromThreadInfo } from '../shared/dm-ops/dm-op-utils.js'; import { useProcessAndSendDMOperation } from '../shared/dm-ops/process-dm-ops.js'; import { IdentityClientContext } from '../shared/identity-client-context.js'; import { values } from '../utils/objects.js'; diff --git a/lib/hooks/input-state-container-hooks.js b/lib/hooks/input-state-container-hooks.js --- a/lib/hooks/input-state-container-hooks.js +++ b/lib/hooks/input-state-container-hooks.js @@ -22,7 +22,7 @@ encryptedMediaBlobURI, encryptedVideoThumbnailBlobURI, } from '../media/media-utils.js'; -import { dmOperationSpecificationTypes } from '../shared/dm-ops/dm-op-utils.js'; +import { dmOperationSpecificationTypes } from '../shared/dm-ops/dm-op-types.js'; import { useSendComposableDMOperation } from '../shared/dm-ops/process-dm-ops.js'; import type { BlobOperation } from '../types/holder-types.js'; import type { diff --git a/lib/hooks/relationship-hooks.js b/lib/hooks/relationship-hooks.js --- a/lib/hooks/relationship-hooks.js +++ b/lib/hooks/relationship-hooks.js @@ -12,7 +12,7 @@ pendingToRealizedThreadIDsSelector, thickRawThreadInfosSelector, } from '../selectors/thread-selectors.js'; -import { dmOperationSpecificationTypes } from '../shared/dm-ops/dm-op-utils.js'; +import { dmOperationSpecificationTypes } from '../shared/dm-ops/dm-op-types.js'; import { useProcessAndSendDMOperation } from '../shared/dm-ops/process-dm-ops.js'; import { getPendingThreadID } from '../shared/thread-utils.js'; import type { RelationshipOperation } from '../types/messages/update-relationship.js'; diff --git a/lib/hooks/thread-hooks.js b/lib/hooks/thread-hooks.js --- a/lib/hooks/thread-hooks.js +++ b/lib/hooks/thread-hooks.js @@ -10,7 +10,7 @@ import { type OutboundDMOperationSpecification, dmOperationSpecificationTypes, -} from '../shared/dm-ops/dm-op-utils.js'; +} from '../shared/dm-ops/dm-op-types.js'; import { useProcessAndSendDMOperation } from '../shared/dm-ops/process-dm-ops.js'; import type { DMCreateSidebarOperation, diff --git a/lib/shared/dm-ops/dm-op-types.js b/lib/shared/dm-ops/dm-op-types.js new file mode 100644 --- /dev/null +++ b/lib/shared/dm-ops/dm-op-types.js @@ -0,0 +1,46 @@ +// @flow + +import type { ComposableDMOperation, DMOperation } from '../../types/dm-ops.js'; +import type { InboundActionMetadata } from '../../types/redux-types.js'; + +export const dmOperationSpecificationTypes = Object.freeze({ + OUTBOUND: 'OutboundDMOperationSpecification', + INBOUND: 'InboundDMOperationSpecification', +}); + +export type OutboundDMOperationSpecificationRecipients = + | { +type: 'all_peer_devices' | 'self_devices' } + | { +type: 'some_users', +userIDs: $ReadOnlyArray } + | { +type: 'all_thread_members', +threadID: string } + | { +type: 'some_devices', +deviceIDs: $ReadOnlyArray }; + +// 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: 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 = { + +type: 'InboundDMOperationSpecification', + +op: DMOperation, + +metadata: ?InboundActionMetadata, +}; + +export type DMOperationSpecification = + | OutboundDMOperationSpecification + | InboundDMOperationSpecification; 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 @@ -7,6 +7,11 @@ import { type ProcessDMOperationUtilities } from './dm-op-spec.js'; import { dmOpSpecs } from './dm-op-specs.js'; +import { + type OutboundDMOperationSpecification, + type OutboundDMOperationSpecificationRecipients, + dmOperationSpecificationTypes, +} from './dm-op-types.js'; import { useProcessAndSendDMOperation } from './process-dm-ops.js'; import { setMissingDeviceListsActionType, @@ -25,14 +30,12 @@ DMAddMembersOperation, DMAddViewerToThreadMembersOperation, DMOperation, - ComposableDMOperation, } from '../../types/dm-ops.js'; import type { RawMessageInfo } from '../../types/message-types.js'; import type { ThickRawThreadInfo, ThreadInfo, } from '../../types/minimally-encoded-thread-permissions-types.js'; -import type { InboundActionMetadata } from '../../types/redux-types.js'; import { outboundP2PMessageStatuses, type OutboundP2PMessage, @@ -93,48 +96,6 @@ return outboundP2PMessages; } -export const dmOperationSpecificationTypes = Object.freeze({ - OUTBOUND: 'OutboundDMOperationSpecification', - INBOUND: 'InboundDMOperationSpecification', -}); - -type OutboundDMOperationSpecificationRecipients = - | { +type: 'all_peer_devices' | 'self_devices' } - | { +type: 'some_users', +userIDs: $ReadOnlyArray } - | { +type: 'all_thread_members', +threadID: string } - | { +type: 'some_devices', +deviceIDs: $ReadOnlyArray }; - -// 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: 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 = { - +type: 'InboundDMOperationSpecification', - +op: DMOperation, - +metadata: ?InboundActionMetadata, -}; - -export type DMOperationSpecification = - | OutboundDMOperationSpecification - | InboundDMOperationSpecification; - function useCreateMessagesToPeersFromDMOp(): ( operation: DMOperation, recipients: OutboundDMOperationSpecificationRecipients, diff --git a/lib/shared/dm-ops/dm-ops-queue-handler.react.js b/lib/shared/dm-ops/dm-ops-queue-handler.react.js --- a/lib/shared/dm-ops/dm-ops-queue-handler.react.js +++ b/lib/shared/dm-ops/dm-ops-queue-handler.react.js @@ -2,7 +2,7 @@ import * as React from 'react'; -import { dmOperationSpecificationTypes } from './dm-op-utils.js'; +import { dmOperationSpecificationTypes } from './dm-op-types.js'; import { useProcessDMOperation } from './process-dm-ops.js'; import { useActionsQueue } from '../../hooks/actions-queue.js'; import { messageInfoSelector } from '../../selectors/chat-selectors.js'; 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 @@ -9,9 +9,11 @@ import { type OutboundDMOperationSpecification, type DMOperationSpecification, - useCreateMessagesToPeersFromDMOp, dmOperationSpecificationTypes, type OutboundComposableDMOperationSpecification, +} from './dm-op-types.js'; +import { + useCreateMessagesToPeersFromDMOp, useSendDMOperationUtils, } from './dm-op-utils.js'; import { useProcessBlobHolders } from '../../actions/holder-actions.js'; diff --git a/lib/shared/edit-messages-utils.js b/lib/shared/edit-messages-utils.js --- a/lib/shared/edit-messages-utils.js +++ b/lib/shared/edit-messages-utils.js @@ -7,7 +7,7 @@ import { type OutboundDMOperationSpecification, dmOperationSpecificationTypes, -} from './dm-ops/dm-op-utils.js'; +} from './dm-ops/dm-op-types.js'; import { useProcessAndSendDMOperation } from './dm-ops/process-dm-ops.js'; import { threadIsPending, useThreadHasPermission } from './thread-utils.js'; import { diff --git a/lib/tunnelbroker/use-peer-to-peer-message-handler.js b/lib/tunnelbroker/use-peer-to-peer-message-handler.js --- a/lib/tunnelbroker/use-peer-to-peer-message-handler.js +++ b/lib/tunnelbroker/use-peer-to-peer-message-handler.js @@ -21,7 +21,7 @@ verifyAndGetDeviceList, useDeviceListUpdate, } from '../shared/device-list-utils.js'; -import { dmOperationSpecificationTypes } from '../shared/dm-ops/dm-op-utils.js'; +import { dmOperationSpecificationTypes } from '../shared/dm-ops/dm-op-types.js'; import { useProcessDMOperation } from '../shared/dm-ops/process-dm-ops.js'; import { IdentityClientContext } from '../shared/identity-client-context.js'; import type { DeviceOlmInboundKeys } from '../types/identity-service-types.js'; 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 @@ -13,7 +13,7 @@ import { dmOperationSpecificationTypes, type OutboundDMOperationSpecification, -} from '../shared/dm-ops/dm-op-utils.js'; +} 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 type { DMSendDeleteMessageOperation } from '../types/dm-ops.js'; diff --git a/native/chat/reaction-message-utils.js b/native/chat/reaction-message-utils.js --- a/native/chat/reaction-message-utils.js +++ b/native/chat/reaction-message-utils.js @@ -12,7 +12,7 @@ import { dmOperationSpecificationTypes, type OutboundDMOperationSpecification, -} from 'lib/shared/dm-ops/dm-op-utils.js'; +} from 'lib/shared/dm-ops/dm-op-types.js'; import { useProcessAndSendDMOperation } from 'lib/shared/dm-ops/process-dm-ops.js'; import { getNextLocalID } from 'lib/shared/message-utils.js'; import type { DMSendReactionMessageOperation } from 'lib/types/dm-ops.js'; diff --git a/native/chat/settings/thread-settings-leave-thread.react.js b/native/chat/settings/thread-settings-leave-thread.react.js --- a/native/chat/settings/thread-settings-leave-thread.react.js +++ b/native/chat/settings/thread-settings-leave-thread.react.js @@ -15,7 +15,7 @@ import { type OutboundDMOperationSpecification, dmOperationSpecificationTypes, -} from 'lib/shared/dm-ops/dm-op-utils.js'; +} from 'lib/shared/dm-ops/dm-op-types.js'; import { useProcessAndSendDMOperation } from 'lib/shared/dm-ops/process-dm-ops.js'; import { identifyInvalidatedThreads } from 'lib/shared/thread-utils.js'; import type { DMLeaveThreadOperation } from 'lib/types/dm-ops'; diff --git a/native/profile/profile-screen.react.js b/native/profile/profile-screen.react.js --- a/native/profile/profile-screen.react.js +++ b/native/profile/profile-screen.react.js @@ -18,7 +18,7 @@ import { type OutboundDMOperationSpecification, dmOperationSpecificationTypes, -} from 'lib/shared/dm-ops/dm-op-utils.js'; +} from 'lib/shared/dm-ops/dm-op-types.js'; import { useProcessAndSendDMOperation } from 'lib/shared/dm-ops/process-dm-ops.js'; import type { LogOutResult } from 'lib/types/account-types.js'; import type { DMCreateThreadOperation } from 'lib/types/dm-ops'; diff --git a/web/chat/reaction-message-utils.js b/web/chat/reaction-message-utils.js --- a/web/chat/reaction-message-utils.js +++ b/web/chat/reaction-message-utils.js @@ -13,7 +13,7 @@ import { dmOperationSpecificationTypes, type OutboundDMOperationSpecification, -} from 'lib/shared/dm-ops/dm-op-utils.js'; +} from 'lib/shared/dm-ops/dm-op-types.js'; import { useProcessAndSendDMOperation } from 'lib/shared/dm-ops/process-dm-ops.js'; import { getNextLocalID } from 'lib/shared/message-utils.js'; import { type DMSendReactionMessageOperation } from 'lib/types/dm-ops.js'; diff --git a/web/chat/thread-menu.react.js b/web/chat/thread-menu.react.js --- a/web/chat/thread-menu.react.js +++ b/web/chat/thread-menu.react.js @@ -15,7 +15,7 @@ import { type OutboundDMOperationSpecification, dmOperationSpecificationTypes, -} from 'lib/shared/dm-ops/dm-op-utils.js'; +} from 'lib/shared/dm-ops/dm-op-types.js'; import { useProcessAndSendDMOperation } from 'lib/shared/dm-ops/process-dm-ops.js'; import { threadIsChannel, diff --git a/web/settings/account-settings.react.js b/web/settings/account-settings.react.js --- a/web/settings/account-settings.react.js +++ b/web/settings/account-settings.react.js @@ -16,7 +16,7 @@ import { dmOperationSpecificationTypes, type OutboundDMOperationSpecification, -} from 'lib/shared/dm-ops/dm-op-utils.js'; +} from 'lib/shared/dm-ops/dm-op-types.js'; import { useProcessAndSendDMOperation } from 'lib/shared/dm-ops/process-dm-ops.js'; import { IdentityClientContext } from 'lib/shared/identity-client-context.js'; import { useTunnelbroker } from 'lib/tunnelbroker/tunnelbroker-context.js';