Remove Signal.Util
This commit is contained in:
parent
3a069323a4
commit
76b9d07acf
25 changed files with 132 additions and 202 deletions
|
@ -20,7 +20,7 @@ function deleteIndexedDB() {
|
||||||
|
|
||||||
/* Delete the database before running any tests */
|
/* Delete the database before running any tests */
|
||||||
before(async () => {
|
before(async () => {
|
||||||
window.Signal.Util.MessageController.install();
|
window.testUtilities.installMessageController();
|
||||||
|
|
||||||
await deleteIndexedDB();
|
await deleteIndexedDB();
|
||||||
try {
|
try {
|
||||||
|
@ -34,7 +34,7 @@ before(async () => {
|
||||||
err && err.stack ? err.stack : err
|
err && err.stack ? err.stack : err
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await window.Signal.Util.initializeMessageCounter();
|
await window.testUtilities.initializeMessageCounter();
|
||||||
await window.Signal.Data.removeAll();
|
await window.Signal.Data.removeAll();
|
||||||
await window.storage.fetch();
|
await window.storage.fetch();
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { render } from 'react-dom';
|
||||||
import { batch as batchDispatch } from 'react-redux';
|
import { batch as batchDispatch } from 'react-redux';
|
||||||
import PQueue from 'p-queue';
|
import PQueue from 'p-queue';
|
||||||
|
|
||||||
|
import * as Registration from './util/registration';
|
||||||
import MessageReceiver from './textsecure/MessageReceiver';
|
import MessageReceiver from './textsecure/MessageReceiver';
|
||||||
import type {
|
import type {
|
||||||
SessionResetsType,
|
SessionResetsType,
|
||||||
|
@ -175,6 +176,15 @@ import { showConfirmationDialog } from './util/showConfirmationDialog';
|
||||||
import { onCallEventSync } from './util/onCallEventSync';
|
import { onCallEventSync } from './util/onCallEventSync';
|
||||||
import { sleeper } from './util/sleeper';
|
import { sleeper } from './util/sleeper';
|
||||||
import { MINUTE } from './util/durations';
|
import { MINUTE } from './util/durations';
|
||||||
|
import {
|
||||||
|
flushMessageCounter,
|
||||||
|
incrementMessageCounter,
|
||||||
|
initializeMessageCounter,
|
||||||
|
} from './util/incrementMessageCounter';
|
||||||
|
import { RetryPlaceholders } from './util/retryPlaceholders';
|
||||||
|
import { setBatchingStrategy } from './util/messageBatcher';
|
||||||
|
import { parseRemoteClientExpiration } from './util/parseRemoteClientExpiration';
|
||||||
|
import { makeLookup } from './util/makeLookup';
|
||||||
|
|
||||||
export function isOverHourIntoPast(timestamp: number): boolean {
|
export function isOverHourIntoPast(timestamp: number): boolean {
|
||||||
const HOUR = 1000 * 60 * 60;
|
const HOUR = 1000 * 60 * 60;
|
||||||
|
@ -218,15 +228,12 @@ export async function startApp(): Promise<void> {
|
||||||
storage: window.storage,
|
storage: window.storage,
|
||||||
});
|
});
|
||||||
|
|
||||||
await window.Signal.Util.initializeMessageCounter();
|
await initializeMessageCounter();
|
||||||
|
|
||||||
let initialBadgesState: BadgesStateType = { byId: {} };
|
let initialBadgesState: BadgesStateType = { byId: {} };
|
||||||
async function loadInitialBadgesState(): Promise<void> {
|
async function loadInitialBadgesState(): Promise<void> {
|
||||||
initialBadgesState = {
|
initialBadgesState = {
|
||||||
byId: window.Signal.Util.makeLookup(
|
byId: makeLookup(await window.Signal.Data.getAllBadges(), 'id'),
|
||||||
await window.Signal.Data.getAllBadges(),
|
|
||||||
'id'
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,8 +494,7 @@ export async function startApp(): Promise<void> {
|
||||||
timeout: durations.MINUTE * 30,
|
timeout: durations.MINUTE * 30,
|
||||||
});
|
});
|
||||||
window.Whisper.deliveryReceiptQueue.pause();
|
window.Whisper.deliveryReceiptQueue.pause();
|
||||||
window.Whisper.deliveryReceiptBatcher =
|
window.Whisper.deliveryReceiptBatcher = createBatcher<Receipt>({
|
||||||
window.Signal.Util.createBatcher<Receipt>({
|
|
||||||
name: 'Whisper.deliveryReceiptBatcher',
|
name: 'Whisper.deliveryReceiptBatcher',
|
||||||
wait: 500,
|
wait: 500,
|
||||||
maxSize: 100,
|
maxSize: 100,
|
||||||
|
@ -603,7 +609,7 @@ export async function startApp(): Promise<void> {
|
||||||
accountManager.addEventListener('registration', () => {
|
accountManager.addEventListener('registration', () => {
|
||||||
window.Whisper.events.trigger('userChanged', false);
|
window.Whisper.events.trigger('userChanged', false);
|
||||||
|
|
||||||
drop(window.Signal.Util.Registration.markDone());
|
drop(Registration.markDone());
|
||||||
log.info('dispatching registration event');
|
log.info('dispatching registration event');
|
||||||
window.Whisper.events.trigger('registration_done');
|
window.Whisper.events.trigger('registration_done');
|
||||||
});
|
});
|
||||||
|
@ -710,7 +716,7 @@ export async function startApp(): Promise<void> {
|
||||||
shutdown: async () => {
|
shutdown: async () => {
|
||||||
log.info('background/shutdown');
|
log.info('background/shutdown');
|
||||||
|
|
||||||
window.Signal.Util.flushMessageCounter();
|
flushMessageCounter();
|
||||||
|
|
||||||
// Stop background processing
|
// Stop background processing
|
||||||
void AttachmentDownloads.stop();
|
void AttachmentDownloads.stop();
|
||||||
|
@ -1007,7 +1013,7 @@ export async function startApp(): Promise<void> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const retryPlaceholders = new window.Signal.Util.RetryPlaceholders({
|
const retryPlaceholders = new RetryPlaceholders({
|
||||||
retryReceiptLifespan,
|
retryReceiptLifespan,
|
||||||
});
|
});
|
||||||
window.Signal.Services.retryPlaceholders = retryPlaceholders;
|
window.Signal.Services.retryPlaceholders = retryPlaceholders;
|
||||||
|
@ -1052,8 +1058,7 @@ export async function startApp(): Promise<void> {
|
||||||
window.ConversationController.get(conversationId);
|
window.ConversationController.get(conversationId);
|
||||||
if (conversation) {
|
if (conversation) {
|
||||||
const receivedAt = Date.now();
|
const receivedAt = Date.now();
|
||||||
const receivedAtCounter =
|
const receivedAtCounter = incrementMessageCounter();
|
||||||
window.Signal.Util.incrementMessageCounter();
|
|
||||||
drop(
|
drop(
|
||||||
conversation.queueJob('addDeliveryIssue', () =>
|
conversation.queueJob('addDeliveryIssue', () =>
|
||||||
conversation.addDeliveryIssue({
|
conversation.addDeliveryIssue({
|
||||||
|
@ -1865,7 +1870,7 @@ export async function startApp(): Promise<void> {
|
||||||
);
|
);
|
||||||
|
|
||||||
window.Whisper.events.on('mightBeUnlinked', () => {
|
window.Whisper.events.on('mightBeUnlinked', () => {
|
||||||
if (window.Signal.Util.Registration.everDone()) {
|
if (Registration.everDone()) {
|
||||||
throttledEnqueueReconnectToWebSocket();
|
throttledEnqueueReconnectToWebSocket();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -2003,7 +2008,7 @@ export async function startApp(): Promise<void> {
|
||||||
window.ConversationController.getOurConversation()
|
window.ConversationController.getOurConversation()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isCoreDataValid && window.Signal.Util.Registration.everDone()) {
|
if (isCoreDataValid && Registration.everDone()) {
|
||||||
void connect();
|
void connect();
|
||||||
window.reduxActions.app.openInbox();
|
window.reduxActions.app.openInbox();
|
||||||
} else {
|
} else {
|
||||||
|
@ -2058,8 +2063,9 @@ export async function startApp(): Promise<void> {
|
||||||
window.Signal.RemoteConfig.onChange(
|
window.Signal.RemoteConfig.onChange(
|
||||||
'desktop.clientExpiration',
|
'desktop.clientExpiration',
|
||||||
({ value }) => {
|
({ value }) => {
|
||||||
const remoteBuildExpirationTimestamp =
|
const remoteBuildExpirationTimestamp = parseRemoteClientExpiration(
|
||||||
window.Signal.Util.parseRemoteClientExpiration(value as string);
|
value as string
|
||||||
|
);
|
||||||
if (remoteBuildExpirationTimestamp) {
|
if (remoteBuildExpirationTimestamp) {
|
||||||
drop(
|
drop(
|
||||||
window.storage.put(
|
window.storage.put(
|
||||||
|
@ -2218,7 +2224,7 @@ export async function startApp(): Promise<void> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!window.Signal.Util.Registration.everDone()) {
|
if (!Registration.everDone()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2240,8 +2246,7 @@ export async function startApp(): Promise<void> {
|
||||||
'desktop.clientExpiration'
|
'desktop.clientExpiration'
|
||||||
);
|
);
|
||||||
if (expiration) {
|
if (expiration) {
|
||||||
const remoteBuildExpirationTimestamp =
|
const remoteBuildExpirationTimestamp = parseRemoteClientExpiration(
|
||||||
window.Signal.Util.parseRemoteClientExpiration(
|
|
||||||
expiration as string
|
expiration as string
|
||||||
);
|
);
|
||||||
if (remoteBuildExpirationTimestamp) {
|
if (remoteBuildExpirationTimestamp) {
|
||||||
|
@ -2601,7 +2606,7 @@ export async function startApp(): Promise<void> {
|
||||||
log.info('App loaded - messages:', processedCount);
|
log.info('App loaded - messages:', processedCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.Signal.Util.setBatchingStrategy(false);
|
setBatchingStrategy(false);
|
||||||
StartupQueue.flush();
|
StartupQueue.flush();
|
||||||
await flushAttachmentDownloadQueue();
|
await flushAttachmentDownloadQueue();
|
||||||
|
|
||||||
|
@ -3594,7 +3599,7 @@ export async function startApp(): Promise<void> {
|
||||||
|
|
||||||
void onEmpty();
|
void onEmpty();
|
||||||
|
|
||||||
void window.Signal.Util.Registration.remove();
|
void Registration.remove();
|
||||||
|
|
||||||
const NUMBER_ID_KEY = 'number_id';
|
const NUMBER_ID_KEY = 'number_id';
|
||||||
const UUID_ID_KEY = 'uuid_id';
|
const UUID_ID_KEY = 'uuid_id';
|
||||||
|
@ -3660,7 +3665,7 @@ export async function startApp(): Promise<void> {
|
||||||
Errors.toLogFormat(eraseError)
|
Errors.toLogFormat(eraseError)
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
await window.Signal.Util.Registration.markEverDone();
|
await Registration.markEverDone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ import {
|
||||||
} from './jobs/conversationJobQueue';
|
} from './jobs/conversationJobQueue';
|
||||||
import { ReadStatus } from './messages/MessageReadStatus';
|
import { ReadStatus } from './messages/MessageReadStatus';
|
||||||
import { SeenStatus } from './MessageSeenStatus';
|
import { SeenStatus } from './MessageSeenStatus';
|
||||||
|
import { incrementMessageCounter } from './util/incrementMessageCounter';
|
||||||
|
|
||||||
type AccessRequiredEnum = Proto.AccessControl.AccessRequired;
|
type AccessRequiredEnum = Proto.AccessControl.AccessRequired;
|
||||||
|
|
||||||
|
@ -1969,7 +1970,7 @@ export async function createGroupV2(
|
||||||
sourceUuid: ourACI,
|
sourceUuid: ourACI,
|
||||||
conversationId: conversation.id,
|
conversationId: conversation.id,
|
||||||
readStatus: ReadStatus.Read,
|
readStatus: ReadStatus.Read,
|
||||||
received_at: window.Signal.Util.incrementMessageCounter(),
|
received_at: incrementMessageCounter(),
|
||||||
received_at_ms: timestamp,
|
received_at_ms: timestamp,
|
||||||
timestamp,
|
timestamp,
|
||||||
seenStatus: SeenStatus.Seen,
|
seenStatus: SeenStatus.Seen,
|
||||||
|
@ -3034,8 +3035,7 @@ async function updateGroup(
|
||||||
// Ensure that all generated messages are ordered properly.
|
// Ensure that all generated messages are ordered properly.
|
||||||
// Before the provided timestamp so update messages appear before the
|
// Before the provided timestamp so update messages appear before the
|
||||||
// initiating message, or after now().
|
// initiating message, or after now().
|
||||||
const finalReceivedAt =
|
const finalReceivedAt = receivedAt || incrementMessageCounter();
|
||||||
receivedAt || window.Signal.Util.incrementMessageCounter();
|
|
||||||
const initialSentAt = sentAt || Date.now();
|
const initialSentAt = sentAt || Date.now();
|
||||||
|
|
||||||
// GroupV1 -> GroupV2 migration changes the groupId, and we need to update our id-based
|
// GroupV1 -> GroupV2 migration changes the groupId, and we need to update our id-based
|
||||||
|
|
|
@ -35,6 +35,7 @@ import { SendMessageProtoError } from '../../textsecure/Errors';
|
||||||
import { strictAssert } from '../../util/assert';
|
import { strictAssert } from '../../util/assert';
|
||||||
import type { LoggerType } from '../../types/Logging';
|
import type { LoggerType } from '../../types/Logging';
|
||||||
import { isStory } from '../../messages/helpers';
|
import { isStory } from '../../messages/helpers';
|
||||||
|
import { sendToGroup } from '../../util/sendToGroup';
|
||||||
|
|
||||||
export async function sendDeleteForEveryone(
|
export async function sendDeleteForEveryone(
|
||||||
conversation: ConversationModel,
|
conversation: ConversationModel,
|
||||||
|
@ -225,7 +226,7 @@ export async function sendDeleteForEveryone(
|
||||||
logId,
|
logId,
|
||||||
messageIds,
|
messageIds,
|
||||||
send: async () =>
|
send: async () =>
|
||||||
window.Signal.Util.sendToGroup({
|
sendToGroup({
|
||||||
abortSignal,
|
abortSignal,
|
||||||
contentHint,
|
contentHint,
|
||||||
groupSendOptions: {
|
groupSendOptions: {
|
||||||
|
|
|
@ -20,6 +20,7 @@ import type {
|
||||||
ConversationQueueJobBundle,
|
ConversationQueueJobBundle,
|
||||||
} from '../conversationJobQueue';
|
} from '../conversationJobQueue';
|
||||||
import { getUntrustedConversationUuids } from './getUntrustedConversationUuids';
|
import { getUntrustedConversationUuids } from './getUntrustedConversationUuids';
|
||||||
|
import { sendToGroup } from '../../util/sendToGroup';
|
||||||
|
|
||||||
// Note: because we don't have a recipient map, if some sends fail, we will resend this
|
// Note: because we don't have a recipient map, if some sends fail, we will resend this
|
||||||
// message to folks that got it on the first go-round. This is okay, because receivers
|
// message to folks that got it on the first go-round. This is okay, because receivers
|
||||||
|
@ -118,7 +119,7 @@ export async function sendGroupUpdate(
|
||||||
logId,
|
logId,
|
||||||
messageIds: [],
|
messageIds: [],
|
||||||
send: async () =>
|
send: async () =>
|
||||||
window.Signal.Util.sendToGroup({
|
sendToGroup({
|
||||||
abortSignal,
|
abortSignal,
|
||||||
groupSendOptions: {
|
groupSendOptions: {
|
||||||
groupV2,
|
groupV2,
|
||||||
|
|
|
@ -32,6 +32,7 @@ import {
|
||||||
UnregisteredUserError,
|
UnregisteredUserError,
|
||||||
} from '../../textsecure/Errors';
|
} from '../../textsecure/Errors';
|
||||||
import { shouldSendToConversation } from './shouldSendToConversation';
|
import { shouldSendToConversation } from './shouldSendToConversation';
|
||||||
|
import { sendToGroup } from '../../util/sendToGroup';
|
||||||
|
|
||||||
export function canAllErrorsBeIgnored(
|
export function canAllErrorsBeIgnored(
|
||||||
conversation: ConversationAttributesType,
|
conversation: ConversationAttributesType,
|
||||||
|
@ -147,7 +148,7 @@ export async function sendProfileKey(
|
||||||
groupV2Info.revision = revision;
|
groupV2Info.revision = revision;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendPromise = window.Signal.Util.sendToGroup({
|
sendPromise = sendToGroup({
|
||||||
contentHint,
|
contentHint,
|
||||||
groupSendOptions: {
|
groupSendOptions: {
|
||||||
flags: Proto.DataMessage.Flags.PROFILE_KEY_UPDATE,
|
flags: Proto.DataMessage.Flags.PROFILE_KEY_UPDATE,
|
||||||
|
|
|
@ -37,6 +37,7 @@ import type {
|
||||||
import { isConversationAccepted } from '../../util/isConversationAccepted';
|
import { isConversationAccepted } from '../../util/isConversationAccepted';
|
||||||
import { isConversationUnregistered } from '../../util/isConversationUnregistered';
|
import { isConversationUnregistered } from '../../util/isConversationUnregistered';
|
||||||
import type { LoggerType } from '../../types/Logging';
|
import type { LoggerType } from '../../types/Logging';
|
||||||
|
import { sendToGroup } from '../../util/sendToGroup';
|
||||||
|
|
||||||
export async function sendReaction(
|
export async function sendReaction(
|
||||||
conversation: ConversationModel,
|
conversation: ConversationModel,
|
||||||
|
@ -250,7 +251,7 @@ export async function sendReaction(
|
||||||
groupV2Info.revision = revision;
|
groupV2Info.revision = revision;
|
||||||
}
|
}
|
||||||
|
|
||||||
return window.Signal.Util.sendToGroup({
|
return sendToGroup({
|
||||||
abortSignal,
|
abortSignal,
|
||||||
contentHint: ContentHint.RESENDABLE,
|
contentHint: ContentHint.RESENDABLE,
|
||||||
groupSendOptions: {
|
groupSendOptions: {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import type { DeleteSentProtoRecipientOptionsType } from '../sql/Interface';
|
||||||
import dataInterface from '../sql/Client';
|
import dataInterface from '../sql/Client';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import { getSourceUuid } from '../messages/helpers';
|
import { getSourceUuid } from '../messages/helpers';
|
||||||
|
import { queueUpdateMessage } from '../util/messageBatcher';
|
||||||
|
|
||||||
const { deleteSentProtoRecipient } = dataInterface;
|
const { deleteSentProtoRecipient } = dataInterface;
|
||||||
|
|
||||||
|
@ -232,7 +233,7 @@ export class MessageReceipts extends Collection<MessageReceiptModel> {
|
||||||
[sourceConversationId]: newSendState,
|
[sourceConversationId]: newSendState,
|
||||||
});
|
});
|
||||||
|
|
||||||
window.Signal.Util.queueUpdateMessage(message.attributes);
|
queueUpdateMessage(message.attributes);
|
||||||
|
|
||||||
// notify frontend listeners
|
// notify frontend listeners
|
||||||
const conversation = window.ConversationController.get(
|
const conversation = window.ConversationController.get(
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { notificationService } from '../services/notifications';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import * as Errors from '../types/errors';
|
import * as Errors from '../types/errors';
|
||||||
import { StartupQueue } from '../util/StartupQueue';
|
import { StartupQueue } from '../util/StartupQueue';
|
||||||
|
import { queueUpdateMessage } from '../util/messageBatcher';
|
||||||
|
|
||||||
export type ReadSyncAttributesType = {
|
export type ReadSyncAttributesType = {
|
||||||
senderId: string;
|
senderId: string;
|
||||||
|
@ -146,7 +147,7 @@ export class ReadSyncs extends Collection {
|
||||||
message.set({ expirationStartTimestamp });
|
message.set({ expirationStartTimestamp });
|
||||||
}
|
}
|
||||||
|
|
||||||
window.Signal.Util.queueUpdateMessage(message.attributes);
|
queueUpdateMessage(message.attributes);
|
||||||
|
|
||||||
this.remove(sync);
|
this.remove(sync);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { notificationService } from '../services/notifications';
|
||||||
import { queueAttachmentDownloads } from '../util/queueAttachmentDownloads';
|
import { queueAttachmentDownloads } from '../util/queueAttachmentDownloads';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import { GiftBadgeStates } from '../components/conversation/Message';
|
import { GiftBadgeStates } from '../components/conversation/Message';
|
||||||
|
import { queueUpdateMessage } from '../util/messageBatcher';
|
||||||
|
|
||||||
export type ViewSyncAttributesType = {
|
export type ViewSyncAttributesType = {
|
||||||
senderId: string;
|
senderId: string;
|
||||||
|
@ -122,7 +123,7 @@ export class ViewSyncs extends Collection {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (didChangeMessage) {
|
if (didChangeMessage) {
|
||||||
window.Signal.Util.queueUpdateMessage(message.attributes);
|
queueUpdateMessage(message.attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.remove(sync);
|
this.remove(sync);
|
||||||
|
|
|
@ -140,6 +140,7 @@ import * as log from '../logging/log';
|
||||||
import * as Errors from '../types/errors';
|
import * as Errors from '../types/errors';
|
||||||
import { isMessageUnread } from '../util/isMessageUnread';
|
import { isMessageUnread } from '../util/isMessageUnread';
|
||||||
import type { SenderKeyTargetType } from '../util/sendToGroup';
|
import type { SenderKeyTargetType } from '../util/sendToGroup';
|
||||||
|
import { sendContentMessageToGroup } from '../util/sendToGroup';
|
||||||
import { singleProtoJobQueue } from '../jobs/singleProtoJobQueue';
|
import { singleProtoJobQueue } from '../jobs/singleProtoJobQueue';
|
||||||
import { TimelineMessageLoadingState } from '../util/timelineUtil';
|
import { TimelineMessageLoadingState } from '../util/timelineUtil';
|
||||||
import { SeenStatus } from '../MessageSeenStatus';
|
import { SeenStatus } from '../MessageSeenStatus';
|
||||||
|
@ -156,6 +157,8 @@ import { ReceiptType } from '../types/Receipt';
|
||||||
import { getQuoteAttachment } from '../util/makeQuote';
|
import { getQuoteAttachment } from '../util/makeQuote';
|
||||||
import { stripNewlinesForLeftPane } from '../util/stripNewlinesForLeftPane';
|
import { stripNewlinesForLeftPane } from '../util/stripNewlinesForLeftPane';
|
||||||
import { findAndFormatContact } from '../util/findAndFormatContact';
|
import { findAndFormatContact } from '../util/findAndFormatContact';
|
||||||
|
import { deriveProfileKeyVersion } from '../util/zkgroup';
|
||||||
|
import { incrementMessageCounter } from '../util/incrementMessageCounter';
|
||||||
|
|
||||||
const EMPTY_ARRAY: Readonly<[]> = [];
|
const EMPTY_ARRAY: Readonly<[]> = [];
|
||||||
const EMPTY_GROUP_COLLISIONS: GroupNameCollisionsWithIdsByTitle = {};
|
const EMPTY_GROUP_COLLISIONS: GroupNameCollisionsWithIdsByTitle = {};
|
||||||
|
@ -163,7 +166,6 @@ const EMPTY_GROUP_COLLISIONS: GroupNameCollisionsWithIdsByTitle = {};
|
||||||
/* eslint-disable more/no-then */
|
/* eslint-disable more/no-then */
|
||||||
window.Whisper = window.Whisper || {};
|
window.Whisper = window.Whisper || {};
|
||||||
|
|
||||||
const { Util } = window.Signal;
|
|
||||||
const { Message } = window.Signal.Types;
|
const { Message } = window.Signal.Types;
|
||||||
const {
|
const {
|
||||||
deleteAttachmentData,
|
deleteAttachmentData,
|
||||||
|
@ -1432,7 +1434,7 @@ export class ConversationModel extends window.Backbone
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
await handleMessageSend(
|
await handleMessageSend(
|
||||||
window.Signal.Util.sendContentMessageToGroup({
|
sendContentMessageToGroup({
|
||||||
contentHint: ContentHint.IMPLICIT,
|
contentHint: ContentHint.IMPLICIT,
|
||||||
contentMessage,
|
contentMessage,
|
||||||
messageId: undefined,
|
messageId: undefined,
|
||||||
|
@ -3237,7 +3239,7 @@ export class ConversationModel extends window.Backbone
|
||||||
type: 'keychange',
|
type: 'keychange',
|
||||||
sent_at: timestamp,
|
sent_at: timestamp,
|
||||||
timestamp,
|
timestamp,
|
||||||
received_at: window.Signal.Util.incrementMessageCounter(),
|
received_at: incrementMessageCounter(),
|
||||||
received_at_ms: timestamp,
|
received_at_ms: timestamp,
|
||||||
key_changed: keyChangedIdString,
|
key_changed: keyChangedIdString,
|
||||||
readStatus: ReadStatus.Read,
|
readStatus: ReadStatus.Read,
|
||||||
|
@ -3311,7 +3313,7 @@ export class ConversationModel extends window.Backbone
|
||||||
type: 'conversation-merge',
|
type: 'conversation-merge',
|
||||||
sent_at: timestamp,
|
sent_at: timestamp,
|
||||||
timestamp,
|
timestamp,
|
||||||
received_at: window.Signal.Util.incrementMessageCounter(),
|
received_at: incrementMessageCounter(),
|
||||||
received_at_ms: timestamp,
|
received_at_ms: timestamp,
|
||||||
conversationMerge: {
|
conversationMerge: {
|
||||||
renderInfo,
|
renderInfo,
|
||||||
|
@ -3363,7 +3365,7 @@ export class ConversationModel extends window.Backbone
|
||||||
local: Boolean(options.local),
|
local: Boolean(options.local),
|
||||||
readStatus: shouldBeUnseen ? ReadStatus.Unread : ReadStatus.Read,
|
readStatus: shouldBeUnseen ? ReadStatus.Unread : ReadStatus.Read,
|
||||||
received_at_ms: timestamp,
|
received_at_ms: timestamp,
|
||||||
received_at: window.Signal.Util.incrementMessageCounter(),
|
received_at: incrementMessageCounter(),
|
||||||
seenStatus: shouldBeUnseen ? SeenStatus.Unseen : SeenStatus.Unseen,
|
seenStatus: shouldBeUnseen ? SeenStatus.Unseen : SeenStatus.Unseen,
|
||||||
sent_at: lastMessage,
|
sent_at: lastMessage,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
@ -3455,8 +3457,7 @@ export class ConversationModel extends window.Backbone
|
||||||
type: 'call-history',
|
type: 'call-history',
|
||||||
sent_at: timestamp,
|
sent_at: timestamp,
|
||||||
timestamp,
|
timestamp,
|
||||||
received_at:
|
received_at: receivedAtCounter || incrementMessageCounter(),
|
||||||
receivedAtCounter || window.Signal.Util.incrementMessageCounter(),
|
|
||||||
received_at_ms: timestamp,
|
received_at_ms: timestamp,
|
||||||
readStatus: unread ? ReadStatus.Unread : ReadStatus.Read,
|
readStatus: unread ? ReadStatus.Unread : ReadStatus.Read,
|
||||||
seenStatus: unread ? SeenStatus.Unseen : SeenStatus.NotApplicable,
|
seenStatus: unread ? SeenStatus.Unseen : SeenStatus.NotApplicable,
|
||||||
|
@ -3554,7 +3555,7 @@ export class ConversationModel extends window.Backbone
|
||||||
conversationId: this.id,
|
conversationId: this.id,
|
||||||
type: 'profile-change',
|
type: 'profile-change',
|
||||||
sent_at: now,
|
sent_at: now,
|
||||||
received_at: window.Signal.Util.incrementMessageCounter(),
|
received_at: incrementMessageCounter(),
|
||||||
received_at_ms: now,
|
received_at_ms: now,
|
||||||
readStatus: ReadStatus.Read,
|
readStatus: ReadStatus.Read,
|
||||||
seenStatus: SeenStatus.NotApplicable,
|
seenStatus: SeenStatus.NotApplicable,
|
||||||
|
@ -3597,7 +3598,7 @@ export class ConversationModel extends window.Backbone
|
||||||
conversationId: this.id,
|
conversationId: this.id,
|
||||||
type,
|
type,
|
||||||
sent_at: now,
|
sent_at: now,
|
||||||
received_at: window.Signal.Util.incrementMessageCounter(),
|
received_at: incrementMessageCounter(),
|
||||||
received_at_ms: now,
|
received_at_ms: now,
|
||||||
readStatus: ReadStatus.Read,
|
readStatus: ReadStatus.Read,
|
||||||
seenStatus: SeenStatus.NotApplicable,
|
seenStatus: SeenStatus.NotApplicable,
|
||||||
|
@ -4265,7 +4266,7 @@ export class ConversationModel extends window.Backbone
|
||||||
preview,
|
preview,
|
||||||
attachments: attachmentsToSend,
|
attachments: attachmentsToSend,
|
||||||
sent_at: now,
|
sent_at: now,
|
||||||
received_at: window.Signal.Util.incrementMessageCounter(),
|
received_at: incrementMessageCounter(),
|
||||||
received_at_ms: now,
|
received_at_ms: now,
|
||||||
expirationStartTimestamp,
|
expirationStartTimestamp,
|
||||||
expireTimer,
|
expireTimer,
|
||||||
|
@ -4879,7 +4880,7 @@ export class ConversationModel extends window.Backbone
|
||||||
flags: Proto.DataMessage.Flags.EXPIRATION_TIMER_UPDATE,
|
flags: Proto.DataMessage.Flags.EXPIRATION_TIMER_UPDATE,
|
||||||
readStatus: shouldBeRead ? ReadStatus.Read : ReadStatus.Unread,
|
readStatus: shouldBeRead ? ReadStatus.Read : ReadStatus.Unread,
|
||||||
received_at_ms: receivedAtMS,
|
received_at_ms: receivedAtMS,
|
||||||
received_at: receivedAt ?? window.Signal.Util.incrementMessageCounter(),
|
received_at: receivedAt ?? incrementMessageCounter(),
|
||||||
seenStatus: shouldBeRead ? SeenStatus.Seen : SeenStatus.Unseen,
|
seenStatus: shouldBeRead ? SeenStatus.Seen : SeenStatus.Unseen,
|
||||||
sent_at: sentAt,
|
sent_at: sentAt,
|
||||||
type: 'timer-notification',
|
type: 'timer-notification',
|
||||||
|
@ -4937,7 +4938,7 @@ export class ConversationModel extends window.Backbone
|
||||||
group_update: { left: 'You' },
|
group_update: { left: 'You' },
|
||||||
readStatus: ReadStatus.Read,
|
readStatus: ReadStatus.Read,
|
||||||
received_at_ms: now,
|
received_at_ms: now,
|
||||||
received_at: window.Signal.Util.incrementMessageCounter(),
|
received_at: incrementMessageCounter(),
|
||||||
seenStatus: SeenStatus.NotApplicable,
|
seenStatus: SeenStatus.NotApplicable,
|
||||||
sent_at: now,
|
sent_at: now,
|
||||||
type: 'group',
|
type: 'group',
|
||||||
|
@ -5216,10 +5217,7 @@ export class ConversationModel extends window.Backbone
|
||||||
return lastProfile.profileKeyVersion;
|
return lastProfile.profileKeyVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
const profileKeyVersion = Util.zkgroup.deriveProfileKeyVersion(
|
const profileKeyVersion = deriveProfileKeyVersion(profileKey, uuid);
|
||||||
profileKey,
|
|
||||||
uuid
|
|
||||||
);
|
|
||||||
if (!profileKeyVersion) {
|
if (!profileKeyVersion) {
|
||||||
log.warn(
|
log.warn(
|
||||||
'deriveProfileKeyVersion: Failed to derive profile key version, ' +
|
'deriveProfileKeyVersion: Failed to derive profile key version, ' +
|
||||||
|
|
|
@ -31,6 +31,7 @@ import {
|
||||||
repeat,
|
repeat,
|
||||||
zipObject,
|
zipObject,
|
||||||
} from '../util/iterables';
|
} from '../util/iterables';
|
||||||
|
import * as GoogleChrome from '../util/GoogleChrome';
|
||||||
import type { DeleteModel } from '../messageModifiers/Deletes';
|
import type { DeleteModel } from '../messageModifiers/Deletes';
|
||||||
import type { SentEventData } from '../textsecure/messageReceiverEvents';
|
import type { SentEventData } from '../textsecure/messageReceiverEvents';
|
||||||
import { isNotNil } from '../util/isNotNil';
|
import { isNotNil } from '../util/isNotNil';
|
||||||
|
@ -188,6 +189,12 @@ import { shouldReplyNotifyUser } from '../util/shouldReplyNotifyUser';
|
||||||
import { isConversationAccepted } from '../util/isConversationAccepted';
|
import { isConversationAccepted } from '../util/isConversationAccepted';
|
||||||
import type { RawBodyRange } from '../types/BodyRange';
|
import type { RawBodyRange } from '../types/BodyRange';
|
||||||
import { BodyRange, applyRangesForText } from '../types/BodyRange';
|
import { BodyRange, applyRangesForText } from '../types/BodyRange';
|
||||||
|
import { deleteForEveryone } from '../util/deleteForEveryone';
|
||||||
|
import { getStringForProfileChange } from '../util/getStringForProfileChange';
|
||||||
|
import {
|
||||||
|
queueUpdateMessage,
|
||||||
|
saveNewMessageBatcher,
|
||||||
|
} from '../util/messageBatcher';
|
||||||
|
|
||||||
/* eslint-disable more/no-then */
|
/* eslint-disable more/no-then */
|
||||||
|
|
||||||
|
@ -195,7 +202,6 @@ window.Whisper = window.Whisper || {};
|
||||||
|
|
||||||
const { Message: TypedMessage } = window.Signal.Types;
|
const { Message: TypedMessage } = window.Signal.Types;
|
||||||
const { upgradeMessageSchema } = window.Signal.Migrations;
|
const { upgradeMessageSchema } = window.Signal.Migrations;
|
||||||
const { GoogleChrome } = window.Signal.Util;
|
|
||||||
const { getMessageBySender } = window.Signal.Data;
|
const { getMessageBySender } = window.Signal.Data;
|
||||||
|
|
||||||
export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
|
@ -486,11 +492,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
text: window.Signal.Util.getStringForProfileChange(
|
text: getStringForProfileChange(change, changedContact, window.i18n),
|
||||||
change,
|
|
||||||
changedContact,
|
|
||||||
window.i18n
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -959,12 +961,8 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
|
|
||||||
const firstAttachment = attachments[0];
|
const firstAttachment = attachments[0];
|
||||||
if (
|
if (
|
||||||
!window.Signal.Util.GoogleChrome.isImageTypeSupported(
|
!GoogleChrome.isImageTypeSupported(firstAttachment.contentType) &&
|
||||||
firstAttachment.contentType
|
!GoogleChrome.isVideoTypeSupported(firstAttachment.contentType)
|
||||||
) &&
|
|
||||||
!window.Signal.Util.GoogleChrome.isVideoTypeSupported(
|
|
||||||
firstAttachment.contentType
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1113,7 +1111,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
referencedMessageNotFound: false,
|
referencedMessageNotFound: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
window.Signal.Util.queueUpdateMessage(this.attributes);
|
queueUpdateMessage(this.attributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3032,7 +3030,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
conversation: ConversationModel,
|
conversation: ConversationModel,
|
||||||
confirm: () => void
|
confirm: () => void
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await window.Signal.Util.saveNewMessageBatcher.add(this.attributes);
|
await saveNewMessageBatcher.add(this.attributes);
|
||||||
|
|
||||||
log.info('Message saved', this.get('sent_at'));
|
log.info('Message saved', this.get('sent_at'));
|
||||||
|
|
||||||
|
@ -3279,7 +3277,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
const deletes = Deletes.getSingleton().forMessage(message);
|
const deletes = Deletes.getSingleton().forMessage(message);
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
deletes.map(async del => {
|
deletes.map(async del => {
|
||||||
await window.Signal.Util.deleteForEveryone(message, del, false);
|
await deleteForEveryone(message, del, false);
|
||||||
changed = true;
|
changed = true;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -105,6 +105,7 @@ import {
|
||||||
} from './notifications';
|
} from './notifications';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import { assertDev } from '../util/assert';
|
import { assertDev } from '../util/assert';
|
||||||
|
import { sendContentMessageToGroup, sendToGroup } from '../util/sendToGroup';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
processGroupCallRingCancellation,
|
processGroupCallRingCancellation,
|
||||||
|
@ -1056,7 +1057,7 @@ export class CallingClass {
|
||||||
messageIds: [],
|
messageIds: [],
|
||||||
send: () =>
|
send: () =>
|
||||||
conversation.queueJob('sendGroupCallUpdateMessage', () =>
|
conversation.queueJob('sendGroupCallUpdateMessage', () =>
|
||||||
window.Signal.Util.sendToGroup({
|
sendToGroup({
|
||||||
contentHint: ContentHint.DEFAULT,
|
contentHint: ContentHint.DEFAULT,
|
||||||
groupSendOptions: {
|
groupSendOptions: {
|
||||||
groupCallUpdate: { eraId },
|
groupCallUpdate: { eraId },
|
||||||
|
@ -1696,7 +1697,7 @@ export class CallingClass {
|
||||||
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
|
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
|
||||||
await conversation.queueJob('handleSendCallMessageToGroup', async () =>
|
await conversation.queueJob('handleSendCallMessageToGroup', async () =>
|
||||||
handleMessageSend(
|
handleMessageSend(
|
||||||
window.Signal.Util.sendContentMessageToGroup({
|
sendContentMessageToGroup({
|
||||||
contentHint: ContentHint.DEFAULT,
|
contentHint: ContentHint.DEFAULT,
|
||||||
contentMessage,
|
contentMessage,
|
||||||
isPartialSend: false,
|
isPartialSend: false,
|
||||||
|
|
43
ts/signal.ts
43
ts/signal.ts
|
@ -10,9 +10,6 @@ import Data from './sql/Client';
|
||||||
import * as Groups from './groups';
|
import * as Groups from './groups';
|
||||||
import * as OS from './OS';
|
import * as OS from './OS';
|
||||||
import * as RemoteConfig from './RemoteConfig';
|
import * as RemoteConfig from './RemoteConfig';
|
||||||
import * as GoogleChrome from './util/GoogleChrome';
|
|
||||||
import * as Registration from './util/registration';
|
|
||||||
import * as zkgroup from './util/zkgroup';
|
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import { ConfirmationDialog } from './components/ConfirmationDialog';
|
import { ConfirmationDialog } from './components/ConfirmationDialog';
|
||||||
|
@ -49,25 +46,6 @@ import type { EmbeddedContactType } from './types/EmbeddedContact';
|
||||||
import type { ContactWithHydratedAvatar } from './textsecure/SendMessage';
|
import type { ContactWithHydratedAvatar } from './textsecure/SendMessage';
|
||||||
import type { LinkPreviewType } from './types/message/LinkPreviews';
|
import type { LinkPreviewType } from './types/message/LinkPreviews';
|
||||||
import type { StickerType, StickerWithHydratedData } from './types/Stickers';
|
import type { StickerType, StickerWithHydratedData } from './types/Stickers';
|
||||||
import { MessageController } from './util/MessageController';
|
|
||||||
import {
|
|
||||||
flushMessageCounter,
|
|
||||||
incrementMessageCounter,
|
|
||||||
initializeMessageCounter,
|
|
||||||
} from './util/incrementMessageCounter';
|
|
||||||
import { sleep } from './util/sleep';
|
|
||||||
import {
|
|
||||||
queueUpdateMessage,
|
|
||||||
saveNewMessageBatcher,
|
|
||||||
setBatchingStrategy,
|
|
||||||
} from './util/messageBatcher';
|
|
||||||
import { sendContentMessageToGroup, sendToGroup } from './util/sendToGroup';
|
|
||||||
import { makeLookup } from './util/makeLookup';
|
|
||||||
import { getStringForProfileChange } from './util/getStringForProfileChange';
|
|
||||||
import { deleteForEveryone } from './util/deleteForEveryone';
|
|
||||||
import { RetryPlaceholders } from './util/retryPlaceholders';
|
|
||||||
import { parseRemoteClientExpiration } from './util/parseRemoteClientExpiration';
|
|
||||||
import { createBatcher } from './util/batcher';
|
|
||||||
|
|
||||||
type MigrationsModuleType = {
|
type MigrationsModuleType = {
|
||||||
attachmentsPath: string;
|
attachmentsPath: string;
|
||||||
|
@ -422,26 +400,5 @@ export const setup = (options: {
|
||||||
Services,
|
Services,
|
||||||
State,
|
State,
|
||||||
Types,
|
Types,
|
||||||
Util: {
|
|
||||||
createBatcher,
|
|
||||||
deleteForEveryone,
|
|
||||||
flushMessageCounter,
|
|
||||||
getStringForProfileChange,
|
|
||||||
GoogleChrome,
|
|
||||||
incrementMessageCounter,
|
|
||||||
initializeMessageCounter,
|
|
||||||
makeLookup,
|
|
||||||
MessageController,
|
|
||||||
parseRemoteClientExpiration,
|
|
||||||
queueUpdateMessage,
|
|
||||||
Registration,
|
|
||||||
RetryPlaceholders,
|
|
||||||
saveNewMessageBatcher,
|
|
||||||
sendContentMessageToGroup,
|
|
||||||
sendToGroup,
|
|
||||||
setBatchingStrategy,
|
|
||||||
sleep,
|
|
||||||
zkgroup,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -70,6 +70,7 @@ import { parseSqliteError, SqliteErrorKind } from './errors';
|
||||||
import { MINUTE } from '../util/durations';
|
import { MINUTE } from '../util/durations';
|
||||||
import { getMessageIdForLogging } from '../util/idForLogging';
|
import { getMessageIdForLogging } from '../util/idForLogging';
|
||||||
import type { MessageAttributesType } from '../model-types';
|
import type { MessageAttributesType } from '../model-types';
|
||||||
|
import { incrementMessageCounter } from '../util/incrementMessageCounter';
|
||||||
|
|
||||||
const getRealPath = pify(fs.realpath);
|
const getRealPath = pify(fs.realpath);
|
||||||
|
|
||||||
|
@ -253,7 +254,7 @@ export function _cleanMessageData(data: MessageType): MessageType {
|
||||||
// Ensure that all messages have the received_at set properly
|
// Ensure that all messages have the received_at set properly
|
||||||
if (!data.received_at) {
|
if (!data.received_at) {
|
||||||
assertDev(false, 'received_at was not set on the message');
|
assertDev(false, 'received_at was not set on the message');
|
||||||
result.received_at = window.Signal.Util.incrementMessageCounter();
|
result.received_at = incrementMessageCounter();
|
||||||
}
|
}
|
||||||
if (data.attachments) {
|
if (data.attachments) {
|
||||||
const logId = getMessageIdForLogging(data);
|
const logId = getMessageIdForLogging(data);
|
||||||
|
|
|
@ -38,6 +38,7 @@ import { getEmojiReducerState as emojis } from '../util/loadRecentEmojis';
|
||||||
import { getInitialState as stickers } from '../types/Stickers';
|
import { getInitialState as stickers } from '../types/Stickers';
|
||||||
import { getThemeType } from '../util/getThemeType';
|
import { getThemeType } from '../util/getThemeType';
|
||||||
import { getInteractionMode } from '../services/InteractionMode';
|
import { getInteractionMode } from '../services/InteractionMode';
|
||||||
|
import { makeLookup } from '../util/makeLookup';
|
||||||
|
|
||||||
export function getInitialState({
|
export function getInitialState({
|
||||||
badges,
|
badges,
|
||||||
|
@ -91,26 +92,14 @@ export function getInitialState({
|
||||||
composer: composer(),
|
composer: composer(),
|
||||||
conversations: {
|
conversations: {
|
||||||
...conversations(),
|
...conversations(),
|
||||||
conversationLookup: window.Signal.Util.makeLookup(
|
conversationLookup: makeLookup(formattedConversations, 'id'),
|
||||||
formattedConversations,
|
conversationsByE164: makeLookup(formattedConversations, 'e164'),
|
||||||
'id'
|
|
||||||
),
|
|
||||||
conversationsByE164: window.Signal.Util.makeLookup(
|
|
||||||
formattedConversations,
|
|
||||||
'e164'
|
|
||||||
),
|
|
||||||
conversationsByUuid: {
|
conversationsByUuid: {
|
||||||
...window.Signal.Util.makeLookup(formattedConversations, 'uuid'),
|
...makeLookup(formattedConversations, 'uuid'),
|
||||||
...window.Signal.Util.makeLookup(formattedConversations, 'pni'),
|
...makeLookup(formattedConversations, 'pni'),
|
||||||
},
|
},
|
||||||
conversationsByGroupId: window.Signal.Util.makeLookup(
|
conversationsByGroupId: makeLookup(formattedConversations, 'groupId'),
|
||||||
formattedConversations,
|
conversationsByUsername: makeLookup(formattedConversations, 'username'),
|
||||||
'groupId'
|
|
||||||
),
|
|
||||||
conversationsByUsername: window.Signal.Util.makeLookup(
|
|
||||||
formattedConversations,
|
|
||||||
'username'
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
crashReports: crashReports(),
|
crashReports: crashReports(),
|
||||||
emojis: emojis(),
|
emojis: emojis(),
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { LoadingState } from '../../util/loadable';
|
||||||
import { assertDev } from '../../util/assert';
|
import { assertDev } from '../../util/assert';
|
||||||
import { explodePromise } from '../../util/explodePromise';
|
import { explodePromise } from '../../util/explodePromise';
|
||||||
import { missingCaseError } from '../../util/missingCaseError';
|
import { missingCaseError } from '../../util/missingCaseError';
|
||||||
|
import * as Registration from '../../util/registration';
|
||||||
import {
|
import {
|
||||||
InstallScreen,
|
InstallScreen,
|
||||||
InstallScreenStep,
|
InstallScreenStep,
|
||||||
|
@ -186,7 +187,7 @@ export function SmartInstallScreen(): ReactElement {
|
||||||
// Delete all data from the database unless we're in the middle of a re-link.
|
// Delete all data from the database unless we're in the middle of a re-link.
|
||||||
// Without this, the app restarts at certain times and can cause weird things to
|
// Without this, the app restarts at certain times and can cause weird things to
|
||||||
// happen, like data from a previous light import showing up after a new install.
|
// happen, like data from a previous light import showing up after a new install.
|
||||||
const shouldRetainData = window.Signal.Util.Registration.everDone();
|
const shouldRetainData = Registration.everDone();
|
||||||
if (!shouldRetainData) {
|
if (!shouldRetainData) {
|
||||||
try {
|
try {
|
||||||
await window.textsecure.storage.protocol.removeAllData();
|
await window.textsecure.storage.protocol.removeAllData();
|
||||||
|
|
|
@ -124,6 +124,7 @@ import { isNotNil } from '../util/isNotNil';
|
||||||
import { chunk } from '../util/iterables';
|
import { chunk } from '../util/iterables';
|
||||||
import { isOlderThan } from '../util/timestamp';
|
import { isOlderThan } from '../util/timestamp';
|
||||||
import { inspectUnknownFieldTags } from '../util/inspectProtobufs';
|
import { inspectUnknownFieldTags } from '../util/inspectProtobufs';
|
||||||
|
import { incrementMessageCounter } from '../util/incrementMessageCounter';
|
||||||
|
|
||||||
const GROUPV1_ID_LENGTH = 16;
|
const GROUPV1_ID_LENGTH = 16;
|
||||||
const GROUPV2_ID_LENGTH = 32;
|
const GROUPV2_ID_LENGTH = 32;
|
||||||
|
@ -378,7 +379,7 @@ export default class MessageReceiver
|
||||||
// Make non-private envelope IDs dashless so they don't get redacted
|
// Make non-private envelope IDs dashless so they don't get redacted
|
||||||
// from logs
|
// from logs
|
||||||
id: getGuid().replace(/-/g, ''),
|
id: getGuid().replace(/-/g, ''),
|
||||||
receivedAtCounter: window.Signal.Util.incrementMessageCounter(),
|
receivedAtCounter: incrementMessageCounter(),
|
||||||
receivedAtDate: Date.now(),
|
receivedAtDate: Date.now(),
|
||||||
// Calculate the message age (time on server).
|
// Calculate the message age (time on server).
|
||||||
messageAgeSec: this.calculateMessageAge(headers, serverTimestamp),
|
messageAgeSec: this.calculateMessageAge(headers, serverTimestamp),
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
import * as durations from '../util/durations';
|
import * as durations from '../util/durations';
|
||||||
import { clearTimeoutIfNecessary } from '../util/clearTimeoutIfNecessary';
|
import { clearTimeoutIfNecessary } from '../util/clearTimeoutIfNecessary';
|
||||||
|
import * as Registration from '../util/registration';
|
||||||
import { UUIDKind } from '../types/UUID';
|
import { UUIDKind } from '../types/UUID';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ export class RotateSignedPreKeyListener {
|
||||||
listener.setTimeoutForNextRun();
|
listener.setTimeoutForNextRun();
|
||||||
|
|
||||||
events.on('timetravel', () => {
|
events.on('timetravel', () => {
|
||||||
if (window.Signal.Util.Registration.isDone()) {
|
if (Registration.isDone()) {
|
||||||
listener.setTimeoutForNextRun();
|
listener.setTimeoutForNextRun();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -33,6 +33,7 @@ import { strictAssert, assertDev } from './assert';
|
||||||
import * as durations from './durations';
|
import * as durations from './durations';
|
||||||
import type { DurationInSeconds } from './durations';
|
import type { DurationInSeconds } from './durations';
|
||||||
import { isPhoneNumberSharingEnabled } from './isPhoneNumberSharingEnabled';
|
import { isPhoneNumberSharingEnabled } from './isPhoneNumberSharingEnabled';
|
||||||
|
import * as Registration from './registration';
|
||||||
import {
|
import {
|
||||||
parseE164FromSignalDotMeHash,
|
parseE164FromSignalDotMeHash,
|
||||||
parseUsernameFromSignalDotMeHash,
|
parseUsernameFromSignalDotMeHash,
|
||||||
|
@ -453,7 +454,7 @@ export function createIPCEvents(
|
||||||
},
|
},
|
||||||
authorizeArtCreator: (data: AuthorizeArtCreatorDataType) => {
|
authorizeArtCreator: (data: AuthorizeArtCreatorDataType) => {
|
||||||
// We can get these events even if the user has never linked this instance.
|
// We can get these events even if the user has never linked this instance.
|
||||||
if (!window.Signal.Util.Registration.everDone()) {
|
if (!Registration.everDone()) {
|
||||||
log.warn('authorizeArtCreator: Not registered, returning early');
|
log.warn('authorizeArtCreator: Not registered, returning early');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -481,7 +482,7 @@ export function createIPCEvents(
|
||||||
|
|
||||||
showStickerPack: (packId, key) => {
|
showStickerPack: (packId, key) => {
|
||||||
// We can get these events even if the user has never linked this instance.
|
// We can get these events even if the user has never linked this instance.
|
||||||
if (!window.Signal.Util.Registration.everDone()) {
|
if (!Registration.everDone()) {
|
||||||
log.warn('showStickerPack: Not registered, returning early');
|
log.warn('showStickerPack: Not registered, returning early');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -489,7 +490,7 @@ export function createIPCEvents(
|
||||||
},
|
},
|
||||||
showGroupViaLink: async hash => {
|
showGroupViaLink: async hash => {
|
||||||
// We can get these events even if the user has never linked this instance.
|
// We can get these events even if the user has never linked this instance.
|
||||||
if (!window.Signal.Util.Registration.everDone()) {
|
if (!Registration.everDone()) {
|
||||||
log.warn('showGroupViaLink: Not registered, returning early');
|
log.warn('showGroupViaLink: Not registered, returning early');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -507,7 +508,7 @@ export function createIPCEvents(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async showConversationViaSignalDotMe(hash: string) {
|
async showConversationViaSignalDotMe(hash: string) {
|
||||||
if (!window.Signal.Util.Registration.everDone()) {
|
if (!Registration.everDone()) {
|
||||||
log.info(
|
log.info(
|
||||||
'showConversationViaSignalDotMe: Not registered, returning early'
|
'showConversationViaSignalDotMe: Not registered, returning early'
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,6 +13,7 @@ import { findAndDeleteOnboardingStoryIfExists } from './findAndDeleteOnboardingS
|
||||||
import { runStorageServiceSyncJob } from '../services/storage';
|
import { runStorageServiceSyncJob } from '../services/storage';
|
||||||
import { saveNewMessageBatcher } from './messageBatcher';
|
import { saveNewMessageBatcher } from './messageBatcher';
|
||||||
import { strictAssert } from './assert';
|
import { strictAssert } from './assert';
|
||||||
|
import { incrementMessageCounter } from './incrementMessageCounter';
|
||||||
|
|
||||||
// * Check if we've viewed onboarding story. Short circuit.
|
// * Check if we've viewed onboarding story. Short circuit.
|
||||||
// * Run storage service sync (just in case) and check again.
|
// * Run storage service sync (just in case) and check again.
|
||||||
|
@ -106,7 +107,7 @@ async function continueDownloadingOnboardingStory(): Promise<void> {
|
||||||
conversationId: signalConversation.id,
|
conversationId: signalConversation.id,
|
||||||
id: UUID.generate().toString(),
|
id: UUID.generate().toString(),
|
||||||
readStatus: ReadStatus.Unread,
|
readStatus: ReadStatus.Unread,
|
||||||
received_at: window.Signal.Util.incrementMessageCounter(),
|
received_at: incrementMessageCounter(),
|
||||||
received_at_ms: timestamp,
|
received_at_ms: timestamp,
|
||||||
seenStatus: SeenStatus.Unseen,
|
seenStatus: SeenStatus.Unseen,
|
||||||
sent_at: timestamp,
|
sent_at: timestamp,
|
||||||
|
|
|
@ -39,6 +39,7 @@ import type MessageSender from '../textsecure/SendMessage';
|
||||||
import type { StoryDistributionListDataType } from '../state/ducks/storyDistributionLists';
|
import type { StoryDistributionListDataType } from '../state/ducks/storyDistributionLists';
|
||||||
import { drop } from './drop';
|
import { drop } from './drop';
|
||||||
import { conversationJobQueue } from '../jobs/conversationJobQueue';
|
import { conversationJobQueue } from '../jobs/conversationJobQueue';
|
||||||
|
import { incrementMessageCounter } from './incrementMessageCounter';
|
||||||
|
|
||||||
const RETRY_LIMIT = 5;
|
const RETRY_LIMIT = 5;
|
||||||
|
|
||||||
|
@ -668,7 +669,7 @@ export function startAutomaticSessionReset(
|
||||||
}
|
}
|
||||||
|
|
||||||
const receivedAt = Date.now();
|
const receivedAt = Date.now();
|
||||||
const receivedAtCounter = window.Signal.Util.incrementMessageCounter();
|
const receivedAtCounter = incrementMessageCounter();
|
||||||
drop(
|
drop(
|
||||||
conversation.queueJob('addChatSessionRefreshed', async () => {
|
conversation.queueJob('addChatSessionRefreshed', async () => {
|
||||||
await conversation.addChatSessionRefreshed({
|
await conversation.addChatSessionRefreshed({
|
||||||
|
|
|
@ -8,6 +8,7 @@ import * as Errors from '../types/errors';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import { ProgressModal } from '../components/ProgressModal';
|
import { ProgressModal } from '../components/ProgressModal';
|
||||||
import { clearTimeoutIfNecessary } from './clearTimeoutIfNecessary';
|
import { clearTimeoutIfNecessary } from './clearTimeoutIfNecessary';
|
||||||
|
import { sleep } from './sleep';
|
||||||
|
|
||||||
export async function longRunningTaskWrapper<T>({
|
export async function longRunningTaskWrapper<T>({
|
||||||
name,
|
name,
|
||||||
|
@ -49,7 +50,7 @@ export async function longRunningTaskWrapper<T>({
|
||||||
log.info(
|
log.info(
|
||||||
`longRunningTaskWrapper/${idLog}: Spinner shown for less than second, showing for another second`
|
`longRunningTaskWrapper/${idLog}: Spinner shown for less than second, showing for another second`
|
||||||
);
|
);
|
||||||
await window.Signal.Util.sleep(ONE_SECOND);
|
await sleep(ONE_SECOND);
|
||||||
}
|
}
|
||||||
unmountComponentAtNode(progressNode);
|
unmountComponentAtNode(progressNode);
|
||||||
progressNode = undefined;
|
progressNode = undefined;
|
||||||
|
|
47
ts/window.d.ts
vendored
47
ts/window.d.ts
vendored
|
@ -9,8 +9,6 @@ import type * as Backbone from 'backbone';
|
||||||
import type PQueue from 'p-queue/dist';
|
import type PQueue from 'p-queue/dist';
|
||||||
import type { assert } from 'chai';
|
import type { assert } from 'chai';
|
||||||
import type { PhoneNumber, PhoneNumberFormat } from 'google-libphonenumber';
|
import type { PhoneNumber, PhoneNumberFormat } from 'google-libphonenumber';
|
||||||
import type * as Registration from './util/registration';
|
|
||||||
import type * as zkgroup from './util/zkgroup';
|
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
ConversationModelCollectionType,
|
ConversationModelCollectionType,
|
||||||
|
@ -41,7 +39,7 @@ import type { createApp } from './state/roots/createApp';
|
||||||
import type Data from './sql/Client';
|
import type Data from './sql/Client';
|
||||||
import type { MessageModel } from './models/messages';
|
import type { MessageModel } from './models/messages';
|
||||||
import type { ConversationModel } from './models/conversations';
|
import type { ConversationModel } from './models/conversations';
|
||||||
import type { BatcherType, createBatcher } from './util/batcher';
|
import type { BatcherType } from './util/batcher';
|
||||||
import type { ConfirmationDialog } from './components/ConfirmationDialog';
|
import type { ConfirmationDialog } from './components/ConfirmationDialog';
|
||||||
import type { SignalProtocolStore } from './SignalProtocolStore';
|
import type { SignalProtocolStore } from './SignalProtocolStore';
|
||||||
import type { SocketStatus } from './types/SocketStatus';
|
import type { SocketStatus } from './types/SocketStatus';
|
||||||
|
@ -57,27 +55,7 @@ import type { IPCEventsType } from './util/createIPCEvents';
|
||||||
import type { SignalContextType } from './windows/context';
|
import type { SignalContextType } from './windows/context';
|
||||||
import type * as Message2 from './types/Message2';
|
import type * as Message2 from './types/Message2';
|
||||||
import type { initializeMigrations } from './signal';
|
import type { initializeMigrations } from './signal';
|
||||||
import type {
|
|
||||||
flushMessageCounter,
|
|
||||||
incrementMessageCounter,
|
|
||||||
initializeMessageCounter,
|
|
||||||
} from './util/incrementMessageCounter';
|
|
||||||
import type { RetryPlaceholders } from './util/retryPlaceholders';
|
import type { RetryPlaceholders } from './util/retryPlaceholders';
|
||||||
import type { sleep } from './util/sleep';
|
|
||||||
import type {
|
|
||||||
queueUpdateMessage,
|
|
||||||
saveNewMessageBatcher,
|
|
||||||
setBatchingStrategy,
|
|
||||||
} from './util/messageBatcher';
|
|
||||||
import type {
|
|
||||||
sendContentMessageToGroup,
|
|
||||||
sendToGroup,
|
|
||||||
} from './util/sendToGroup';
|
|
||||||
import type * as GoogleChrome from './util/GoogleChrome';
|
|
||||||
import type { makeLookup } from './util/makeLookup';
|
|
||||||
import type { getStringForProfileChange } from './util/getStringForProfileChange';
|
|
||||||
import type { deleteForEveryone } from './util/deleteForEveryone';
|
|
||||||
import type { parseRemoteClientExpiration } from './util/parseRemoteClientExpiration';
|
|
||||||
|
|
||||||
export { Long } from 'long';
|
export { Long } from 'long';
|
||||||
|
|
||||||
|
@ -155,27 +133,6 @@ export type SignalCoreType = {
|
||||||
Address: typeof Address;
|
Address: typeof Address;
|
||||||
QualifiedAddress: typeof QualifiedAddress;
|
QualifiedAddress: typeof QualifiedAddress;
|
||||||
};
|
};
|
||||||
Util: {
|
|
||||||
createBatcher: typeof createBatcher;
|
|
||||||
deleteForEveryone: typeof deleteForEveryone;
|
|
||||||
flushMessageCounter: typeof flushMessageCounter;
|
|
||||||
getStringForProfileChange: typeof getStringForProfileChange;
|
|
||||||
GoogleChrome: typeof GoogleChrome;
|
|
||||||
incrementMessageCounter: typeof incrementMessageCounter;
|
|
||||||
initializeMessageCounter: typeof initializeMessageCounter;
|
|
||||||
makeLookup: typeof makeLookup;
|
|
||||||
MessageController: typeof MessageController;
|
|
||||||
parseRemoteClientExpiration: typeof parseRemoteClientExpiration;
|
|
||||||
queueUpdateMessage: typeof queueUpdateMessage;
|
|
||||||
Registration: typeof Registration;
|
|
||||||
RetryPlaceholders: typeof RetryPlaceholders;
|
|
||||||
saveNewMessageBatcher: typeof saveNewMessageBatcher;
|
|
||||||
sendContentMessageToGroup: typeof sendContentMessageToGroup;
|
|
||||||
sendToGroup: typeof sendToGroup;
|
|
||||||
setBatchingStrategy: typeof setBatchingStrategy;
|
|
||||||
sleep: typeof sleep;
|
|
||||||
zkgroup: typeof zkgroup;
|
|
||||||
};
|
|
||||||
Components: {
|
Components: {
|
||||||
ConfirmationDialog: typeof ConfirmationDialog;
|
ConfirmationDialog: typeof ConfirmationDialog;
|
||||||
};
|
};
|
||||||
|
@ -298,6 +255,8 @@ declare global {
|
||||||
testUtilities: {
|
testUtilities: {
|
||||||
onComplete: (info: unknown) => void;
|
onComplete: (info: unknown) => void;
|
||||||
prepareTests: () => void;
|
prepareTests: () => void;
|
||||||
|
installMessageController: () => void;
|
||||||
|
initializeMessageCounter: () => Promise<void>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ import { sync } from 'fast-glob';
|
||||||
import { assert } from 'chai';
|
import { assert } from 'chai';
|
||||||
|
|
||||||
import { getSignalProtocolStore } from '../../SignalProtocolStore';
|
import { getSignalProtocolStore } from '../../SignalProtocolStore';
|
||||||
|
import { MessageController } from '../../util/MessageController';
|
||||||
|
import { initializeMessageCounter } from '../../util/incrementMessageCounter';
|
||||||
|
|
||||||
window.assert = assert;
|
window.assert = assert;
|
||||||
|
|
||||||
|
@ -27,6 +29,12 @@ window.testUtilities = {
|
||||||
cwd: __dirname,
|
cwd: __dirname,
|
||||||
}).forEach(require);
|
}).forEach(require);
|
||||||
},
|
},
|
||||||
|
installMessageController() {
|
||||||
|
MessageController.install();
|
||||||
|
},
|
||||||
|
initializeMessageCounter() {
|
||||||
|
return initializeMessageCounter();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
window.getSignalProtocolStore = getSignalProtocolStore;
|
window.getSignalProtocolStore = getSignalProtocolStore;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue