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) { getProfile: function(number) {
return this.server.getProfile(number).then(function(profile) { return this.server.getProfile(number);
var identityKey = dcodeIO.ByteBuffer.wrap(profile.identityKey).toArrayBuffer();
return textsecure.storage.protocol.isTrusted(number, identityKey).then(function(trusted) {
});
});
}, },
sendRequestGroupSyncMessage: function() { sendRequestGroupSyncMessage: function() {

View file

@ -339,6 +339,27 @@
}.bind(this)); }.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() { fetchMessages: function() {
if (!this.id) { return false; } if (!this.id) { return false; }
return this.messageCollection.fetchConversation(this.id, null, this.get('unreadCount')); return this.messageCollection.fetchConversation(this.id, null, this.get('unreadCount'));

View file

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

View file

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