mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
Divorce identity wipe from tryAgain functions
We'd like to live in a world where we can retry all the pending conflicts in a conversation as a batch, which means we don't want to wipe the identity key before processing each message. Thus, remove that step from these handlers and encapsulate in a method on the conversation model.
This commit is contained in:
@@ -190,6 +190,7 @@
|
||||
return '';
|
||||
}
|
||||
},
|
||||
|
||||
isPrivate: function() {
|
||||
return this.get('type') === 'private';
|
||||
},
|
||||
@@ -218,7 +219,35 @@
|
||||
this.updateAvatarUrl();
|
||||
}
|
||||
return this.avatarUrl || '/images/default.png';
|
||||
},
|
||||
|
||||
resolveConflicts: function() {
|
||||
if (!this.isPrivate()) {
|
||||
throw "Can't call resolveConflicts on non-private conversation";
|
||||
}
|
||||
|
||||
if (!this.messageCollection.find(function(m) { return m.getKeyConflict(); })) {
|
||||
throw "No conflicts to resolve";
|
||||
}
|
||||
|
||||
textsecure.storage.devices.removeIdentityKeyForNumber(this.get('id'));
|
||||
this.messageCollection.each(function(message) {
|
||||
var conflict = message.getKeyConflict();
|
||||
if (conflict) {
|
||||
new textsecure.ReplayableError(conflict).replay().
|
||||
then(function(pushMessageContent) {
|
||||
message.save('errors', []);
|
||||
if (message.isIncoming()) {
|
||||
extension.trigger('message:decrypted', {
|
||||
message_id: message.id,
|
||||
data: pushMessageContent
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Whisper.ConversationCollection = Backbone.Collection.extend({
|
||||
|
||||
Reference in New Issue
Block a user