Introduce Service Id Types
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
414c0a58d3
commit
366b875fd2
269 changed files with 5832 additions and 5550 deletions
|
@ -8,7 +8,7 @@ import type {
|
|||
MessageAttributesType,
|
||||
QuotedMessageType,
|
||||
} from '../model-types.d';
|
||||
import type { UUIDStringType } from '../types/UUID';
|
||||
import type { ServiceIdString } from '../types/ServiceId';
|
||||
import { PaymentEventKind } from '../types/Payment';
|
||||
import type { AnyPaymentEvent } from '../types/Payment';
|
||||
import type { LocalizerType } from '../types/Util';
|
||||
|
@ -193,7 +193,7 @@ export function getSourceDevice(
|
|||
|
||||
export function getSourceUuid(
|
||||
message: Pick<MessageAttributesType, 'type' | 'sourceUuid'>
|
||||
): UUIDStringType | undefined {
|
||||
): ServiceIdString | undefined {
|
||||
if (isIncoming(message) || isStory(message)) {
|
||||
return message.sourceUuid;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ export function getSourceUuid(
|
|||
);
|
||||
}
|
||||
|
||||
return window.textsecure.storage.user.getUuid()?.toString();
|
||||
return window.textsecure.storage.user.getAci();
|
||||
}
|
||||
|
||||
export const isCustomError = (e: unknown): e is CustomError =>
|
||||
|
|
|
@ -5,7 +5,7 @@ import { get, isEmpty } from 'lodash';
|
|||
import { getOwn } from '../util/getOwn';
|
||||
import { map, concat, repeat, zipObject } from '../util/iterables';
|
||||
import { isOutgoing } from '../state/selectors/message';
|
||||
import type { CustomError, MessageAttributesType } from '../model-types.d';
|
||||
import type { MessageAttributesType } from '../model-types.d';
|
||||
import type { SendState, SendStateByConversationId } from './MessageSendState';
|
||||
import {
|
||||
SendActionType,
|
||||
|
@ -13,6 +13,11 @@ import {
|
|||
SendStatus,
|
||||
} from './MessageSendState';
|
||||
|
||||
type LegacyCustomError = Error & {
|
||||
identifier?: string;
|
||||
number?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* This converts legacy message fields, such as `sent_to`, into the new
|
||||
* `sendStateByConversationId` format. These legacy fields aren't typed to prevent their
|
||||
|
@ -130,7 +135,7 @@ export function migrateLegacySendAttributes(
|
|||
}
|
||||
|
||||
function getConversationIdsFromErrors(
|
||||
errors: undefined | ReadonlyArray<CustomError>,
|
||||
errors: undefined | ReadonlyArray<LegacyCustomError>,
|
||||
getConversation: GetConversationType
|
||||
): Array<string> {
|
||||
const result: Array<string> = [];
|
||||
|
|
|
@ -7,7 +7,7 @@ import pMap from 'p-map';
|
|||
import { CURRENT_SCHEMA_VERSION } from '../types/Message2';
|
||||
import { isNotNil } from '../util/isNotNil';
|
||||
import type { MessageAttributesType } from '../model-types.d';
|
||||
import type { UUIDStringType } from '../types/UUID';
|
||||
import type { AciString } from '../types/ServiceId';
|
||||
import * as Errors from '../types/errors';
|
||||
|
||||
const MAX_CONCURRENCY = 5;
|
||||
|
@ -33,7 +33,7 @@ export async function migrateMessageData({
|
|||
) => Promise<Array<MessageAttributesType>>;
|
||||
saveMessages: (
|
||||
data: ReadonlyArray<MessageAttributesType>,
|
||||
options: { ourUuid: UUIDStringType }
|
||||
options: { ourAci: AciString }
|
||||
) => Promise<void>;
|
||||
maxVersion?: number;
|
||||
}>): Promise<
|
||||
|
@ -103,7 +103,7 @@ export async function migrateMessageData({
|
|||
|
||||
const saveStartTime = Date.now();
|
||||
|
||||
const ourUuid = window.textsecure.storage.user.getCheckedUuid().toString();
|
||||
const ourAci = window.textsecure.storage.user.getCheckedAci();
|
||||
await saveMessages(
|
||||
[
|
||||
...upgradedMessages,
|
||||
|
@ -114,7 +114,7 @@ export async function migrateMessageData({
|
|||
schemaMigrationAttempts: (message.schemaMigrationAttempts ?? 0) + 1,
|
||||
})),
|
||||
],
|
||||
{ ourUuid }
|
||||
{ ourAci }
|
||||
);
|
||||
const saveDuration = Date.now() - saveStartTime;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue