diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 39a241676..b3af8774d 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -1012,6 +1012,8 @@ MessageReceiver.prototype.extend({ throw e; } }, + // handle a SYNC message for a message + // sent by another device handleSentMessage(envelope, sentContainer, msg) { const { destination, @@ -1029,9 +1031,10 @@ MessageReceiver.prototype.extend({ this.processDecrypted(envelope, msg).then(message => { const groupId = message.group && message.group.id; const isBlocked = this.isGroupBlocked(groupId); + const primaryDevicePubKey = window.storage.get('primaryDevicePubKey'); const isMe = envelope.source === textsecure.storage.user.getNumber() || - envelope.source === window.storage.get('primaryDevicePubKey'); + envelope.source === primaryDevicePubKey; const isLeavingGroup = Boolean( message.group && message.group.type === textsecure.protobuf.GroupContext.Type.QUIT @@ -1046,6 +1049,16 @@ MessageReceiver.prototype.extend({ return this.removeFromCache(envelope); } + // handle profileKey and avatar updates + if (envelope.source === primaryDevicePubKey) { + const { profileKey, profile } = message; + const primaryConversation = ConversationController.get( + primaryDevicePubKey + ); + // + this.updateProfile(primaryConversation, profile, profileKey); + } + const ev = new Event('sent'); ev.confirm = this.removeFromCache.bind(this, envelope); ev.data = {