Faster incremental builds

This commit is contained in:
Fedor Indutny
2025-10-06 12:23:41 -07:00
committed by GitHub
parent 7ab12f3d7a
commit 780f39c285
130 changed files with 1479 additions and 1450 deletions
+12
View File
@@ -260,6 +260,18 @@ const typescriptRules = {
// TODO: DESKTOP-4655
'import/no-cycle': 'off',
'import/no-restricted-paths': [
'error',
{
zones: [
{
target: ['ts/util', 'ts/types'],
from: ['ts/components', 'ts/axo'],
message: 'Importing components is forbidden from ts/{util,types}',
},
],
},
],
};
const TAILWIND_REPLACEMENTS = [
+1 -1
View File
@@ -13,7 +13,7 @@ import type {
SessionResetsType,
ProcessedDataMessage,
} from './textsecure/Types.d.ts';
import { HTTPError } from './textsecure/Errors.js';
import { HTTPError } from './types/HTTPError.js';
import createTaskWithTimeout, {
suspendTasksWithTimeout,
resumeTasksWithTimeout,
+2 -4
View File
@@ -18,10 +18,8 @@ import { clearTimeoutIfNecessary } from './util/clearTimeoutIfNecessary.js';
import { missingCaseError } from './util/missingCaseError.js';
import type { StorageInterface } from './types/Storage.d.ts';
import * as Errors from './types/errors.js';
import {
HTTPError,
type SendMessageChallengeData,
} from './textsecure/Errors.js';
import { HTTPError } from './types/HTTPError.js';
import type { SendMessageChallengeData } from './textsecure/Errors.js';
import { createLogger } from './logging/log.js';
import { drop } from './util/drop.js';
import { findRetryAfterTimeFromError } from './jobs/helpers/findRetryAfterTimeFromError.js';
+1 -1
View File
@@ -38,7 +38,7 @@ import type {
AttachmentDraftType,
InMemoryAttachmentDraftType,
} from '../types/Attachment.js';
import { isImageAttachment, isVoiceMessage } from '../types/Attachment.js';
import { isImageAttachment, isVoiceMessage } from '../util/Attachment.js';
import type { AciString } from '../types/ServiceId.js';
import { AudioCapture } from './conversation/AudioCapture.js';
import { CompositionUpload } from './CompositionUpload.js';
+1 -1
View File
@@ -5,7 +5,7 @@ import type { ChangeEventHandler } from 'react';
import React, { forwardRef } from 'react';
import type { AttachmentDraftType } from '../types/Attachment.js';
import { isVideoAttachment, isImageAttachment } from '../types/Attachment.js';
import { isVideoAttachment, isImageAttachment } from '../util/Attachment.js';
import type { LocalizerType } from '../types/Util.js';
import {
+1 -1
View File
@@ -3,7 +3,7 @@
import React from 'react';
import { getExtensionForDisplay } from '../types/Attachment.js';
import { getExtensionForDisplay } from '../util/Attachment.js';
import { isFileDangerous } from '../util/isFileDangerous.js';
import { tw } from '../axo/tw.js';
+1 -1
View File
@@ -22,7 +22,7 @@ import { Avatar, AvatarSize } from './Avatar.js';
import { IMAGE_PNG, isImage, isVideo } from '../types/MIME.js';
import { formatDateTimeForAttachment } from '../util/timestamp.js';
import { formatDuration } from '../util/formatDuration.js';
import { isGIF, isIncremental } from '../types/Attachment.js';
import { isGIF, isIncremental } from '../util/Attachment.js';
import { useRestoreFocus } from '../hooks/useRestoreFocus.js';
import { usePrevious } from '../hooks/usePrevious.js';
import { arrow } from '../util/keyboard.js';
@@ -27,13 +27,6 @@ import { UserText } from './UserText.js';
const { noop } = lodash;
export enum SafetyNumberChangeSource {
InitiateCall = 'InitiateCall',
JoinCall = 'JoinCall',
MessageSend = 'MessageSend',
Story = 'Story',
}
enum DialogState {
StartingInReview = 'StartingInReview',
ExplicitReviewNeeded = 'ExplicitReviewNeeded',
+1 -1
View File
@@ -17,7 +17,7 @@ import type { PropsType as TextStoryCreatorPropsType } from './TextStoryCreator.
import type { PropsType as MediaEditorPropsType } from './MediaEditor.js';
import { TEXT_ATTACHMENT } from '../types/MIME.js';
import { isVideoAttachment } from '../types/Attachment.js';
import { isVideoAttachment } from '../util/Attachment.js';
import { SendStoryModal } from './SendStoryModal.js';
import { MediaEditor } from './MediaEditor.js';
+1 -1
View File
@@ -18,7 +18,7 @@ import {
isDownloaded,
isDownloading,
isGIF,
} from '../types/Attachment.js';
} from '../util/Attachment.js';
import { getClassNamesFor } from '../util/getClassNamesFor.js';
import { isVideoTypeSupported } from '../util/GoogleChrome.js';
import { createLogger } from '../logging/log.js';
+1 -1
View File
@@ -8,7 +8,7 @@ import lodash from 'lodash';
import type { LinkPreviewForUIType } from '../types/message/LinkPreviews.js';
import type { LocalizerType } from '../types/Util.js';
import { CurveType, Image } from './conversation/Image.js';
import { isImageAttachment } from '../types/Attachment.js';
import { isImageAttachment } from '../util/Attachment.js';
import { getSafeDomain } from '../types/LinkPreview.js';
const { unescape } = lodash;
+1 -1
View File
@@ -43,7 +43,7 @@ import { ToastType } from '../types/Toast.js';
import { getAvatarColor } from '../types/Colors.js';
import { getStoryBackground } from '../util/getStoryBackground.js';
import { getStoryDuration } from '../util/getStoryDuration.js';
import { isVideoAttachment } from '../types/Attachment.js';
import { isVideoAttachment } from '../util/Attachment.js';
import { graphemeAndLinkAwareSlice } from '../util/graphemeAndLinkAwareSlice.js';
import { useEscapeHandling } from '../hooks/useEscapeHandling.js';
import { useRetryStorySend } from '../hooks/useRetryStorySend.js';
@@ -16,7 +16,7 @@ import {
canDisplayImage,
isImageAttachment,
isVideoAttachment,
} from '../../types/Attachment.js';
} from '../../util/Attachment.js';
export type Props<T extends AttachmentForUIType | AttachmentDraftType> =
Readonly<{
@@ -4,7 +4,7 @@
import React from 'react';
import classNames from 'classnames';
import { useEscapeHandling } from '../../hooks/useEscapeHandling.js';
import { getSuggestedFilename } from '../../types/Attachment.js';
import { getSuggestedFilename } from '../../util/Attachment.js';
import { IMAGE_PNG, type MIMEType } from '../../types/MIME.js';
export type PropsType = {
+1 -1
View File
@@ -13,7 +13,7 @@ import {
getImageDimensionsForTimeline,
defaultBlurHash,
isDownloadable,
} from '../../types/Attachment.js';
} from '../../util/Attachment.js';
import * as Errors from '../../types/errors.js';
import { createLogger } from '../../logging/log.js';
import { useReducedMotion } from '../../hooks/useReducedMotion.js';
+1 -1
View File
@@ -12,7 +12,7 @@ import {
defaultBlurHash,
isIncremental,
isReadyToView,
} from '../../types/Attachment.js';
} from '../../util/Attachment.js';
import { SpinnerV2 } from '../SpinnerV2.js';
import { useUndownloadableMediaHandler } from '../../hooks/useUndownloadableMediaHandler.js';
@@ -17,7 +17,7 @@ import {
import { pngUrl, squareStickerUrl } from '../../storybook/Fixtures.js';
import { fakeAttachment } from '../../test-helpers/fakeAttachment.js';
import { strictAssert } from '../../util/assert.js';
import { isDownloadable } from '../../types/Attachment.js';
import { isDownloadable } from '../../util/Attachment.js';
const { i18n } = window.SignalContext;
+1 -1
View File
@@ -17,7 +17,7 @@ import {
isDownloadable,
isIncremental,
isVideoAttachment,
} from '../../types/Attachment.js';
} from '../../util/Attachment.js';
import { Image, CurveType } from './Image.js';
+2 -8
View File
@@ -53,6 +53,7 @@ import type { WidthBreakpoint } from '../_util.js';
import { OutgoingGiftBadgeModal } from '../OutgoingGiftBadgeModal.js';
import { createLogger } from '../../logging/log.js';
import { StoryViewModeType } from '../../types/Stories.js';
import { GiftBadgeStates } from '../../types/GiftBadgeStates.js';
import type {
AttachmentForUIType,
AttachmentType,
@@ -71,7 +72,7 @@ import {
isImageAttachment,
isPlayed,
isVideo,
} from '../../types/Attachment.js';
} from '../../util/Attachment.js';
import type { EmbeddedContactForUIType } from '../../types/EmbeddedContact.js';
import { getIncrement } from '../../util/timer.js';
@@ -208,13 +209,6 @@ export type AudioAttachmentProps = {
onCorrupted(): void;
};
export enum GiftBadgeStates {
Unopened = 'Unopened',
Opened = 'Opened',
Redeemed = 'Redeemed',
Failed = 'Failed',
}
export type GiftBadgeType =
| {
state:
+1 -1
View File
@@ -11,7 +11,7 @@ import type { LocalizerType } from '../../types/Util.js';
import type { AttachmentForUIType } from '../../types/Attachment.js';
import type { MessageStatusType } from '../../types/message/MessageStatus.js';
import type { PushPanelForConversationActionType } from '../../state/ducks/conversations.js';
import { isDownloaded } from '../../types/Attachment.js';
import { isDownloaded } from '../../util/Attachment.js';
import type { DirectionType } from './Message.js';
import type { ComputePeaksResult } from '../VoiceNotesPlaybackContext.js';
+1 -1
View File
@@ -4,7 +4,7 @@
import type { KeyboardEvent } from 'react';
import React from 'react';
import type { AttachmentType } from '../../types/Attachment.js';
import { canBeDownloaded, isDownloaded } from '../../types/Attachment.js';
import { canBeDownloaded, isDownloaded } from '../../util/Attachment.js';
import type { ShowConversationType } from '../../state/ducks/conversations.js';
import type { HydratedBodyRangesType } from '../../types/BodyRange.js';
import type { LocalizerType } from '../../types/Util.js';
@@ -11,7 +11,7 @@ import { LinkPreviewDate } from './LinkPreviewDate.js';
import type { LinkPreviewForUIType } from '../../types/message/LinkPreviews.js';
import type { LocalizerType } from '../../types/Util.js';
import { getClassNamesFor } from '../../util/getClassNamesFor.js';
import { isImageAttachment } from '../../types/Attachment.js';
import { isImageAttachment } from '../../util/Attachment.js';
import { isCallLink } from '../../types/LinkPreview.js';
import { Avatar } from '../Avatar.js';
import { getColorForCallLink } from '../../util/getColorForCallLink.js';
@@ -13,7 +13,7 @@ import { EmojiPicker } from '../emoji/EmojiPicker.js';
import type { AudioAttachmentProps } from './Message.js';
import type { Props } from './TimelineMessage.js';
import { TimelineMessage } from './TimelineMessage.js';
import { GiftBadgeStates, TextDirection } from './Message.js';
import { TextDirection } from './Message.js';
import {
AUDIO_MP3,
IMAGE_JPEG,
@@ -33,6 +33,7 @@ import { getDefaultConversation } from '../../test-helpers/getDefaultConversatio
import { WidthBreakpoint } from '../_util.js';
import { DAY, HOUR, MINUTE, SECOND } from '../../util/durations/index.js';
import { ContactFormType } from '../../types/EmbeddedContact.js';
import { GiftBadgeStates } from '../../types/GiftBadgeStates.js';
import { generateAci } from '../../types/ServiceId.js';
import {
@@ -15,7 +15,7 @@ import { ContextMenuTrigger } from 'react-contextmenu';
import { createPortal } from 'react-dom';
import { Manager, Popper, Reference } from 'react-popper';
import type { PreventOverflowModifier } from '@popperjs/core/lib/modifiers/preventOverflow.js';
import { isDownloaded } from '../../types/Attachment.js';
import { isDownloaded } from '../../util/Attachment.js';
import type { LocalizerType } from '../../types/I18N.js';
import { handleOutsideClick } from '../../util/handleOutsideClick.js';
import { offsetDistanceModifier } from '../../util/popperUtil.js';
@@ -16,7 +16,7 @@ import {
defaultBlurHash,
isGIF,
isVideoAttachment,
} from '../../../types/Attachment.js';
} from '../../../util/Attachment.js';
import { ImageOrBlurhash } from '../../ImageOrBlurhash.js';
import { SpinnerV2 } from '../../SpinnerV2.js';
import { tw } from '../../../axo/tw.js';
+1 -1
View File
@@ -54,7 +54,7 @@ import type {
GroupCredentialsType,
GroupLogResponseType,
} from './textsecure/WebAPI.js';
import { HTTPError } from './textsecure/Errors.js';
import { HTTPError } from './types/HTTPError.js';
import type MessageSender from './textsecure/SendMessage.js';
import { CURRENT_SCHEMA_VERSION as MAX_MESSAGE_SCHEMA } from './types/Message2.js';
import type { ConversationModel } from './models/conversations.js';
+1 -1
View File
@@ -11,7 +11,7 @@ import { DataWriter } from '../sql/Client.js';
import * as Bytes from '../Bytes.js';
import * as Errors from '../types/errors.js';
import { createLogger } from '../logging/log.js';
import { HTTPError } from '../textsecure/Errors.js';
import { HTTPError } from '../types/HTTPError.js';
import { SignalService as Proto } from '../protobuf/index.js';
import type { ContactAvatarType } from '../types/Avatar.js';
import { ToastType } from '../types/Toast.js';
+2 -1
View File
@@ -1,7 +1,8 @@
// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { getUrl, type AttachmentForUIType } from '../types/Attachment.js';
import type { AttachmentForUIType } from '../types/Attachment.js';
import { getUrl } from '../util/Attachment.js';
import { MediaTier } from '../types/AttachmentDownload.js';
import { missingCaseError } from '../util/missingCaseError.js';
import { getAttachmentCiphertextSize } from '../util/AttachmentCrypto.js';
+2 -2
View File
@@ -45,11 +45,11 @@ import {
} from '../services/backups/util/mediaId.js';
import { fromBase64, toBase64 } from '../Bytes.js';
import type { WebAPIType } from '../textsecure/WebAPI.js';
import type { AttachmentType } from '../types/Attachment.js';
import {
type AttachmentType,
canAttachmentHaveThumbnail,
mightStillBeOnTransitTier,
} from '../types/Attachment.js';
} from '../util/Attachment.js';
import {
type CreatedThumbnailType,
makeImageThumbnailForBackup,
+4 -2
View File
@@ -27,13 +27,15 @@ import {
type AttachmentType,
AttachmentVariant,
AttachmentPermanentlyUndownloadableError,
} from '../types/Attachment.js';
import {
wasImportedFromLocalBackup,
canAttachmentHaveThumbnail,
shouldAttachmentEndUpInRemoteBackup,
getUndownloadedAttachmentSignature,
isIncremental,
hasRequiredInformationForBackup,
} from '../types/Attachment.js';
} from '../util/Attachment.js';
import type { ReadonlyMessageAttributesType } from '../model-types.d.ts';
import { backupsService } from '../services/backups/index.js';
import { getMessageById } from '../messages/getMessageById.js';
@@ -69,7 +71,7 @@ import { formatCountForLogging } from '../logging/formatCountForLogging.js';
import { strictAssert } from '../util/assert.js';
import { getAttachmentCiphertextSize } from '../util/AttachmentCrypto.js';
import { updateBackupMediaDownloadProgress } from '../util/updateBackupMediaDownloadProgress.js';
import { HTTPError } from '../textsecure/Errors.js';
import { HTTPError } from '../types/HTTPError.js';
import { isOlderThan } from '../util/timestamp.js';
import { getMessageQueueTime as doGetMessageQueueTime } from '../util/getMessageQueueTime.js';
import { JobCancelReason } from './types.js';
+2 -2
View File
@@ -5,13 +5,13 @@ import type { AttachmentBackfillResponseSyncEvent } from '../../textsecure/messa
import MessageSender from '../../textsecure/SendMessage.js';
import { createLogger } from '../../logging/log.js';
import type { ReadonlyMessageAttributesType } from '../../model-types.d.ts';
import type { AttachmentType } from '../../types/Attachment.js';
import {
type AttachmentType,
isDownloading,
isDownloaded,
isDownloadable,
getUndownloadedAttachmentSignature,
} from '../../types/Attachment.js';
} from '../../util/Attachment.js';
import {
type MessageAttachmentType,
AttachmentDownloadUrgency,
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { isRecord } from '../../util/isRecord.js';
import { HTTPError } from '../../textsecure/Errors.js';
import { HTTPError } from '../../types/HTTPError.js';
import { parseRetryAfterWithDefault } from '../../util/parseRetryAfter.js';
export function findRetryAfterTimeFromError(
+1 -1
View File
@@ -15,7 +15,7 @@ import { JobQueue } from './JobQueue.js';
import { jobQueueDatabaseStore } from './JobQueueDatabaseStore.js';
import { parseIntWithFallback } from '../util/parseIntWithFallback.js';
import type { WebAPIType } from '../textsecure/WebAPI.js';
import { HTTPError } from '../textsecure/Errors.js';
import { HTTPError } from '../types/HTTPError.js';
import { sleeper } from '../util/sleeper.js';
import { parseUnknown } from '../util/schemas.js';
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import type { LinkPreviewType } from '../types/message/LinkPreviews.js';
import { isImageAttachment } from '../types/Attachment.js';
import { isImageAttachment } from '../util/Attachment.js';
const MINIMUM_FULL_SIZE_DIMENSION = 200;
+1 -1
View File
@@ -9,7 +9,7 @@ import type { AttachmentType } from '../types/Attachment.js';
import {
doAttachmentsOnSameMessageMatch,
isDownloaded,
} from '../types/Attachment.js';
} from '../util/Attachment.js';
import { getMessageById } from '../messages/getMessageById.js';
import { trimMessageWhitespace } from '../types/BodyRange.js';
+1 -1
View File
@@ -6,7 +6,7 @@ import { z } from 'zod';
import type { ReadonlyMessageAttributesType } from '../model-types.d.ts';
import * as Errors from '../types/errors.js';
import { createLogger } from '../logging/log.js';
import { GiftBadgeStates } from '../components/conversation/Message.js';
import { GiftBadgeStates } from '../types/GiftBadgeStates.js';
import { ReadStatus } from '../messages/MessageReadStatus.js';
import { getMessageIdForLogging } from '../util/idForLogging.js';
import { getMessageSentTimestamp } from '../util/getMessageSentTimestamp.js';
+1 -1
View File
@@ -14,7 +14,7 @@ import { getQuoteBodyText } from '../util/getQuoteBodyText.js';
import { isQuoteAMatch, messageHasPaymentEvent } from './helpers.js';
import * as Errors from '../types/errors.js';
import type { MessageModel } from '../models/messages.js';
import { isDownloadable } from '../types/Attachment.js';
import { isDownloadable } from '../util/Attachment.js';
const { omit } = lodash;
+1 -1
View File
@@ -49,7 +49,7 @@ import { isMessageEmpty } from '../util/isMessageEmpty.js';
import { isValidTapToView } from '../util/isValidTapToView.js';
import { getNotificationTextForMessage } from '../util/getNotificationTextForMessage.js';
import { getMessageAuthorText } from '../util/getMessageAuthorText.js';
import { GiftBadgeStates } from '../components/conversation/Message.js';
import { GiftBadgeStates } from '../types/GiftBadgeStates.js';
import { parseBoostBadgeListFromServer } from '../badges/parseBadgesFromServer.js';
import { SignalService as Proto } from '../protobuf/index.js';
import {
+1 -1
View File
@@ -16,7 +16,7 @@ import { PaymentEventKind } from '../types/Payment.js';
import type { AnyPaymentEvent } from '../types/Payment.js';
import type { LocalizerType } from '../types/Util.js';
import { missingCaseError } from '../util/missingCaseError.js';
import { isDownloaded } from '../types/Attachment.js';
import { isDownloaded } from '../util/Attachment.js';
const log = createLogger('helpers');
+2 -5
View File
@@ -13,10 +13,7 @@ import type { ReadStatus } from './messages/MessageReadStatus.js';
import type { SendStateByConversationId } from './messages/MessageSendState.js';
import type { GroupNameCollisionsWithIdsByTitle } from './util/groupMemberNameCollisions.js';
import type {
AttachmentDraftType,
AttachmentType,
} from './types/Attachment.js';
import type { AttachmentDraftType, AttachmentType } from './util/Attachment.js';
import type { EmbeddedContactType } from './types/EmbeddedContact.js';
import { SignalService as Proto } from './protobuf/index.js';
import type { AvatarDataType, ContactAvatarType } from './types/Avatar.js';
@@ -27,7 +24,7 @@ import type {
} from './types/ServiceId.js';
import type { StoryDistributionIdString } from './types/StoryDistributionId.js';
import type { SeenStatus } from './MessageSeenStatus.js';
import type { GiftBadgeStates } from './components/conversation/Message.js';
import type { GiftBadgeStates } from './types/GiftBadgeStates.js';
import type { LinkPreviewType } from './types/message/LinkPreviews.js';
import type { StickerType } from './types/Stickers.js';
+1 -1
View File
@@ -21,7 +21,7 @@ import {
type SubscriptionCostType,
} from '../../types/backups.js';
import { uploadFile } from '../../util/uploadAttachment.js';
import { HTTPError } from '../../textsecure/Errors.js';
import { HTTPError } from '../../types/HTTPError.js';
import { createLogger } from '../../logging/log.js';
import { toLogFormat } from '../../types/errors.js';
+1 -1
View File
@@ -33,7 +33,7 @@ import {
BackupCredentialType,
} from '../../types/backups.js';
import { toLogFormat } from '../../types/errors.js';
import { HTTPError } from '../../textsecure/Errors.js';
import { HTTPError } from '../../types/HTTPError.js';
import type {
GetBackupCredentialsResponseType,
GetBackupCDNCredentialsResponseType,
+3 -3
View File
@@ -23,7 +23,7 @@ import type {
IdentityKeyType,
} from '../../sql/Interface.js';
import { createLogger } from '../../logging/log.js';
import { GiftBadgeStates } from '../../components/conversation/Message.js';
import { GiftBadgeStates } from '../../types/GiftBadgeStates.js';
import { type CustomColorType } from '../../types/Colors.js';
import { StorySendMode, MY_STORY_ID } from '../../types/Stories.js';
import { getStickerPacksForBackup } from '../../types/Stickers.js';
@@ -125,12 +125,12 @@ import {
numberToPhoneType,
} from '../../types/EmbeddedContact.js';
import { toLogFormat } from '../../types/errors.js';
import type { AttachmentType } from '../../types/Attachment.js';
import {
type AttachmentType,
isGIF,
isDownloaded,
hasRequiredInformationForBackup,
} from '../../types/Attachment.js';
} from '../../util/Attachment.js';
import { getFilePointerForAttachment } from './util/filePointers.js';
import { getBackupMediaRootKey } from './crypto.js';
import type {
+1 -1
View File
@@ -21,7 +21,7 @@ import {
type IdentityKeyType,
} from '../../sql/Interface.js';
import { createLogger } from '../../logging/log.js';
import { GiftBadgeStates } from '../../components/conversation/Message.js';
import { GiftBadgeStates } from '../../types/GiftBadgeStates.js';
import { StorySendMode, MY_STORY_ID } from '../../types/Stories.js';
import type { AciString, ServiceIdString } from '../../types/ServiceId.js';
import * as LinkPreview from '../../types/LinkPreview.js';
+1 -1
View File
@@ -42,7 +42,7 @@ import {
type BackupsSubscriptionType,
type BackupStatusType,
} from '../../types/backups.js';
import { HTTPError } from '../../textsecure/Errors.js';
import { HTTPError } from '../../types/HTTPError.js';
import { constantTimeEqual } from '../../Crypto.js';
import { measureSize } from '../../AttachmentCrypto.js';
import { isTestOrMockEnvironment } from '../../environment.js';
+2 -2
View File
@@ -8,11 +8,11 @@ import {
stringToMIMEType,
} from '../../../types/MIME.js';
import { createLogger } from '../../../logging/log.js';
import type { AttachmentType } from '../../../types/Attachment.js';
import {
type AttachmentType,
hasRequiredInformationForBackup,
hasRequiredInformationToDownloadFromTransitTier,
} from '../../../types/Attachment.js';
} from '../../../util/Attachment.js';
import { Backups, SignalService } from '../../../protobuf/index.js';
import * as Bytes from '../../../Bytes.js';
import {
+1 -1
View File
@@ -4,7 +4,7 @@
import { DataReader } from '../../../sql/Client.js';
import * as Bytes from '../../../Bytes.js';
import { getBackupMediaRootKey } from '../crypto.js';
import { type BackupableAttachmentType } from '../../../types/Attachment.js';
import type { BackupableAttachmentType } from '../../../types/Attachment.js';
export function getMediaIdFromMediaName(mediaName: string): {
string: string;
+1 -1
View File
@@ -33,7 +33,7 @@ import { drop } from '../util/drop.js';
import { findRetryAfterTimeFromError } from '../jobs/helpers/findRetryAfterTimeFromError.js';
import { singleProtoJobQueue } from '../jobs/singleProtoJobQueue.js';
import { SEALED_SENDER } from '../types/SealedSender.js';
import { HTTPError } from '../textsecure/Errors.js';
import { HTTPError } from '../types/HTTPError.js';
import { Address } from '../types/Address.js';
import { QualifiedAddress } from '../types/QualifiedAddress.js';
import { trimForDisplay, verifyAccessKey, decryptProfile } from '../Crypto.js';
+1 -1
View File
@@ -9,7 +9,7 @@ import { clearTimeoutIfNecessary } from '../util/clearTimeoutIfNecessary.js';
import * as Registration from '../util/registration.js';
import { createLogger } from '../logging/log.js';
import * as Errors from '../types/errors.js';
import { HTTPError } from '../textsecure/Errors.js';
import { HTTPError } from '../types/HTTPError.js';
import { drop } from '../util/drop.js';
import { strictAssert } from '../util/assert.js';
import type { MessageAttributesType } from '../model-types.js';
+1 -1
View File
@@ -23,7 +23,7 @@ import {
import * as Errors from '../types/errors.js';
import { createLogger } from '../logging/log.js';
import MessageSender from '../textsecure/SendMessage.js';
import { HTTPError } from '../textsecure/Errors.js';
import { HTTPError } from '../types/HTTPError.js';
import { findRetryAfterTimeFromError } from '../jobs/helpers/findRetryAfterTimeFromError.js';
import * as Bytes from '../Bytes.js';
import { storageServiceUploadJob } from './storage.js';
+1 -1
View File
@@ -10,7 +10,7 @@ import { isProduction } from './util/version.js';
import { DataReader, DataWriter } from './sql/Client.js';
// Types
import * as TypesAttachment from './types/Attachment.js';
import * as TypesAttachment from './util/Attachment.js';
import * as VisualAttachment from './types/VisualAttachment.js';
import * as MessageType from './types/Message2.js';
import { Address } from './types/Address.js';
+2 -5
View File
@@ -255,11 +255,8 @@ import { INITIAL_EXPIRE_TIMER_VERSION } from '../util/expirationTimer.js';
import type { GifType } from '../components/fun/panels/FunPanelGifs.js';
import type { NotificationProfileType } from '../types/NotificationProfile.js';
import * as durations from '../util/durations/index.js';
import {
isFile,
isVisualMedia,
type AttachmentType,
} from '../types/Attachment.js';
import type { AttachmentType } from '../types/Attachment.js';
import { isFile, isVisualMedia } from '../util/Attachment.js';
import { generateMessageId } from '../util/generateMessageId.js';
import type {
ConversationColorType,
+1 -1
View File
@@ -23,7 +23,7 @@ import {
sql,
sqlJoin,
} from './util.js';
import { type AttachmentType } from '../types/Attachment.js';
import type { AttachmentType } from '../types/Attachment.js';
import {
APPLICATION_OCTET_STREAM,
IMAGE_JPEG,
+1 -1
View File
@@ -22,7 +22,7 @@ import type {
ConversationsUpdatedActionType,
} from './conversations.js';
import { createLogger } from '../../logging/log.js';
import { isAudio } from '../../types/Attachment.js';
import { isAudio } from '../../util/Attachment.js';
import { getLocalAttachmentUrl } from '../../util/getLocalAttachmentUrl.js';
import { assertDev } from '../../util/assert.js';
+1 -1
View File
@@ -84,7 +84,7 @@ import {
isAnybodyInGroupCall,
MAX_CALL_PARTICIPANTS_FOR_DEFAULT_MUTE,
} from './callingHelpers.js';
import { SafetyNumberChangeSource } from '../../components/SafetyNumberChangeDialog.js';
import { SafetyNumberChangeSource } from '../../types/SafetyNumberChangeSource.js';
import {
isGroupOrAdhocCallMode,
isGroupOrAdhocCallState,
+6 -7
View File
@@ -11,13 +11,12 @@ import type {
AddLinkPreviewActionType,
RemoveLinkPreviewActionType,
} from './linkPreviews.js';
import {
type AttachmentType,
type AttachmentDraftType,
type InMemoryAttachmentDraftType,
isVideoAttachment,
isImageAttachment,
import type {
AttachmentType,
AttachmentDraftType,
InMemoryAttachmentDraftType,
} from '../../types/Attachment.js';
import { isVideoAttachment, isImageAttachment } from '../../util/Attachment.js';
import { DataReader, DataWriter } from '../../sql/Client.js';
import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions.js';
import type { DraftBodyRanges } from '../../types/BodyRange.js';
@@ -38,7 +37,7 @@ import { completeRecording, getIsRecording } from './audioRecorder.js';
import { SHOW_TOAST } from './toast.js';
import type { AnyToast } from '../../types/Toast.js';
import { ToastType } from '../../types/Toast.js';
import { SafetyNumberChangeSource } from '../../components/SafetyNumberChangeDialog.js';
import { SafetyNumberChangeSource } from '../../types/SafetyNumberChangeSource.js';
import { assignWithNoUnnecessaryAllocation } from '../../util/assignWithNoUnnecessaryAllocation.js';
import { blockSendUntilConversationsAreVerified } from '../../util/blockSendUntilConversationsAreVerified.js';
import { clearConversationDraftAttachments } from '../../util/clearConversationDraftAttachments.js';
+1 -1
View File
@@ -19,7 +19,7 @@ import { assertDev, strictAssert } from '../../util/assert.js';
import { drop } from '../../util/drop.js';
import type { DurationInSeconds } from '../../util/durations/index.js';
import * as universalExpireTimer from '../../util/universalExpireTimer.js';
import * as Attachment from '../../types/Attachment.js';
import * as Attachment from '../../util/Attachment.js';
import type { LocalizerType } from '../../types/I18N.js';
import { AttachmentDownloadUrgency } from '../../types/AttachmentDownload.js';
import { isFileDangerous } from '../../util/isFileDangerous.js';
+2 -2
View File
@@ -16,7 +16,7 @@ import type {
} from './conversations.js';
import type { MessagePropsType } from '../selectors/message.js';
import type { RecipientsByConversation } from './stories.js';
import type { SafetyNumberChangeSource } from '../../components/SafetyNumberChangeDialog.js';
import type { SafetyNumberChangeSource } from '../../types/SafetyNumberChangeSource.js';
import type { StateType as RootStateType } from '../reducer.js';
import * as SingleServePromise from '../../services/singleServePromise.js';
import * as Stickers from '../../types/Stickers.js';
@@ -39,7 +39,7 @@ import {
MESSAGE_EXPIRED,
actions as conversationsActions,
} from './conversations.js';
import { isDownloaded } from '../../types/Attachment.js';
import { isDownloaded } from '../../util/Attachment.js';
import { isPermanentlyUndownloadable } from '../../jobs/AttachmentDownloadManager.js';
import type { ButtonVariant } from '../../components/Button.js';
import type { MessageRequestState } from '../../components/conversation/MessageRequestActionsConfirmation.js';
+1 -1
View File
@@ -18,7 +18,7 @@ import { isRecord } from '../../util/isRecord.js';
import { strictAssert } from '../../util/assert.js';
import * as Registration from '../../util/registration.js';
import { missingCaseError } from '../../util/missingCaseError.js';
import { HTTPError } from '../../textsecure/Errors.js';
import { HTTPError } from '../../types/HTTPError.js';
import {
Provisioner,
EventKind as ProvisionEventKind,
+1 -1
View File
@@ -22,7 +22,7 @@ import type { ReadonlyMessageAttributesType } from '../../model-types.d.ts';
import {
getUndownloadedAttachmentSignature,
isIncremental,
} from '../../types/Attachment.js';
} from '../../util/Attachment.js';
import {
isImageTypeSupported,
isVideoTypeSupported,
+1 -1
View File
@@ -24,7 +24,7 @@ import type {
MessageExpiredActionType,
} from './conversations.js';
import type { MediaItemType } from '../../types/MediaItem.js';
import { isFile, isVisualMedia } from '../../types/Attachment.js';
import { isFile, isVisualMedia } from '../../util/Attachment.js';
import type { StateType as RootStateType } from '../reducer.js';
import { getPropsForAttachment } from '../selectors/message.js';
+2 -2
View File
@@ -31,7 +31,7 @@ import { SIGNAL_ACI } from '../../types/SignalConversation.js';
import { DataReader, DataWriter } from '../../sql/Client.js';
import { ReadStatus } from '../../messages/MessageReadStatus.js';
import { SendStatus } from '../../messages/MessageSendState.js';
import { SafetyNumberChangeSource } from '../../components/SafetyNumberChangeDialog.js';
import { SafetyNumberChangeSource } from '../../types/SafetyNumberChangeSource.js';
import {
areStoryViewReceiptsEnabled,
StoryViewDirectionType,
@@ -53,7 +53,7 @@ import {
hasFailed,
isDownloaded,
isDownloading,
} from '../../types/Attachment.js';
} from '../../util/Attachment.js';
import {
getConversationSelector,
getHideStoryConversationIds,
+2 -2
View File
@@ -25,9 +25,9 @@ import { getLocalAttachmentUrl } from '../../util/getLocalAttachmentUrl.js';
import type { MessageWithUIFieldsType } from '../ducks/conversations.js';
import type { ReadonlyMessageAttributesType } from '../../model-types.d.ts';
import { getMessageIdForLogging } from '../../util/idForLogging.js';
import * as Attachment from '../../types/Attachment.js';
import * as Attachment from '../../util/Attachment.js';
import type { ActiveAudioPlayerStateType } from '../ducks/audioPlayer.js';
import { isPlayed } from '../../types/Attachment.js';
import { isPlayed } from '../../util/Attachment.js';
import type { ServiceIdString } from '../../types/ServiceId.js';
const log = createLogger('audioPlayer');
+1 -1
View File
@@ -70,7 +70,7 @@ import {
isVoiceMessage,
isIncremental,
defaultBlurHash,
} from '../../types/Attachment.js';
} from '../../util/Attachment.js';
import type { MessageAttachmentType } from '../../types/AttachmentDownload.js';
import { type DefaultConversationColorType } from '../../types/Colors.js';
import { ReadStatus } from '../../messages/MessageReadStatus.js';
+1 -1
View File
@@ -22,7 +22,7 @@ import { useGlobalModalActions } from '../ducks/globalModals.js';
import { useLinkPreviewActions } from '../ducks/linkPreviews.js';
import { SmartCompositionTextArea } from './CompositionTextArea.js';
import { useToastActions } from '../ducks/toast.js';
import { isDownloaded } from '../../types/Attachment.js';
import { isDownloaded } from '../../util/Attachment.js';
import { getMessageById } from '../../messages/getMessageById.js';
import { strictAssert } from '../../util/assert.js';
import type {
+2 -4
View File
@@ -3,12 +3,10 @@
import React, { memo, useCallback } from 'react';
import { useSelector } from 'react-redux';
import { SafetyNumberChangeSource } from '../../types/SafetyNumberChangeSource.js';
import * as SingleServePromise from '../../services/singleServePromise.js';
import type { SafetyNumberProps } from '../../components/SafetyNumberChangeDialog.js';
import {
SafetyNumberChangeDialog,
SafetyNumberChangeSource,
} from '../../components/SafetyNumberChangeDialog.js';
import { SafetyNumberChangeDialog } from '../../components/SafetyNumberChangeDialog.js';
import { SmartSafetyNumberViewer } from './SafetyNumberViewer.js';
import { getByDistributionListConversationsStoppingSend } from '../selectors/conversations-extra.js';
import { getIntl, getTheme } from '../selectors/user.js';
+2 -2
View File
@@ -30,8 +30,8 @@ import type {
import {
hasRequiredInformationForBackup,
isVoiceMessage,
type AttachmentType,
} from '../../types/Attachment.js';
} from '../../util/Attachment.js';
import type { AttachmentType } from '../../types/Attachment.js';
import { strictAssert } from '../../util/assert.js';
import { SignalService } from '../../protobuf/index.js';
import { getRandomBytes } from '../../Crypto.js';
+1 -1
View File
@@ -5,7 +5,7 @@ import { v4 as generateGuid } from 'uuid';
import { SendStatus } from '../../messages/MessageSendState.js';
import type { ConversationModel } from '../../models/conversations.js';
import { GiftBadgeStates } from '../../components/conversation/Message.js';
import { GiftBadgeStates } from '../../types/GiftBadgeStates.js';
import { DataWriter } from '../../sql/Client.js';
import { getRandomBytes } from '../../Crypto.js';
+1 -1
View File
@@ -15,7 +15,7 @@ import {
} from '../../services/backups/util/filePointers.js';
import { IMAGE_PNG } from '../../types/MIME.js';
import * as Bytes from '../../Bytes.js';
import { type AttachmentType } from '../../types/Attachment.js';
import type { AttachmentType } from '../../types/Attachment.js';
import { MASTER_KEY, MEDIA_ROOT_KEY } from './helpers.js';
import { generateKeys } from '../../AttachmentCrypto.js';
import type { GetBackupCdnInfoType } from '../../services/backups/util/mediaId.js';
@@ -12,10 +12,8 @@ import { getDownloadsPath, getPath } from '../windows/main/attachments.js';
import { IMAGE_JPEG, LONG_MESSAGE } from '../types/MIME.js';
import type { MessageAttributesType } from '../model-types.js';
import {
type AttachmentType,
deleteAllAttachmentFilesOnDisk,
} from '../types/Attachment.js';
import type { AttachmentType } from '../types/Attachment.js';
import { deleteAllAttachmentFilesOnDisk } from '../util/Attachment.js';
import { strictAssert } from '../util/assert.js';
const { emptyDir, ensureFile } = fsExtra;
@@ -25,7 +25,7 @@ import { APPLICATION_OCTET_STREAM, VIDEO_MP4 } from '../../types/MIME.js';
import { createName, getRelativePath } from '../../util/attachmentPath.js';
import { encryptAttachmentV2, generateKeys } from '../../AttachmentCrypto.js';
import { SECOND } from '../../util/durations/index.js';
import { HTTPError } from '../../textsecure/Errors.js';
import { HTTPError } from '../../types/HTTPError.js';
const { ensureFile } = fsExtra;
+1 -1
View File
@@ -8,7 +8,7 @@ import { drop } from '../../util/drop.js';
import { ProfileService } from '../../services/profiles.js';
import { generateAci } from '../../types/ServiceId.js';
import { HTTPError } from '../../textsecure/Errors.js';
import { HTTPError } from '../../types/HTTPError.js';
describe('util/profiles', () => {
const SERVICE_ID_1 = generateAci();
@@ -9,7 +9,7 @@ import { DataWriter } from '../../sql/Client.js';
import { IMAGE_PNG } from '../../types/MIME.js';
import { downloadAttachment } from '../../util/downloadAttachment.js';
import { MediaTier } from '../../types/AttachmentDownload.js';
import { HTTPError } from '../../textsecure/Errors.js';
import { HTTPError } from '../../types/HTTPError.js';
import {
getCdnNumberForBackupTier,
type downloadAttachment as downloadAttachmentFromServer,
+1 -1
View File
@@ -13,7 +13,6 @@ import { generateAci } from '../../types/ServiceId.js';
import type { DeviceType } from '../../textsecure/Types.d.ts';
import {
ConnectTimeoutError,
HTTPError,
IncorrectSenderKeyAuthError,
MessageError,
OutgoingIdentityKeyError,
@@ -24,6 +23,7 @@ import {
UnknownRecipientError,
UnregisteredUserError,
} from '../../textsecure/Errors.js';
import { HTTPError } from '../../types/HTTPError.js';
describe('sendToGroup', () => {
const serviceIdOne = generateAci();
@@ -4,7 +4,7 @@
import { assert } from 'chai';
import { findRetryAfterTimeFromError } from '../../../jobs/helpers/findRetryAfterTimeFromError.js';
import { HTTPError } from '../../../textsecure/Errors.js';
import { HTTPError } from '../../../types/HTTPError.js';
import { MINUTE } from '../../../util/durations/index.js';
describe('findRetryAfterTimeFromError', () => {
@@ -4,10 +4,8 @@
import { assert } from 'chai';
import * as sinon from 'sinon';
import lodash from 'lodash';
import {
HTTPError,
SendMessageProtoError,
} from '../../../textsecure/Errors.js';
import { SendMessageProtoError } from '../../../textsecure/Errors.js';
import { HTTPError } from '../../../types/HTTPError.js';
import { SECOND } from '../../../util/durations/index.js';
import {
@@ -3,7 +3,7 @@
import { assert } from 'chai';
import * as sinon from 'sinon';
import { HTTPError } from '../../../textsecure/Errors.js';
import { HTTPError } from '../../../types/HTTPError.js';
import * as durations from '../../../util/durations/index.js';
import { drop } from '../../../util/drop.js';
+26 -22
View File
@@ -3,7 +3,11 @@
import { assert } from 'chai';
import * as Attachment from '../../types/Attachment.js';
import * as Attachment from '../../util/Attachment.js';
import type {
LocalAttachmentV2Type,
AttachmentType,
} from '../../types/Attachment.js';
import * as MIME from '../../types/MIME.js';
import { SignalService } from '../../protobuf/index.js';
import * as Bytes from '../../Bytes.js';
@@ -15,7 +19,7 @@ import { migrateDataToFileSystem } from '../../util/attachments/migrateDataToFil
const logger = createLogger('Attachment_test');
const FAKE_LOCAL_ATTACHMENT: Attachment.LocalAttachmentV2Type = {
const FAKE_LOCAL_ATTACHMENT: LocalAttachmentV2Type = {
version: 2,
size: 1,
plaintextHash: 'bogus',
@@ -26,7 +30,7 @@ const FAKE_LOCAL_ATTACHMENT: Attachment.LocalAttachmentV2Type = {
describe('Attachment', () => {
describe('getFileExtension', () => {
it('should return file extension from content type', () => {
const input: Attachment.AttachmentType = fakeAttachment({
const input: AttachmentType = fakeAttachment({
data: Bytes.fromString('foo'),
contentType: MIME.IMAGE_GIF,
});
@@ -34,7 +38,7 @@ describe('Attachment', () => {
});
it('should return file extension for QuickTime videos', () => {
const input: Attachment.AttachmentType = fakeAttachment({
const input: AttachmentType = fakeAttachment({
data: Bytes.fromString('foo'),
contentType: MIME.VIDEO_QUICKTIME,
});
@@ -45,7 +49,7 @@ describe('Attachment', () => {
describe('getSuggestedFilename', () => {
context('for attachment with filename', () => {
it('should return existing filename if present', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
fileName: 'funny-cat.mov',
data: Bytes.fromString('foo'),
contentType: MIME.VIDEO_QUICKTIME,
@@ -57,7 +61,7 @@ describe('Attachment', () => {
});
context('for attachment without filename', () => {
it('should generate a filename based on timestamp', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
data: Bytes.fromString('foo'),
contentType: MIME.VIDEO_QUICKTIME,
});
@@ -74,7 +78,7 @@ describe('Attachment', () => {
});
context('for attachment with index', () => {
it('should use filename if it is provided', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
fileName: 'funny-cat.mov',
data: Bytes.fromString('foo'),
contentType: MIME.VIDEO_QUICKTIME,
@@ -91,7 +95,7 @@ describe('Attachment', () => {
});
it('should use filename if it is provided and index is 1', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
fileName: 'funny-cat.mov',
data: Bytes.fromString('foo'),
contentType: MIME.VIDEO_QUICKTIME,
@@ -109,7 +113,7 @@ describe('Attachment', () => {
});
it('should use filename if it is provided and index is >1', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
fileName: 'funny-cat.mov',
data: Bytes.fromString('foo'),
contentType: MIME.VIDEO_QUICKTIME,
@@ -127,7 +131,7 @@ describe('Attachment', () => {
});
it('should use provided index if > 1 and filename not provided', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
data: Bytes.fromString('foo'),
contentType: MIME.VIDEO_QUICKTIME,
});
@@ -144,7 +148,7 @@ describe('Attachment', () => {
});
it('should not use provided index == 1 if filename not provided', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
data: Bytes.fromString('foo'),
contentType: MIME.VIDEO_QUICKTIME,
});
@@ -164,7 +168,7 @@ describe('Attachment', () => {
describe('isVisualMedia', () => {
it('should return true for images', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
fileName: 'meme.gif',
data: Bytes.fromString('gif'),
contentType: MIME.IMAGE_GIF,
@@ -173,7 +177,7 @@ describe('Attachment', () => {
});
it('should return true for videos', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
fileName: 'meme.mp4',
data: Bytes.fromString('mp4'),
contentType: MIME.VIDEO_MP4,
@@ -182,7 +186,7 @@ describe('Attachment', () => {
});
it('should return false for voice message attachment', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
fileName: 'Voice Message.aac',
flags: SignalService.AttachmentPointer.Flags.VOICE_MESSAGE,
data: Bytes.fromString('voice message'),
@@ -192,7 +196,7 @@ describe('Attachment', () => {
});
it('should return false for other attachments', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
fileName: 'foo.json',
data: Bytes.fromString('{"foo": "bar"}'),
contentType: MIME.APPLICATION_JSON,
@@ -203,7 +207,7 @@ describe('Attachment', () => {
describe('isFile', () => {
it('should return true for JSON', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
fileName: 'foo.json',
data: Bytes.fromString('{"foo": "bar"}'),
contentType: MIME.APPLICATION_JSON,
@@ -212,7 +216,7 @@ describe('Attachment', () => {
});
it('should return false for images', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
fileName: 'meme.gif',
data: Bytes.fromString('gif'),
contentType: MIME.IMAGE_GIF,
@@ -221,7 +225,7 @@ describe('Attachment', () => {
});
it('should return false for videos', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
fileName: 'meme.mp4',
data: Bytes.fromString('mp4'),
contentType: MIME.VIDEO_MP4,
@@ -230,7 +234,7 @@ describe('Attachment', () => {
});
it('should return false for voice message attachment', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
fileName: 'Voice Message.aac',
flags: SignalService.AttachmentPointer.Flags.VOICE_MESSAGE,
data: Bytes.fromString('voice message'),
@@ -242,7 +246,7 @@ describe('Attachment', () => {
describe('isVoiceMessage', () => {
it('should return true for voice message attachment', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
fileName: 'Voice Message.aac',
flags: SignalService.AttachmentPointer.Flags.VOICE_MESSAGE,
data: Bytes.fromString('voice message'),
@@ -252,7 +256,7 @@ describe('Attachment', () => {
});
it('should return true for legacy Android voice message attachment', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
data: Bytes.fromString('voice message'),
contentType: MIME.AUDIO_MP3,
});
@@ -260,7 +264,7 @@ describe('Attachment', () => {
});
it('should return false for other attachments', () => {
const attachment: Attachment.AttachmentType = fakeAttachment({
const attachment: AttachmentType = fakeAttachment({
fileName: 'foo.gif',
data: Bytes.fromString('foo'),
contentType: MIME.IMAGE_GIF,
+2 -41
View File
@@ -3,59 +3,20 @@
/* eslint-disable max-classes-per-file */
import type { Response } from 'node-fetch';
import type { LibSignalErrorBase } from '@signalapp/libsignal-client';
import { parseRetryAfter } from '../util/parseRetryAfter.js';
import type { ServiceIdString } from '../types/ServiceId.js';
import type { HTTPError } from '../types/HTTPError.js';
import type { HeaderListType } from '../types/WebAPI.d.ts';
import type { CallbackResultType } from './Types.d.ts';
import type { HeaderListType } from './WebAPI.js';
function appendStack(newError: Error, originalError: Error) {
// eslint-disable-next-line no-param-reassign
newError.stack += `\nOriginal stack:\n${originalError.stack}`;
}
export class HTTPError extends Error {
public override readonly name = 'HTTPError';
public readonly code: number;
public readonly responseHeaders: HeaderListType;
public readonly response: unknown;
static fromResponse(response: Response): HTTPError {
return new HTTPError(response.statusText, {
code: response.status,
headers: Object.fromEntries(response.headers),
response,
});
}
constructor(
message: string,
options: {
code: number;
headers: HeaderListType;
response?: unknown;
stack?: string;
cause?: unknown;
}
) {
super(`${message}; code: ${options.code}`, { cause: options.cause });
const { code: providedCode, headers, response, stack } = options;
this.code = providedCode > 999 || providedCode < 100 ? -1 : providedCode;
this.responseHeaders = headers;
this.stack += `\nOriginal stack:\n${stack}`;
this.response = response;
}
}
export class ReplayableError extends Error {
functionCode?: number;
+1 -1
View File
@@ -31,11 +31,11 @@ import {
SendMessageNetworkError,
SendMessageChallengeError,
UnregisteredUserError,
HTTPError,
} from './Errors.js';
import type { CallbackResultType, CustomError } from './Types.d.ts';
import { Address } from '../types/Address.js';
import * as Errors from '../types/errors.js';
import { HTTPError } from '../types/HTTPError.js';
import { QualifiedAddress } from '../types/QualifiedAddress.js';
import type { ServiceIdString } from '../types/ServiceId.js';
import { Sessions, IdentityKeys } from '../LibSignalStores.js';
+1 -1
View File
@@ -61,10 +61,10 @@ import { getRandomBytes } from '../Crypto.js';
import {
MessageError,
SendMessageProtoError,
HTTPError,
NoSenderKeyError,
} from './Errors.js';
import { BodyRange } from '../types/BodyRange.js';
import { HTTPError } from '../types/HTTPError.js';
import type { RawBodyRange } from '../types/BodyRange.js';
import type { StoryContextType } from '../types/Util.js';
import type {
+2 -1
View File
@@ -28,6 +28,7 @@ import { drop } from '../util/drop.js';
import type { ProxyAgent } from '../util/createProxyAgent.js';
import { createProxyAgent } from '../util/createProxyAgent.js';
import { type SocketInfo, SocketStatus } from '../types/SocketStatus.js';
import { HTTPError } from '../types/HTTPError.js';
import * as Errors from '../types/errors.js';
import * as Bytes from '../Bytes.js';
import { createLogger } from '../logging/log.js';
@@ -42,7 +43,7 @@ import WebSocketResource, {
connectUnauthenticatedLibsignal,
ServerRequestType,
} from './WebsocketResources.js';
import { ConnectTimeoutError, HTTPError } from './Errors.js';
import { ConnectTimeoutError } from './Errors.js';
import type { IRequestHandler, WebAPICredentials } from './Types.d.ts';
import { connect as connectWebSocket } from './WebSocket.js';
import { type ServerAlert } from '../util/handleServerAlerts.js';
+1 -1
View File
@@ -11,7 +11,7 @@ import type {
PniString,
} from '../types/ServiceId.js';
import type { TextAttachmentType } from '../types/Attachment.js';
import type { GiftBadgeStates } from '../components/conversation/Message.js';
import type { GiftBadgeStates } from '../types/GiftBadgeStates.js';
import type { MIMEType } from '../types/MIME.js';
import type { DurationInSeconds } from '../util/durations/index.js';
import type { AnyPaymentEvent } from '../types/Payment.js';
+1 -1
View File
@@ -7,7 +7,7 @@ import * as Registration from '../util/registration.js';
import { ServiceIdKind } from '../types/ServiceId.js';
import { createLogger } from '../logging/log.js';
import * as Errors from '../types/errors.js';
import { HTTPError } from './Errors.js';
import { HTTPError } from '../types/HTTPError.js';
const log = createLogger('UpdateKeysListener');
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { HTTPError } from './Errors.js';
import type { HTTPError } from '../types/HTTPError.js';
export async function handleStatusCode(status: number): Promise<void> {
if (status === 499) {
+2 -2
View File
@@ -36,6 +36,7 @@ import { createProxyAgent } from '../util/createProxyAgent.js';
import type { ProxyAgent } from '../util/createProxyAgent.js';
import type { FetchFunctionType } from '../util/uploads/tusProtocol.js';
import { VerificationTransport } from '../types/VerificationTransport.js';
import type { HeaderListType } from '../types/WebAPI.d.ts';
import { ZERO_ACCESS_KEY } from '../types/SealedSender.js';
import { toLogFormat } from '../types/errors.js';
import { isPackIdValid, redactPackId } from '../util/Stickers.js';
@@ -51,6 +52,7 @@ import {
untaggedPniSchema,
} from '../types/ServiceId.js';
import type { BackupPresentationHeadersType } from '../types/backups.js';
import { HTTPError } from '../types/HTTPError.js';
import * as Bytes from '../Bytes.js';
import { getRandomBytes, randomInt } from '../Crypto.js';
import * as linkPreviewFetch from '../linkPreviews/linkPreviewFetch.js';
@@ -66,7 +68,6 @@ import { CDSI } from './cds/CDSI.js';
import { SignalService as Proto } from '../protobuf/index.js';
import { isEnabled as isRemoteConfigEnabled } from '../RemoteConfig.js';
import { HTTPError } from './Errors.js';
import type MessageSender from './SendMessage.js';
import type {
WebAPICredentials,
@@ -172,7 +173,6 @@ function getContentType(response: Response) {
}
type FetchHeaderListType = { [name: string]: string };
export type HeaderListType = { [name: string]: string | ReadonlyArray<string> };
type HTTPCodeType = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD';
type RedactUrl = (url: string) => string;
+2 -1
View File
@@ -12,9 +12,10 @@ import { getUserAgent } from '../util/getUserAgent.js';
import * as durations from '../util/durations/index.js';
import type { ProxyAgent } from '../util/createProxyAgent.js';
import { createHTTPSAgent } from '../util/createHTTPSAgent.js';
import { HTTPError } from '../types/HTTPError.js';
import { createLogger } from '../logging/log.js';
import * as Timers from '../Timers.js';
import { ConnectTimeoutError, HTTPError } from './Errors.js';
import { ConnectTimeoutError } from './Errors.js';
import { handleStatusCode, translateError } from './Utils.js';
const { client: WebSocketClient } = ws;
+2 -2
View File
@@ -12,12 +12,12 @@ import fsExtra from 'fs-extra';
import { createLogger } from '../logging/log.js';
import * as Errors from '../types/errors.js';
import { strictAssert } from '../util/assert.js';
import { hasRequiredInformationForBackup } from '../util/Attachment.js';
import {
AttachmentSizeError,
type AttachmentType,
AttachmentVariant,
AttachmentPermanentlyUndownloadableError,
hasRequiredInformationForBackup,
type BackupableAttachmentType,
} from '../types/Attachment.js';
import * as Bytes from '../Bytes.js';
@@ -49,9 +49,9 @@ import { MAX_BACKUP_THUMBNAIL_SIZE } from '../types/VisualAttachment.js';
import { missingCaseError } from '../util/missingCaseError.js';
import { IV_LENGTH, MAC_LENGTH } from '../types/Crypto.js';
import { BackupCredentialType } from '../types/backups.js';
import { HTTPError } from '../types/HTTPError.js';
import { getValue } from '../RemoteConfig.js';
import { parseIntOrThrow } from '../util/parseIntOrThrow.js';
import { HTTPError } from './Errors.js';
const { ensureFile } = fsExtra;
+2 -5
View File
@@ -11,11 +11,7 @@ import {
PublicKey,
} from '@signalapp/libsignal-client';
import {
OutgoingIdentityKeyError,
UnregisteredUserError,
HTTPError,
} from './Errors.js';
import { OutgoingIdentityKeyError, UnregisteredUserError } from './Errors.js';
import { Sessions, IdentityKeys } from '../LibSignalStores.js';
import { Address } from '../types/Address.js';
import { QualifiedAddress } from '../types/QualifiedAddress.js';
@@ -24,6 +20,7 @@ import type { ServerKeysType, WebAPIType } from './WebAPI.js';
import { createLogger } from '../logging/log.js';
import { isRecord } from '../util/isRecord.js';
import type { GroupSendToken } from '../types/GroupSendEndorsements.js';
import { HTTPError } from '../types/HTTPError.js';
import { onFailedToSendWithEndorsements } from '../util/groupSendEndorsements.js';
const log = createLogger('getKeysForServiceId');
+2 -2
View File
@@ -29,7 +29,7 @@ import type {
ProcessedGiftBadge,
ProcessedStoryContext,
} from './Types.d.ts';
import { GiftBadgeStates } from '../components/conversation/Message.js';
import { GiftBadgeStates } from '../types/GiftBadgeStates.js';
import { APPLICATION_OCTET_STREAM, stringToMIMEType } from '../types/MIME.js';
import { SECOND, DurationInSeconds } from '../util/durations/index.js';
import type { AnyPaymentEvent } from '../types/Payment.js';
@@ -37,7 +37,7 @@ import { PaymentEventKind } from '../types/Payment.js';
import { filterAndClean } from '../types/BodyRange.js';
import { bytesToUuid } from '../util/uuidToBytes.js';
import { createName } from '../util/attachmentPath.js';
import { partitionBodyAndNormalAttachments } from '../types/Attachment.js';
import { partitionBodyAndNormalAttachments } from '../util/Attachment.js';
import { isNotNil } from '../util/isNotNil.js';
const { isNumber } = lodash;
+21 -1211
View File
File diff suppressed because it is too large Load Diff
+2 -5
View File
@@ -3,11 +3,8 @@
import lodash from 'lodash';
import type { ReadonlyMessageAttributesType } from '../model-types.js';
import {
isVoiceMessage,
type AttachmentForUIType,
isDownloaded,
} from './Attachment.js';
import type { AttachmentForUIType } from './Attachment.js';
import { isVoiceMessage, isDownloaded } from '../util/Attachment.js';
import type { HydratedBodyRangesType } from './BodyRange.js';
import type { LinkPreviewForUIType } from './message/LinkPreviews.js';
+9
View File
@@ -0,0 +1,9 @@
// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
export enum GiftBadgeStates {
Unopened = 'Unopened',
Opened = 'Opened',
Redeemed = 'Redeemed',
Failed = 'Failed',
}
+45
View File
@@ -0,0 +1,45 @@
// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { Response } from 'node-fetch';
import type { HeaderListType } from './WebAPI.d.ts';
export class HTTPError extends Error {
public override readonly name = 'HTTPError';
public readonly code: number;
public readonly responseHeaders: HeaderListType;
public readonly response: unknown;
static fromResponse(response: Response): HTTPError {
return new HTTPError(response.statusText, {
code: response.status,
headers: Object.fromEntries(response.headers),
response,
});
}
constructor(
message: string,
options: {
code: number;
headers: HeaderListType;
response?: unknown;
stack?: string;
cause?: unknown;
}
) {
super(`${message}; code: ${options.code}`, { cause: options.cause });
const { code: providedCode, headers, response, stack } = options;
this.code = providedCode > 999 || providedCode < 100 ? -1 : providedCode;
this.responseHeaders = headers;
this.stack += `\nOriginal stack:\n${stack}`;
this.response = response;
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ import {
replaceUnicodeOrderOverrides,
replaceUnicodeV2,
shouldGenerateThumbnailForAttachmentType,
} from './Attachment.js';
} from '../util/Attachment.js';
import type { MakeVideoScreenshotResultType } from './VisualAttachment.js';
import * as Errors from './errors.js';
import * as SchemaVersion from './SchemaVersion.js';
+9
View File
@@ -0,0 +1,9 @@
// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
export enum SafetyNumberChangeSource {
InitiateCall = 'InitiateCall',
JoinCall = 'JoinCall',
MessageSend = 'MessageSend',
Story = 'Story',
}
+4
View File
@@ -0,0 +1,4 @@
// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
export type HeaderListType = { [name: string]: string | ReadonlyArray<string> };
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2018 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { HTTPError } from '../textsecure/Errors.js';
import { HTTPError } from './HTTPError.js';
export function toLogFormat(error: unknown): string {
let result = '';
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -11,7 +11,7 @@ import type {
AttachmentType,
UploadedAttachmentType,
} from '../types/Attachment.js';
import { canBeTranscoded } from '../types/Attachment.js';
import { canBeTranscoded } from './Attachment.js';
import * as Errors from '../types/errors.js';
import * as Bytes from '../Bytes.js';

Some files were not shown because too many files have changed in this diff Show More