Refine sealed sender logic

This commit is contained in:
Scott Nonnenberg 2018-10-31 16:58:14 -07:00
parent f11dd18536
commit e2e0e4c96b
3 changed files with 156 additions and 98 deletions

View file

@ -1121,9 +1121,11 @@
// Sent:
async function handleMessageSentProfileUpdate({
data,
confirm,
messageDescriptor,
}) {
// First set profileSharing = true for the conversation we sent to
const { id, type } = messageDescriptor;
const conversation = await ConversationController.getOrCreateAndWait(
id,
@ -1135,6 +1137,14 @@
Conversation: Whisper.Conversation,
});
// Then we update our own profileKey if it's different from what we have
const ourNumber = textsecure.storage.user.getNumber();
const profileKey = data.message.profileKey.toString('base64');
const me = await ConversationController.getOrCreate(ourNumber, 'private');
// Will do the save for us if needed
await me.setProfileKey(profileKey);
return confirm();
}