Fix race handling contact sync with verified info (#1419)
When processing a contact sync with embedded identity key verification info, we were running overlapping async fetch/save operations on the same conversation model, causing a race that tends to clobber updates to the contact info. In this change we extend the application-level contact info handler to block on a subsequent call to the verification handler, which effectively serializes the fetch/save calls, and relieves the need for the message receiver to trigger a seperate event concerning the verification info on contact sync messages. Fixes #1408 // FREEBIE
This commit is contained in:
		
					parent
					
						
							
								07abe2639f
							
						
					
				
			
			
				commit
				
					
						51cd28bb4a
					
				
			
		
					 3 changed files with 14 additions and 26 deletions
				
			
		| 
						 | 
				
			
			@ -38784,10 +38784,7 @@ MessageReceiver.prototype.extend({
 | 
			
		|||
            throw new Error('Got empty SyncMessage');
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    handleVerified: function(envelope, verified, options) {
 | 
			
		||||
        options = options || {};
 | 
			
		||||
        _.defaults(options, {viaContactSync: false});
 | 
			
		||||
 | 
			
		||||
    handleVerified: function(envelope, verified) {
 | 
			
		||||
        var ev = new Event('verified');
 | 
			
		||||
        ev.confirm = this.removeFromCache.bind(this, envelope);
 | 
			
		||||
        ev.verified = {
 | 
			
		||||
| 
						 | 
				
			
			@ -38795,7 +38792,6 @@ MessageReceiver.prototype.extend({
 | 
			
		|||
            destination: verified.destination,
 | 
			
		||||
            identityKey: verified.identityKey.toArrayBuffer()
 | 
			
		||||
        };
 | 
			
		||||
        ev.viaContactSync = options.viaContactSync;
 | 
			
		||||
        return this.dispatchAndWait(ev);
 | 
			
		||||
    },
 | 
			
		||||
    handleRead: function(envelope, read) {
 | 
			
		||||
| 
						 | 
				
			
			@ -38825,14 +38821,6 @@ MessageReceiver.prototype.extend({
 | 
			
		|||
                ev.contactDetails = contactDetails;
 | 
			
		||||
                results.push(this.dispatchAndWait(ev));
 | 
			
		||||
 | 
			
		||||
                if (contactDetails.verified) {
 | 
			
		||||
                    results.push(this.handleVerified(
 | 
			
		||||
                        envelope,
 | 
			
		||||
                        contactDetails.verified,
 | 
			
		||||
                        {viaContactSync: true}
 | 
			
		||||
                    ));
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                contactDetails = contactBuffer.next();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue