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
|
@ -347,7 +347,7 @@ async function _runJob(job?: AttachmentDownloadJobType): Promise<void> {
|
|||
);
|
||||
if (message) {
|
||||
await saveMessage(message.attributes, {
|
||||
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
|
||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ async function _finishJob(
|
|||
if (message) {
|
||||
logger.info(`attachment_downloads/_finishJob for job id: ${id}`);
|
||||
await saveMessage(message.attributes, {
|
||||
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
|
||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import { isOutgoing, isStory } from '../state/selectors/message';
|
|||
import { getOwn } from '../util/getOwn';
|
||||
import { missingCaseError } from '../util/missingCaseError';
|
||||
import { createWaitBatcher } from '../util/waitBatcher';
|
||||
import type { UUIDStringType } from '../types/UUID';
|
||||
import type { ServiceIdString } from '../types/ServiceId';
|
||||
import * as Errors from '../types/errors';
|
||||
import {
|
||||
SendActionType,
|
||||
|
@ -37,7 +37,7 @@ export enum MessageReceiptType {
|
|||
export type MessageReceiptAttributesType = {
|
||||
messageSentAt: number;
|
||||
receiptTimestamp: number;
|
||||
sourceUuid: UUIDStringType;
|
||||
sourceServiceId: ServiceIdString;
|
||||
sourceConversationId: string;
|
||||
sourceDevice: number;
|
||||
type: MessageReceiptType;
|
||||
|
@ -80,7 +80,7 @@ const deleteSentProtoBatcher = createWaitBatcher({
|
|||
|
||||
async function getTargetMessage(
|
||||
sourceId: string,
|
||||
sourceUuid: UUIDStringType,
|
||||
serviceId: ServiceIdString,
|
||||
messages: ReadonlyArray<MessageAttributesType>
|
||||
): Promise<MessageModel | null> {
|
||||
if (messages.length === 0) {
|
||||
|
@ -94,7 +94,9 @@ async function getTargetMessage(
|
|||
return window.MessageController.register(message.id, message);
|
||||
}
|
||||
|
||||
const groups = await window.Signal.Data.getAllGroupsInvolvingUuid(sourceUuid);
|
||||
const groups = await window.Signal.Data.getAllGroupsInvolvingServiceId(
|
||||
serviceId
|
||||
);
|
||||
|
||||
const ids = groups.map(item => item.id);
|
||||
ids.push(sourceId);
|
||||
|
@ -154,9 +156,9 @@ export class MessageReceipts extends Collection<MessageReceiptModel> {
|
|||
return [];
|
||||
}
|
||||
|
||||
const ourUuid = window.textsecure.storage.user.getCheckedUuid().toString();
|
||||
const ourAci = window.textsecure.storage.user.getCheckedAci();
|
||||
const sourceUuid = getSourceUuid(message.attributes);
|
||||
if (ourUuid !== sourceUuid) {
|
||||
if (ourAci !== sourceUuid) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -255,14 +257,14 @@ export class MessageReceipts extends Collection<MessageReceiptModel> {
|
|||
type === MessageReceiptType.Read
|
||||
) {
|
||||
const recipient = window.ConversationController.get(sourceConversationId);
|
||||
const recipientUuid = recipient?.get('uuid');
|
||||
const recipientServiceId = recipient?.getServiceId();
|
||||
const deviceId = receipt.get('sourceDevice');
|
||||
|
||||
if (recipientUuid && deviceId) {
|
||||
if (recipientServiceId && deviceId) {
|
||||
await Promise.all([
|
||||
deleteSentProtoBatcher.add({
|
||||
timestamp: messageSentAt,
|
||||
recipientUuid,
|
||||
recipientServiceId,
|
||||
deviceId,
|
||||
}),
|
||||
|
||||
|
@ -283,7 +285,7 @@ export class MessageReceipts extends Collection<MessageReceiptModel> {
|
|||
async onReceipt(receipt: MessageReceiptModel): Promise<void> {
|
||||
const messageSentAt = receipt.get('messageSentAt');
|
||||
const sourceConversationId = receipt.get('sourceConversationId');
|
||||
const sourceUuid = receipt.get('sourceUuid');
|
||||
const sourceServiceId = receipt.get('sourceServiceId');
|
||||
const type = receipt.get('type');
|
||||
|
||||
try {
|
||||
|
@ -293,7 +295,7 @@ export class MessageReceipts extends Collection<MessageReceiptModel> {
|
|||
|
||||
const message = await getTargetMessage(
|
||||
sourceConversationId,
|
||||
sourceUuid,
|
||||
sourceServiceId,
|
||||
messages
|
||||
);
|
||||
|
||||
|
@ -315,7 +317,7 @@ export class MessageReceipts extends Collection<MessageReceiptModel> {
|
|||
'MessageReceipts: No message for receipt',
|
||||
type,
|
||||
sourceConversationId,
|
||||
sourceUuid,
|
||||
sourceServiceId,
|
||||
messageSentAt
|
||||
);
|
||||
return;
|
||||
|
|
|
@ -7,10 +7,11 @@ import { Collection, Model } from 'backbone';
|
|||
import type { ConversationModel } from '../models/conversations';
|
||||
import * as log from '../logging/log';
|
||||
import * as Errors from '../types/errors';
|
||||
import type { AciString } from '../types/ServiceId';
|
||||
|
||||
export type MessageRequestAttributesType = {
|
||||
threadE164?: string;
|
||||
threadUuid?: string;
|
||||
threadAci?: AciString;
|
||||
groupV2Id?: string;
|
||||
type: number;
|
||||
};
|
||||
|
@ -44,7 +45,7 @@ export class MessageRequests extends Collection<MessageRequestModel> {
|
|||
|
||||
if (conversation.get('uuid')) {
|
||||
const syncByUuid = this.findWhere({
|
||||
threadUuid: conversation.get('uuid'),
|
||||
threadAci: conversation.get('uuid'),
|
||||
});
|
||||
if (syncByUuid) {
|
||||
log.info(
|
||||
|
@ -75,7 +76,7 @@ export class MessageRequests extends Collection<MessageRequestModel> {
|
|||
async onResponse(sync: MessageRequestModel): Promise<void> {
|
||||
try {
|
||||
const threadE164 = sync.get('threadE164');
|
||||
const threadUuid = sync.get('threadUuid');
|
||||
const threadAci = sync.get('threadAci');
|
||||
const groupV2Id = sync.get('groupV2Id');
|
||||
|
||||
let conversation;
|
||||
|
@ -84,17 +85,17 @@ export class MessageRequests extends Collection<MessageRequestModel> {
|
|||
if (groupV2Id) {
|
||||
conversation = window.ConversationController.get(groupV2Id);
|
||||
}
|
||||
if (!conversation && (threadE164 || threadUuid)) {
|
||||
if (!conversation && (threadE164 || threadAci)) {
|
||||
conversation = window.ConversationController.lookupOrCreate({
|
||||
e164: threadE164,
|
||||
uuid: threadUuid,
|
||||
uuid: threadAci,
|
||||
reason: 'MessageRequests.onResponse',
|
||||
});
|
||||
}
|
||||
|
||||
if (!conversation) {
|
||||
log.warn(
|
||||
`Received message request response for unknown conversation: groupv2(${groupV2Id}) ${threadUuid} ${threadE164}`
|
||||
`Received message request response for unknown conversation: groupv2(${groupV2Id}) ${threadAci} ${threadE164}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import { isMessageUnread } from '../util/isMessageUnread';
|
|||
import { notificationService } from '../services/notifications';
|
||||
import * as log from '../logging/log';
|
||||
import * as Errors from '../types/errors';
|
||||
import type { AciString } from '../types/ServiceId';
|
||||
import { StartupQueue } from '../util/StartupQueue';
|
||||
import { queueUpdateMessage } from '../util/messageBatcher';
|
||||
import { getMessageSentTimestamp } from '../util/getMessageSentTimestamp';
|
||||
|
@ -18,7 +19,7 @@ import { getMessageSentTimestamp } from '../util/getMessageSentTimestamp';
|
|||
export type ReadSyncAttributesType = {
|
||||
senderId: string;
|
||||
sender?: string;
|
||||
senderUuid: string;
|
||||
senderAci: AciString;
|
||||
timestamp: number;
|
||||
readAt: number;
|
||||
};
|
||||
|
@ -29,7 +30,7 @@ let singleton: ReadSyncs | undefined;
|
|||
|
||||
async function maybeItIsAReactionReadSync(sync: ReadSyncModel): Promise<void> {
|
||||
const readReaction = await window.Signal.Data.markReactionAsRead(
|
||||
sync.get('senderUuid'),
|
||||
sync.get('senderAci'),
|
||||
Number(sync.get('timestamp'))
|
||||
);
|
||||
|
||||
|
@ -38,7 +39,7 @@ async function maybeItIsAReactionReadSync(sync: ReadSyncModel): Promise<void> {
|
|||
'Nothing found for read sync',
|
||||
sync.get('senderId'),
|
||||
sync.get('sender'),
|
||||
sync.get('senderUuid'),
|
||||
sync.get('senderAci'),
|
||||
sync.get('timestamp')
|
||||
);
|
||||
return;
|
||||
|
|
|
@ -7,10 +7,11 @@ import { Collection, Model } from 'backbone';
|
|||
import type { MessageModel } from '../models/messages';
|
||||
import * as log from '../logging/log';
|
||||
import * as Errors from '../types/errors';
|
||||
import type { AciString } from '../types/ServiceId';
|
||||
|
||||
export type ViewOnceOpenSyncAttributesType = {
|
||||
source?: string;
|
||||
sourceUuid: string;
|
||||
sourceAci: AciString;
|
||||
timestamp: number;
|
||||
};
|
||||
|
||||
|
@ -30,7 +31,7 @@ export class ViewOnceOpenSyncs extends Collection<ViewOnceOpenSyncModel> {
|
|||
forMessage(message: MessageModel): ViewOnceOpenSyncModel | null {
|
||||
const syncBySourceUuid = this.find(item => {
|
||||
return (
|
||||
item.get('sourceUuid') === message.get('sourceUuid') &&
|
||||
item.get('sourceAci') === message.get('sourceUuid') &&
|
||||
item.get('timestamp') === message.get('sent_at')
|
||||
);
|
||||
});
|
||||
|
@ -62,26 +63,24 @@ export class ViewOnceOpenSyncs extends Collection<ViewOnceOpenSyncModel> {
|
|||
);
|
||||
|
||||
const found = messages.find(item => {
|
||||
const itemSourceUuid = item.sourceUuid;
|
||||
const syncSourceUuid = sync.get('sourceUuid');
|
||||
const itemSourceAci = item.sourceUuid;
|
||||
const syncSourceAci = sync.get('sourceAci');
|
||||
const itemSource = item.source;
|
||||
const syncSource = sync.get('source');
|
||||
|
||||
return Boolean(
|
||||
(itemSourceUuid &&
|
||||
syncSourceUuid &&
|
||||
itemSourceUuid === syncSourceUuid) ||
|
||||
(itemSourceAci && syncSourceAci && itemSourceAci === syncSourceAci) ||
|
||||
(itemSource && syncSource && itemSource === syncSource)
|
||||
);
|
||||
});
|
||||
|
||||
const syncSource = sync.get('source');
|
||||
const syncSourceUuid = sync.get('sourceUuid');
|
||||
const syncSourceAci = sync.get('sourceAci');
|
||||
const syncTimestamp = sync.get('timestamp');
|
||||
const wasMessageFound = Boolean(found);
|
||||
log.info('Receive view once open sync:', {
|
||||
syncSource,
|
||||
syncSourceUuid,
|
||||
syncSourceAci,
|
||||
syncTimestamp,
|
||||
wasMessageFound,
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@ import type { MessageModel } from '../models/messages';
|
|||
import { ReadStatus } from '../messages/MessageReadStatus';
|
||||
import { markViewed } from '../services/MessageUpdater';
|
||||
import { isDownloaded } from '../types/Attachment';
|
||||
import type { AciString } from '../types/ServiceId';
|
||||
import * as Errors from '../types/errors';
|
||||
import { isIncoming } from '../state/selectors/message';
|
||||
import { notificationService } from '../services/notifications';
|
||||
|
@ -21,7 +22,7 @@ import { getMessageSentTimestamp } from '../util/getMessageSentTimestamp';
|
|||
export type ViewSyncAttributesType = {
|
||||
senderId: string;
|
||||
senderE164?: string;
|
||||
senderUuid: string;
|
||||
senderAci: AciString;
|
||||
timestamp: number;
|
||||
viewedAt: number;
|
||||
};
|
||||
|
@ -84,7 +85,7 @@ export class ViewSyncs extends Collection {
|
|||
'Nothing found for view sync',
|
||||
sync.get('senderId'),
|
||||
sync.get('senderE164'),
|
||||
sync.get('senderUuid'),
|
||||
sync.get('senderAci'),
|
||||
sync.get('timestamp')
|
||||
);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue