Fetch profiles whenever conversations are opened

For a group, fetch everyone's profile.

// FREEBIE
This commit is contained in:
lilia 2017-05-26 17:05:49 -07:00 committed by Scott Nonnenberg
parent d295fa7057
commit f095a1583e
4 changed files with 25 additions and 14 deletions

View file

@ -39186,13 +39186,7 @@ MessageSender.prototype = {
},
getProfile: function(number) {
return this.server.getProfile(number).then(function(profile) {
var identityKey = dcodeIO.ByteBuffer.wrap(profile.identityKey).toArrayBuffer();
return textsecure.storage.protocol.isTrusted(number, identityKey).then(function(trusted) {
});
});
return this.server.getProfile(number);
},
sendRequestGroupSyncMessage: function() {

View file

@ -339,6 +339,27 @@
}.bind(this));
},
getProfiles: function() {
// request all conversation members' keys
var ids = [];
if (this.isPrivate()) {
ids = [this.id];
} else {
ids = this.get('members');
}
ids.forEach(this.getProfile);
},
getProfile: function(id) {
return textsecure.messaging.getProfile(id).then(function(profile) {
var identityKey = dcodeIO.ByteBuffer.wrap(profile.identityKey, 'base64').toArrayBuffer();
return textsecure.storage.protocol.saveIdentity(
id, identityKey, storage.get('safety-numbers-approval', true), false
);
});
},
fetchMessages: function() {
if (!this.id) { return false; }
return this.messageCollection.fetchConversation(this.id, null, this.get('unreadCount'));

View file

@ -230,6 +230,8 @@
},
onOpened: function() {
this.model.getProfiles();
this.view.resetScrollPosition();
this.$el.trigger('force-resize');
this.focusMessageField();

View file

@ -255,13 +255,7 @@ MessageSender.prototype = {
},
getProfile: function(number) {
return this.server.getProfile(number).then(function(profile) {
var identityKey = dcodeIO.ByteBuffer.wrap(profile.identityKey).toArrayBuffer();
return textsecure.storage.protocol.isTrusted(number, identityKey).then(function(trusted) {
});
});
return this.server.getProfile(number);
},
sendRequestGroupSyncMessage: function() {