When incoming message should've been sealed sender, reply with profile key

This commit is contained in:
Evan Hahn 2021-05-05 11:39:16 -05:00 committed by GitHub
parent 18c86898d1
commit 8ef14e6f39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 384 additions and 38 deletions

View file

@ -75,6 +75,7 @@ import MessageSender, { CallbackResultType } from './textsecure/SendMessage';
import { CURRENT_SCHEMA_VERSION as MAX_MESSAGE_SCHEMA } from '../js/modules/types/message';
import { ConversationModel } from './models/conversations';
import { getGroupSizeHardLimit } from './groups/limits';
import { ourProfileKeyService } from './services/ourProfileKey';
export { joinViaLink } from './groups/joinViaLink';
@ -1251,7 +1252,7 @@ export async function modifyGroupV2({
// Send message to notify group members (including pending members) of change
const profileKey = conversation.get('profileSharing')
? window.storage.get('profileKey')
? await ourProfileKeyService.get()
: undefined;
const sendOptions = await conversation.getSendOptions();
@ -1620,7 +1621,7 @@ export async function createGroupV2({
});
const timestamp = Date.now();
const profileKey = ourConversation.get('profileKey');
const profileKey = await ourProfileKeyService.get();
const groupV2Info = conversation.getGroupV2Info({
includePendingMembers: true,
@ -1633,7 +1634,7 @@ export async function createGroupV2({
sender.sendMessageToGroup({
groupV2: groupV2Info,
timestamp,
profileKey: profileKey ? base64ToArrayBuffer(profileKey) : undefined,
profileKey,
}),
timestamp,
});
@ -1953,8 +1954,6 @@ export async function initiateMigrationToGroupV2(
// Ensure we have the credentials we need before attempting GroupsV2 operations
await maybeFetchNewCredentials();
let ourProfileKey: undefined | string;
try {
await conversation.queueJob(async () => {
const ACCESS_ENUM =
@ -1997,7 +1996,6 @@ export async function initiateMigrationToGroupV2(
`initiateMigrationToGroupV2/${logId}: cannot get our own conversation. Cannot migrate`
);
}
ourProfileKey = ourConversation.get('profileKey');
const {
membersV2,
@ -2137,6 +2135,10 @@ export async function initiateMigrationToGroupV2(
const logId = conversation.idForLogging();
const timestamp = Date.now();
const ourProfileKey:
| ArrayBuffer
| undefined = await ourProfileKeyService.get();
await wrapWithSyncMessageSend({
conversation,
logId: `sendMessageToGroup/${logId}`,
@ -2147,9 +2149,7 @@ export async function initiateMigrationToGroupV2(
includePendingMembers: true,
}),
timestamp,
profileKey: ourProfileKey
? base64ToArrayBuffer(ourProfileKey)
: undefined,
profileKey: ourProfileKey,
}),
timestamp,
});