Send and receive PniSignatureMessage
This commit is contained in:
parent
95be24e8f7
commit
00cfd92dd0
43 changed files with 1082 additions and 164 deletions
|
@ -10,13 +10,8 @@ import * as Bytes from '../Bytes';
|
|||
import { getRandomBytes } from '../Crypto';
|
||||
import { getConversationMembers } from './getConversationMembers';
|
||||
import { isDirectConversation, isMe } from './whatTypeOfConversation';
|
||||
import { isInSystemContacts } from './isInSystemContacts';
|
||||
import { missingCaseError } from './missingCaseError';
|
||||
import { senderCertificateService } from '../services/senderCertificate';
|
||||
import {
|
||||
PhoneNumberSharingMode,
|
||||
parsePhoneNumberSharingMode,
|
||||
} from './phoneNumberSharingMode';
|
||||
import { shouldSharePhoneNumberWith } from './phoneNumberSharingMode';
|
||||
import type { SerializedCertificateType } from '../textsecure/OutgoingMessage';
|
||||
import { SenderCertificateMode } from '../textsecure/OutgoingMessage';
|
||||
import { isNotNil } from './isNotNil';
|
||||
|
@ -146,25 +141,11 @@ function getSenderCertificateForDirectConversation(
|
|||
);
|
||||
}
|
||||
|
||||
const phoneNumberSharingMode = parsePhoneNumberSharingMode(
|
||||
window.storage.get('phoneNumberSharingMode')
|
||||
);
|
||||
|
||||
let certificateMode: SenderCertificateMode;
|
||||
switch (phoneNumberSharingMode) {
|
||||
case PhoneNumberSharingMode.Everybody:
|
||||
certificateMode = SenderCertificateMode.WithE164;
|
||||
break;
|
||||
case PhoneNumberSharingMode.ContactsOnly:
|
||||
certificateMode = isInSystemContacts(conversationAttrs)
|
||||
? SenderCertificateMode.WithE164
|
||||
: SenderCertificateMode.WithoutE164;
|
||||
break;
|
||||
case PhoneNumberSharingMode.Nobody:
|
||||
certificateMode = SenderCertificateMode.WithoutE164;
|
||||
break;
|
||||
default:
|
||||
throw missingCaseError(phoneNumberSharingMode);
|
||||
if (shouldSharePhoneNumberWith(conversationAttrs)) {
|
||||
certificateMode = SenderCertificateMode.WithE164;
|
||||
} else {
|
||||
certificateMode = SenderCertificateMode.WithoutE164;
|
||||
}
|
||||
|
||||
return senderCertificateService.get(certificateMode);
|
||||
|
|
|
@ -236,7 +236,14 @@ async function maybeSaveToSendLog(
|
|||
sendType: SendTypesType;
|
||||
}
|
||||
): Promise<void> {
|
||||
const { contentHint, contentProto, recipients, timestamp, urgent } = result;
|
||||
const {
|
||||
contentHint,
|
||||
contentProto,
|
||||
recipients,
|
||||
timestamp,
|
||||
urgent,
|
||||
hasPniSignatureMessage,
|
||||
} = result;
|
||||
|
||||
if (!shouldSaveProto(sendType)) {
|
||||
return;
|
||||
|
@ -268,6 +275,7 @@ async function maybeSaveToSendLog(
|
|||
proto: Buffer.from(contentProto),
|
||||
contentHint,
|
||||
urgent: isBoolean(urgent) ? urgent : true,
|
||||
hasPniSignatureMessage: Boolean(hasPniSignatureMessage),
|
||||
},
|
||||
{
|
||||
messageIds,
|
||||
|
|
|
@ -10,7 +10,7 @@ import { readSyncJobQueue } from '../jobs/readSyncJobQueue';
|
|||
import { notificationService } from '../services/notifications';
|
||||
import { expiringMessagesDeletionService } from '../services/expiringMessagesDeletion';
|
||||
import { tapToViewMessagesDeletionService } from '../services/tapToViewMessagesDeletionService';
|
||||
import { isGroup } from './whatTypeOfConversation';
|
||||
import { isGroup, isDirectConversation } from './whatTypeOfConversation';
|
||||
import * as log from '../logging/log';
|
||||
import { getConversationIdForLogging } from './idForLogging';
|
||||
import { ReadStatus } from '../messages/MessageReadStatus';
|
||||
|
@ -94,6 +94,7 @@ export async function markConversationRead(
|
|||
uuid: messageSyncData.sourceUuid,
|
||||
})?.id,
|
||||
timestamp: messageSyncData.sent_at,
|
||||
isDirectConversation: isDirectConversation(conversationAttrs),
|
||||
hasErrors: message ? hasErrors(message.attributes) : false,
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { ConversationAttributesType } from '../model-types.d';
|
||||
|
||||
import { makeEnumParser } from './enum';
|
||||
import { isInSystemContacts } from './isInSystemContacts';
|
||||
import { missingCaseError } from './missingCaseError';
|
||||
import { isDirectConversation, isMe } from './whatTypeOfConversation';
|
||||
|
||||
// These strings are saved to disk, so be careful when changing them.
|
||||
export enum PhoneNumberSharingMode {
|
||||
|
@ -14,3 +19,26 @@ export const parsePhoneNumberSharingMode = makeEnumParser(
|
|||
PhoneNumberSharingMode,
|
||||
PhoneNumberSharingMode.Everybody
|
||||
);
|
||||
|
||||
export const shouldSharePhoneNumberWith = (
|
||||
conversation: ConversationAttributesType
|
||||
): boolean => {
|
||||
if (!isDirectConversation(conversation) || isMe(conversation)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const phoneNumberSharingMode = parsePhoneNumberSharingMode(
|
||||
window.storage.get('phoneNumberSharingMode')
|
||||
);
|
||||
|
||||
switch (phoneNumberSharingMode) {
|
||||
case PhoneNumberSharingMode.Everybody:
|
||||
return true;
|
||||
case PhoneNumberSharingMode.ContactsOnly:
|
||||
return isInSystemContacts(conversation);
|
||||
case PhoneNumberSharingMode.Nobody:
|
||||
return false;
|
||||
default:
|
||||
throw missingCaseError(phoneNumberSharingMode);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -122,11 +122,15 @@ export async function sendReceipts({
|
|||
map(batches, async batch => {
|
||||
const timestamps = batch.map(receipt => receipt.timestamp);
|
||||
const messageIds = batch.map(receipt => receipt.messageId);
|
||||
const isDirectConversation = batch.some(
|
||||
receipt => receipt.isDirectConversation
|
||||
);
|
||||
|
||||
await handleMessageSend(
|
||||
messaging[methodName]({
|
||||
senderE164: sender.get('e164'),
|
||||
senderUuid: sender.get('uuid'),
|
||||
isDirectConversation,
|
||||
timestamps,
|
||||
options: sendOptions,
|
||||
}),
|
||||
|
|
|
@ -225,6 +225,7 @@ export async function sendContentMessageToGroup({
|
|||
sendType,
|
||||
timestamp,
|
||||
urgent,
|
||||
hasPniSignatureMessage: false,
|
||||
});
|
||||
const groupId = sendTarget.isGroupV2() ? sendTarget.getGroupId() : undefined;
|
||||
return window.textsecure.messaging.sendGroupProto({
|
||||
|
@ -544,6 +545,7 @@ export async function sendToGroupViaSenderKey(options: {
|
|||
proto: Buffer.from(Proto.Content.encode(contentMessage).finish()),
|
||||
timestamp,
|
||||
urgent,
|
||||
hasPniSignatureMessage: false,
|
||||
},
|
||||
{
|
||||
recipients: senderKeyRecipientsWithDevices,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue