diff --git a/ts/components/conversation/TimerNotification.tsx b/ts/components/conversation/TimerNotification.tsx index 4eef19309..d35760681 100644 --- a/ts/components/conversation/TimerNotification.tsx +++ b/ts/components/conversation/TimerNotification.tsx @@ -3,11 +3,11 @@ import React from 'react'; import { PropsForExpirationTimer } from '../../state/ducks/conversations'; import { assertUnreachable } from '../../types/sqlSharedTypes'; -import { ExpirableReadableMessage } from './message/message-item/ExpirableReadableMessage'; -import { SessionIcon } from '../icon'; -import { SpacerSM, Text } from '../basic/Text'; +import { isLegacyDisappearingModeEnabled } from '../../session/disappearing_messages/legacy'; import { Flex } from '../basic/Flex'; -import { isLegacyDisappearingModeEnabled } from '../../util/expiringMessages'; +import { SpacerSM, Text } from '../basic/Text'; +import { SessionIcon } from '../icon'; +import { ExpirableReadableMessage } from './message/message-item/ExpirableReadableMessage'; export const TimerNotification = (props: PropsForExpirationTimer) => { const { messageId, pubkey, profileName, expirationMode, timespan, type, disabled } = props; diff --git a/ts/data/data.ts b/ts/data/data.ts index 3488f7993..c74678c70 100644 --- a/ts/data/data.ts +++ b/ts/data/data.ts @@ -10,6 +10,7 @@ import { StorageItem } from '../node/storage_item'; import { HexKeyPair } from '../receiver/keypairs'; import { Quote } from '../receiver/types'; import { getSodiumRenderer } from '../session/crypto'; +import { updateExpiringMessagesCheck } from '../session/disappearing_messages'; import { PubKey } from '../session/types'; import { fromArrayBufferToBase64, fromBase64ToArrayBuffer } from '../session/utils/String'; import { @@ -19,7 +20,6 @@ import { UnprocessedDataNode, UpdateLastHashType, } from '../types/sqlSharedTypes'; -import { ExpirationTimerOptions } from '../util/expiringMessages'; import { Storage } from '../util/storage'; import { channels } from './channels'; import * as dataInit from './dataInit'; @@ -244,7 +244,7 @@ async function updateLastHash(data: UpdateLastHashType): Promise { async function saveMessage(data: MessageAttributes): Promise { const cleanedData = cleanData(data); const id = await channels.saveMessage(cleanedData); - ExpirationTimerOptions.updateExpiringMessagesCheck(); + updateExpiringMessagesCheck(); return id; } diff --git a/ts/mains/main_renderer.tsx b/ts/mains/main_renderer.tsx index ba2a7b516..4a7c5096c 100644 --- a/ts/mains/main_renderer.tsx +++ b/ts/mains/main_renderer.tsx @@ -1,32 +1,32 @@ +import Backbone from 'backbone'; import _ from 'lodash'; import ReactDOM from 'react-dom'; -import Backbone from 'backbone'; -import React from 'react'; import nativeEmojiData from '@emoji-mart/data'; +import React from 'react'; -import { MessageModel } from '../models/message'; import { isMacOS } from '../OS'; +import { SessionInboxView } from '../components/SessionInboxView'; +import { SessionRegistrationView } from '../components/registration/SessionRegistrationView'; +import { Data } from '../data/data'; +import { OpenGroupData } from '../data/opengroups'; +import { SettingsKey } from '../data/settings-key'; +import { MessageModel } from '../models/message'; +import { deleteAllLogs } from '../node/logs'; import { queueAllCached } from '../receiver/receiver'; +import { loadKnownBlindedKeys } from '../session/apis/open_group_api/sogsv3/knownBlindedkeys'; import { getConversationController } from '../session/conversations'; +import { initExpiringMessageListener } from '../session/disappearing_messages'; import { AttachmentDownloads, ToastUtils } from '../session/utils'; import { getOurPubKeyStrFromCache } from '../session/utils/User'; +import { runners } from '../session/utils/job_runners/JobRunner'; +import { LibSessionUtil } from '../session/utils/libsession/libsession_utils'; +import { switchPrimaryColorTo } from '../themes/switchPrimaryColor'; import { BlockedNumberController } from '../util'; -import { ExpirationTimerOptions } from '../util/expiringMessages'; +import { initialiseEmojiData } from '../util/emoji'; import { Notifications } from '../util/notifications'; import { Registration } from '../util/registration'; -import { isSignInByLinking, Storage } from '../util/storage'; -import { Data } from '../data/data'; -import { SessionRegistrationView } from '../components/registration/SessionRegistrationView'; -import { SessionInboxView } from '../components/SessionInboxView'; -import { deleteAllLogs } from '../node/logs'; -import { OpenGroupData } from '../data/opengroups'; -import { loadKnownBlindedKeys } from '../session/apis/open_group_api/sogsv3/knownBlindedkeys'; -import { initialiseEmojiData } from '../util/emoji'; -import { switchPrimaryColorTo } from '../themes/switchPrimaryColor'; -import { LibSessionUtil } from '../session/utils/libsession/libsession_utils'; -import { runners } from '../session/utils/job_runners/JobRunner'; -import { SettingsKey } from '../data/settings-key'; +import { Storage, isSignInByLinking } from '../util/storage'; // Globally disable drag and drop document.body.addEventListener( @@ -293,7 +293,7 @@ async function start() { ReactDOM.render(, document.getElementById('root')); switchBodyToRtlIfNeeded(); } - ExpirationTimerOptions.initExpiringMessageListener(); + initExpiringMessageListener(); if (Registration.isDone() && !isSignInByLinking()) { await connect(); diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 134b773c1..12d06fa81 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -117,11 +117,11 @@ import { getSubscriberCountOutsideRedux, } from '../state/selectors/sogsRoomInfo'; // decide it it makes sense to move this to a redux slice? -import { DisappearingMessageConversationModeType } from '../session/disappearing_messages/types'; import { changeToDisappearingMessageType, setExpirationStartTimestamp, -} from '../util/expiringMessages'; +} from '../session/disappearing_messages'; +import { DisappearingMessageConversationModeType } from '../session/disappearing_messages/types'; import { markAttributesAsReadIfNeeded } from './messageFactory'; type InMemoryConvoInfos = { diff --git a/ts/models/message.ts b/ts/models/message.ts index a36ee0a06..1ef0c7e7b 100644 --- a/ts/models/message.ts +++ b/ts/models/message.ts @@ -45,6 +45,12 @@ import { isUsAnySogsFromCache } from '../session/apis/open_group_api/sogsv3/know import { GetNetworkTime } from '../session/apis/snode_api/getNetworkTime'; import { SnodeNamespaces } from '../session/apis/snode_api/namespaces'; import { DURATION } from '../session/constants'; +import { + changeToDisappearingConversationMode, + checkForExpireUpdateInContentMessage, + setExpirationStartTimestamp, + updateMessageExpiryOnSwarm, +} from '../session/disappearing_messages'; import { TimerOptions } from '../session/disappearing_messages/timerOptions'; import { OpenGroupVisibleMessage } from '../session/messages/outgoing/visibleMessage/OpenGroupVisibleMessage'; import { @@ -89,12 +95,6 @@ import { import { ReactionList } from '../types/Reaction'; import { getAttachmentMetadata } from '../types/message/initializeAttachmentMetadata'; import { roomHasBlindEnabled } from '../types/sqlSharedTypes'; -import { - changeToDisappearingConversationMode, - checkForExpireUpdateInContentMessage, - setExpirationStartTimestamp, - updateMessageExpiryOnSwarm, -} from '../util/expiringMessages'; import { LinkPreviews } from '../util/linkPreviews'; import { Notifications } from '../util/notifications'; import { Storage } from '../util/storage'; diff --git a/ts/receiver/contentMessage.ts b/ts/receiver/contentMessage.ts index e4b0cd194..6ea73a05d 100644 --- a/ts/receiver/contentMessage.ts +++ b/ts/receiver/contentMessage.ts @@ -22,26 +22,26 @@ import { findCachedBlindedMatchOrLookupOnAllServers } from '../session/apis/open import { getConversationController } from '../session/conversations'; import { concatUInt8Array, getSodiumRenderer } from '../session/crypto'; import { removeMessagePadding } from '../session/crypto/BufferPadding'; +import { + changeToDisappearingMessageType, + checkForExpireUpdateInContentMessage, + checkHasOutdatedDisappearingMessageClient, + setExpirationStartTimestamp, +} from '../session/disappearing_messages'; import { ProfileManager } from '../session/profile_manager/ProfileManager'; import { GroupUtils, UserUtils } from '../session/utils'; import { perfEnd, perfStart } from '../session/utils/Performance'; import { fromHexToArray, toHex } from '../session/utils/String'; +import { isUsFromCache } from '../session/utils/User'; import { assertUnreachable } from '../types/sqlSharedTypes'; import { BlockedNumberController } from '../util'; import { ReadReceipts } from '../util/readReceipts'; import { Storage } from '../util/storage'; +import { ContactsWrapperActions } from '../webworker/workers/browser/libsession_worker_interface'; import { handleCallMessage } from './callMessage'; import { getAllCachedECKeyPair, sentAtMoreRecentThanWrapper } from './closedGroups'; import { ConfigMessageHandler } from './configMessage'; import { ECKeyPair } from './keypairs'; -import { ContactsWrapperActions } from '../webworker/workers/browser/libsession_worker_interface'; -import { isUsFromCache } from '../session/utils/User'; -import { - changeToDisappearingMessageType, - checkForExpireUpdateInContentMessage, - checkHasOutdatedDisappearingMessageClient, - setExpirationStartTimestamp, -} from '../util/expiringMessages'; export async function handleSwarmContentMessage(envelope: EnvelopePlus, messageHash: string) { try { diff --git a/ts/receiver/dataMessage.ts b/ts/receiver/dataMessage.ts index b3da4dada..d07c0ddc1 100644 --- a/ts/receiver/dataMessage.ts +++ b/ts/receiver/dataMessage.ts @@ -20,12 +20,12 @@ import { createSwarmMessageSentFromNotUs, createSwarmMessageSentFromUs, } from '../models/messageFactory'; +import { getMessageReadyToDisappear } from '../session/disappearing_messages'; import { DisappearingMessageUpdate } from '../session/disappearing_messages/types'; import { ProfileManager } from '../session/profile_manager/ProfileManager'; import { isUsFromCache } from '../session/utils/User'; import { Action, Reaction } from '../types/Reaction'; import { toLogFormat } from '../types/attachments/Errors'; -import { getMessageReadyToDisappear } from '../util/expiringMessages'; import { Reactions } from '../util/reactions'; function cleanAttachment(attachment: any) { diff --git a/ts/receiver/queuedJob.ts b/ts/receiver/queuedJob.ts index 29c82b534..8fccad01f 100644 --- a/ts/receiver/queuedJob.ts +++ b/ts/receiver/queuedJob.ts @@ -10,6 +10,10 @@ import { Quote } from './types'; import { ConversationTypeEnum } from '../models/conversationAttributes'; import { MessageDirection } from '../models/messageType'; import { SignalService } from '../protobuf'; +import { + changeToDisappearingConversationMode, + setExpirationStartTimestamp, +} from '../session/disappearing_messages'; import { ProfileManager } from '../session/profile_manager/ProfileManager'; import { PubKey } from '../session/types'; import { UserUtils } from '../session/utils'; @@ -17,10 +21,6 @@ import { PropsForMessageWithoutConvoProps, lookupQuote } from '../state/ducks/co import { showMessageRequestBannerOutsideRedux } from '../state/ducks/userConfig'; import { getHideMessageRequestBannerOutsideRedux } from '../state/selectors/userConfig'; import { GoogleChrome } from '../util'; -import { - changeToDisappearingConversationMode, - setExpirationStartTimestamp, -} from '../util/expiringMessages'; import { LinkPreviews } from '../util/linkPreviews'; import { ReleasedFeatures } from '../util/releaseFeature'; diff --git a/ts/session/apis/open_group_api/sogsv3/sogsApiV3.ts b/ts/session/apis/open_group_api/sogsv3/sogsApiV3.ts index 6a110d873..392cd849e 100644 --- a/ts/session/apis/open_group_api/sogsv3/sogsApiV3.ts +++ b/ts/session/apis/open_group_api/sogsv3/sogsApiV3.ts @@ -1,24 +1,22 @@ /* eslint-disable no-restricted-syntax */ /* eslint-disable no-await-in-loop */ -import { compact, isArray, isEmpty, isFinite, isNumber, isObject, pick } from 'lodash'; import { base64_variants, from_base64 } from 'libsodium-wrappers-sumo'; +import { compact, isArray, isEmpty, isFinite, isNumber, isObject, pick } from 'lodash'; import { v4 } from 'uuid'; import { OpenGroupData } from '../../../../data/opengroups'; +import { ConversationModel } from '../../../../models/conversation'; import { handleOpenGroupV4Message } from '../../../../receiver/opengroup'; +import { callUtilsWorker } from '../../../../webworker/workers/browser/util_worker_interface'; +import { getConversationController } from '../../../conversations'; +import { PubKey } from '../../../types'; import { OpenGroupRequestCommonType } from '../opengroupV2/ApiUtil'; -import { BatchSogsReponse, OpenGroupBatchRow, SubRequestMessagesType } from './sogsV3BatchPoll'; import { - getRoomAndUpdateLastFetchTimestamp, OpenGroupMessageV4, + getRoomAndUpdateLastFetchTimestamp, } from '../opengroupV2/OpenGroupServerPoller'; -import { getOpenGroupV2ConversationId } from '../utils/OpenGroupUtils'; -import { handleCapabilities } from './sogsCapabilities'; -import { getConversationController } from '../../../conversations'; -import { ConversationModel } from '../../../../models/conversation'; import { filterDuplicatesFromDbAndIncomingV4 } from '../opengroupV2/SogsFilterDuplicate'; -import { callUtilsWorker } from '../../../../webworker/workers/browser/util_worker_interface'; -import { PubKey } from '../../../types'; +import { getOpenGroupV2ConversationId } from '../utils/OpenGroupUtils'; import { addCachedBlindedKey, findCachedBlindedMatchOrLookItUp, @@ -27,21 +25,23 @@ import { tryMatchBlindWithStandardKey, } from './knownBlindedkeys'; import { SogsBlinding } from './sogsBlinding'; +import { handleCapabilities } from './sogsCapabilities'; +import { BatchSogsReponse, OpenGroupBatchRow, SubRequestMessagesType } from './sogsV3BatchPoll'; -import { UserUtils } from '../../../utils'; +import { Data } from '../../../../data/data'; +import { ConversationTypeEnum } from '../../../../models/conversationAttributes'; +import { createSwarmMessageSentFromUs } from '../../../../models/messageFactory'; +import { SignalService } from '../../../../protobuf'; import { innerHandleSwarmContentMessage } from '../../../../receiver/contentMessage'; +import { handleOutboxMessageModel } from '../../../../receiver/dataMessage'; import { EnvelopePlus } from '../../../../receiver/types'; -import { SignalService } from '../../../../protobuf'; -import { removeMessagePadding } from '../../../crypto/BufferPadding'; +import { assertUnreachable } from '../../../../types/sqlSharedTypes'; import { getSodiumRenderer } from '../../../crypto'; -import { handleOutboxMessageModel } from '../../../../receiver/dataMessage'; -import { ConversationTypeEnum } from '../../../../models/conversationAttributes'; -import { createSwarmMessageSentFromUs } from '../../../../models/messageFactory'; -import { Data } from '../../../../data/data'; -import { processMessagesUsingCache } from './sogsV3MutationCache'; -import { destroyMessagesAndUpdateRedux } from '../../../../util/expiringMessages'; +import { removeMessagePadding } from '../../../crypto/BufferPadding'; +import { destroyMessagesAndUpdateRedux } from '../../../disappearing_messages'; +import { UserUtils } from '../../../utils'; import { sogsRollingDeletions } from './sogsRollingDeletions'; -import { assertUnreachable } from '../../../../types/sqlSharedTypes'; +import { processMessagesUsingCache } from './sogsV3MutationCache'; /** * Get the convo matching those criteria and make sure it is an opengroup convo, or return null. diff --git a/ts/util/expiringMessages.ts b/ts/session/disappearing_messages/index.ts similarity index 89% rename from ts/util/expiringMessages.ts rename to ts/session/disappearing_messages/index.ts index cfb8a7bec..2dac2b10f 100644 --- a/ts/util/expiringMessages.ts +++ b/ts/session/disappearing_messages/index.ts @@ -1,22 +1,26 @@ import { throttle, uniq } from 'lodash'; -import { messagesExpired } from '../state/ducks/conversations'; -import { initWallClockListener } from './wallClockListener'; - -import { Data } from '../data/data'; -import { ConversationModel } from '../models/conversation'; -import { MessageModel } from '../models/message'; -import { ProtobufUtils, SignalService } from '../protobuf'; -import { expireMessageOnSnode } from '../session/apis/snode_api/expireRequest'; -import { GetNetworkTime } from '../session/apis/snode_api/getNetworkTime'; -import { getConversationController } from '../session/conversations'; +import { messagesExpired } from '../../state/ducks/conversations'; +import { initWallClockListener } from '../../util/wallClockListener'; + +import { Data } from '../../data/data'; +import { ConversationModel } from '../../models/conversation'; +import { MessageModel } from '../../models/message'; +import { SignalService } from '../../protobuf'; +import { ReleasedFeatures } from '../../util/releaseFeature'; +import { expireMessageOnSnode } from '../apis/snode_api/expireRequest'; +import { GetNetworkTime } from '../apis/snode_api/getNetworkTime'; +import { getConversationController } from '../conversations'; +import { isValidUnixTimestamp } from '../utils/Timestamps'; +import { + checkIsLegacyDisappearingDataMessage, + couldBeLegacyDisappearingMessageContent, +} from './legacy'; import { DisappearingMessageConversationModeType, DisappearingMessageMode, DisappearingMessageType, DisappearingMessageUpdate, -} from '../session/disappearing_messages/types'; -import { isValidUnixTimestamp } from '../session/utils/Timestamps'; -import { ReleasedFeatures } from './releaseFeature'; +} from './types'; export async function destroyMessagesAndUpdateRedux( messages: Array<{ @@ -126,7 +130,7 @@ const throttledCheckExpiringMessages = throttle(checkExpiringMessages, 1000); let isInit = false; -const initExpiringMessageListener = () => { +export const initExpiringMessageListener = () => { if (isInit) { throw new Error('expiring messages listener is already init'); } @@ -138,15 +142,10 @@ const initExpiringMessageListener = () => { isInit = true; }; -const updateExpiringMessagesCheck = () => { +export const updateExpiringMessagesCheck = () => { void throttledCheckExpiringMessages(); }; -export const ExpirationTimerOptions = { - initExpiringMessageListener, - updateExpiringMessagesCheck, -}; - export function setExpirationStartTimestamp( mode: DisappearingMessageConversationModeType, timestamp?: number, @@ -209,17 +208,6 @@ export function setExpirationStartTimestamp( return expirationStartTimestamp; } -// TODO legacy messages support will be removed in a future release -export function isLegacyDisappearingModeEnabled( - expirationMode: DisappearingMessageConversationModeType | undefined -): boolean { - return Boolean( - expirationMode && - expirationMode !== 'off' && - !ReleasedFeatures.isDisappearMessageV2FeatureReleasedCached() - ); -} - // TODO legacy messages support will be removed in a future release /** * Converts DisappearingMessageConversationModeType to DisappearingMessageType @@ -278,17 +266,6 @@ export function changeToDisappearingConversationMode( return expirationType === 'deleteAfterSend' ? 'deleteAfterSend' : 'deleteAfterRead'; } -// TODO legacy messages support will be removed in a future release -// NOTE We need this to check for legacy disappearing messages where the expirationType and expireTimer should be undefined on the ContentMessage -function couldBeLegacyDisappearingMessageContent(contentMessage: SignalService.Content): boolean { - return ( - (contentMessage.expirationType === SignalService.Content.ExpirationType.UNKNOWN || - (ReleasedFeatures.isDisappearMessageV2FeatureReleasedCached() && - !ProtobufUtils.hasDefinedProperty(contentMessage, 'expirationType'))) && - !ProtobufUtils.hasDefinedProperty(contentMessage, 'expirationTimer') - ); -} - /** * Checks if a message is meant to disappear but doesn't have the correct expiration values set * @@ -309,17 +286,6 @@ function checkDisappearButIsntMessage( ); } -export function checkIsLegacyDisappearingDataMessage( - couldBeLegacyContent: boolean, - dataMessage: SignalService.DataMessage -): boolean { - return ( - couldBeLegacyContent && - ProtobufUtils.hasDefinedProperty(dataMessage, 'expireTimer') && - dataMessage.expireTimer > -1 - ); -} - // TODO legacy messages support will be removed in a future release export async function checkForExpireUpdateInContentMessage( content: SignalService.Content, diff --git a/ts/session/disappearing_messages/legacy.ts b/ts/session/disappearing_messages/legacy.ts new file mode 100644 index 000000000..316cd73bf --- /dev/null +++ b/ts/session/disappearing_messages/legacy.ts @@ -0,0 +1,38 @@ +import { ProtobufUtils, SignalService } from '../../protobuf'; +import { ReleasedFeatures } from '../../util/releaseFeature'; +import { DisappearingMessageConversationModeType } from './types'; + +// TODO legacy messages support will be removed in a future release +export function isLegacyDisappearingModeEnabled( + expirationMode: DisappearingMessageConversationModeType | undefined +): boolean { + return Boolean( + expirationMode && + expirationMode !== 'off' && + !ReleasedFeatures.isDisappearMessageV2FeatureReleasedCached() + ); +} + +export function checkIsLegacyDisappearingDataMessage( + couldBeLegacyContent: boolean, + dataMessage: SignalService.DataMessage +): boolean { + return ( + couldBeLegacyContent && + ProtobufUtils.hasDefinedProperty(dataMessage, 'expireTimer') && + dataMessage.expireTimer > -1 + ); +} + +// TODO legacy messages support will be removed in a future release +// NOTE We need this to check for legacy disappearing messages where the expirationType and expireTimer should be undefined on the ContentMessage +export function couldBeLegacyDisappearingMessageContent( + contentMessage: SignalService.Content +): boolean { + return ( + (contentMessage.expirationType === SignalService.Content.ExpirationType.UNKNOWN || + (ReleasedFeatures.isDisappearMessageV2FeatureReleasedCached() && + !ProtobufUtils.hasDefinedProperty(contentMessage, 'expirationType'))) && + !ProtobufUtils.hasDefinedProperty(contentMessage, 'expirationTimer') + ); +} diff --git a/ts/session/group/closed-group.ts b/ts/session/group/closed-group.ts index bb8861cc4..46b6251c4 100644 --- a/ts/session/group/closed-group.ts +++ b/ts/session/group/closed-group.ts @@ -12,15 +12,15 @@ import { distributingClosedGroupEncryptionKeyPairs, } from '../../receiver/closedGroups'; import { ECKeyPair } from '../../receiver/keypairs'; -import { - changeToDisappearingMessageType, - setExpirationStartTimestamp, -} from '../../util/expiringMessages'; import { GetNetworkTime } from '../apis/snode_api/getNetworkTime'; import { SnodeNamespaces } from '../apis/snode_api/namespaces'; import { getConversationController } from '../conversations'; import { generateCurve25519KeyPairWithoutPrefix } from '../crypto'; import { encryptUsingSessionProtocol } from '../crypto/MessageEncrypter'; +import { + changeToDisappearingMessageType, + setExpirationStartTimestamp, +} from '../disappearing_messages'; import { DisappearAfterSendOnly } from '../disappearing_messages/types'; import { ClosedGroupAddedMembersMessage } from '../messages/outgoing/controlMessage/group/ClosedGroupAddedMembersMessage'; import { ClosedGroupEncryptionPairMessage } from '../messages/outgoing/controlMessage/group/ClosedGroupEncryptionPairMessage'; diff --git a/ts/session/sending/MessageSender.ts b/ts/session/sending/MessageSender.ts index 984de39bb..0aeeae442 100644 --- a/ts/session/sending/MessageSender.ts +++ b/ts/session/sending/MessageSender.ts @@ -8,39 +8,39 @@ import { Data } from '../../data/data'; import { SignalService } from '../../protobuf'; import { OpenGroupRequestCommonType } from '../apis/open_group_api/opengroupV2/ApiUtil'; import { OpenGroupMessageV2 } from '../apis/open_group_api/opengroupV2/OpenGroupMessageV2'; -import { fromUInt8ArrayToBase64 } from '../utils/String'; -import { EmptySwarmError } from '../utils/errors'; import { sendMessageOnionV4BlindedRequest, sendSogsMessageOnionV4, } from '../apis/open_group_api/sogsv3/sogsV3SendMessage'; -import { GetNetworkTime } from '../apis/snode_api/getNetworkTime'; -import { SnodeNamespace, SnodeNamespaces } from '../apis/snode_api/namespaces'; -import { getSwarmFor } from '../apis/snode_api/snodePool'; import { NotEmptyArrayOfBatchResults, StoreOnNodeMessage, StoreOnNodeParams, StoreOnNodeParamsNoSig, } from '../apis/snode_api/SnodeRequestTypes'; +import { GetNetworkTime } from '../apis/snode_api/getNetworkTime'; +import { SnodeNamespace, SnodeNamespaces } from '../apis/snode_api/namespaces'; +import { getSwarmFor } from '../apis/snode_api/snodePool'; import { SnodeSignature, SnodeSignatureResult } from '../apis/snode_api/snodeSignatures'; import { SnodeAPIStore } from '../apis/snode_api/storeMessage'; import { getConversationController } from '../conversations'; import { MessageEncrypter } from '../crypto'; import { addMessagePadding } from '../crypto/BufferPadding'; +import { + changeToDisappearingConversationMode, + updateMessageExpiryOnSwarm, +} from '../disappearing_messages'; import { ContentMessage } from '../messages/outgoing'; import { ConfigurationMessage } from '../messages/outgoing/controlMessage/ConfigurationMessage'; -import { ClosedGroupNewMessage } from '../messages/outgoing/controlMessage/group/ClosedGroupNewMessage'; import { SharedConfigMessage } from '../messages/outgoing/controlMessage/SharedConfigMessage'; import { UnsendMessage } from '../messages/outgoing/controlMessage/UnsendMessage'; +import { ClosedGroupNewMessage } from '../messages/outgoing/controlMessage/group/ClosedGroupNewMessage'; import { OpenGroupVisibleMessage } from '../messages/outgoing/visibleMessage/OpenGroupVisibleMessage'; import { ed25519Str } from '../onions/onionPath'; import { PubKey } from '../types'; import { RawMessage } from '../types/RawMessage'; -import { - changeToDisappearingConversationMode, - updateMessageExpiryOnSwarm, -} from '../../util/expiringMessages'; +import { fromUInt8ArrayToBase64 } from '../utils/String'; +import { EmptySwarmError } from '../utils/errors'; // ================ SNODE STORE ================ diff --git a/ts/session/sending/MessageSentHandler.ts b/ts/session/sending/MessageSentHandler.ts index 462a49ae9..504e4a96c 100644 --- a/ts/session/sending/MessageSentHandler.ts +++ b/ts/session/sending/MessageSentHandler.ts @@ -1,11 +1,11 @@ import _ from 'lodash'; import { Data } from '../../data/data'; import { SignalService } from '../../protobuf'; +import { PnServer } from '../apis/push_notification_api'; import { changeToDisappearingConversationMode, setExpirationStartTimestamp, -} from '../../util/expiringMessages'; -import { PnServer } from '../apis/push_notification_api'; +} from '../disappearing_messages'; import { OpenGroupVisibleMessage } from '../messages/outgoing/visibleMessage/OpenGroupVisibleMessage'; import { RawMessage } from '../types'; import { UserUtils } from '../utils'; diff --git a/ts/session/utils/calling/CallManager.ts b/ts/session/utils/calling/CallManager.ts index a580119b9..e169fcbee 100644 --- a/ts/session/utils/calling/CallManager.ts +++ b/ts/session/utils/calling/CallManager.ts @@ -26,14 +26,14 @@ import { getCallMediaPermissionsSettings } from '../../../components/settings/Se import { Data } from '../../../data/data'; import { approveConvoAndSendResponse } from '../../../interactions/conversationInteractions'; import { READ_MESSAGE_STATE } from '../../../models/conversationAttributes'; -import { - changeToDisappearingMessageType, - setExpirationStartTimestamp, -} from '../../../util/expiringMessages'; import { PnServer } from '../../apis/push_notification_api'; import { GetNetworkTime } from '../../apis/snode_api/getNetworkTime'; import { SnodeNamespaces } from '../../apis/snode_api/namespaces'; import { DURATION } from '../../constants'; +import { + changeToDisappearingMessageType, + setExpirationStartTimestamp, +} from '../../disappearing_messages'; import { MessageSender } from '../../sending'; import { getIsRinging } from '../RingingManager'; import { getBlackSilenceMediaStream } from './Silence'; diff --git a/ts/test/session/unit/disappearing/DisappearingMessage_test.ts b/ts/test/session/unit/disappearing_messages/DisappearingMessage_test.ts similarity index 99% rename from ts/test/session/unit/disappearing/DisappearingMessage_test.ts rename to ts/test/session/unit/disappearing_messages/DisappearingMessage_test.ts index f341bf3de..0d42dc09d 100644 --- a/ts/test/session/unit/disappearing/DisappearingMessage_test.ts +++ b/ts/test/session/unit/disappearing_messages/DisappearingMessage_test.ts @@ -4,18 +4,18 @@ import Sinon from 'sinon'; import { ConversationModel } from '../../../../models/conversation'; import { ConversationTypeEnum } from '../../../../models/conversationAttributes'; import { GetNetworkTime } from '../../../../session/apis/snode_api/getNetworkTime'; +import { + changeToDisappearingConversationMode, + changeToDisappearingMessageType, + checkForExpireUpdateInContentMessage, + setExpirationStartTimestamp, +} from '../../../../session/disappearing_messages'; import { DisappearingMessageConversationModeType, DisappearingMessageType, } from '../../../../session/disappearing_messages/types'; import { UserUtils } from '../../../../session/utils'; import { isValidUnixTimestamp } from '../../../../session/utils/Timestamps'; -import { - changeToDisappearingConversationMode, - changeToDisappearingMessageType, - checkForExpireUpdateInContentMessage, - setExpirationStartTimestamp, -} from '../../../../util/expiringMessages'; import { ReleasedFeatures } from '../../../../util/releaseFeature'; import { TestUtils } from '../../../test-utils'; import { diff --git a/ts/test/session/unit/disappearing/ExpireRequest_test.ts b/ts/test/session/unit/disappearing_messages/ExpireRequest_test.ts similarity index 100% rename from ts/test/session/unit/disappearing/ExpireRequest_test.ts rename to ts/test/session/unit/disappearing_messages/ExpireRequest_test.ts diff --git a/ts/test/session/unit/disappearing/GetExpiriesRequest_test.ts b/ts/test/session/unit/disappearing_messages/GetExpiriesRequest_test.ts similarity index 100% rename from ts/test/session/unit/disappearing/GetExpiriesRequest_test.ts rename to ts/test/session/unit/disappearing_messages/GetExpiriesRequest_test.ts