mirror of
				https://github.com/vector-im/element-web.git
				synced 2025-11-04 10:11:03 +01:00 
			
		
		
		
	only patch m.direct data on server once per session to avoid request storm
This commit is contained in:
		
							parent
							
								
									379ddfff29
								
							
						
					
					
						commit
						85b6f157c1
					
				@ -27,6 +27,8 @@ export default class DMRoomMap {
 | 
				
			|||||||
    constructor(matrixClient) {
 | 
					    constructor(matrixClient) {
 | 
				
			||||||
        this.matrixClient = matrixClient;
 | 
					        this.matrixClient = matrixClient;
 | 
				
			||||||
        this.roomToUser = null;
 | 
					        this.roomToUser = null;
 | 
				
			||||||
 | 
					        // see _onAccountData
 | 
				
			||||||
 | 
					        this._hasSentOutPatchDirectAccountDataPatch = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // XXX: Force-bind the event handler method because it
 | 
					        // XXX: Force-bind the event handler method because it
 | 
				
			||||||
        // doesn't call it with our object as the 'this'
 | 
					        // doesn't call it with our object as the 'this'
 | 
				
			||||||
@ -75,8 +77,14 @@ export default class DMRoomMap {
 | 
				
			|||||||
            const selfDMs = userToRooms[myUserId];
 | 
					            const selfDMs = userToRooms[myUserId];
 | 
				
			||||||
            if (selfDMs && selfDMs.length) {
 | 
					            if (selfDMs && selfDMs.length) {
 | 
				
			||||||
                this._patchUpSelfDMs(userToRooms);
 | 
					                this._patchUpSelfDMs(userToRooms);
 | 
				
			||||||
 | 
					                // to avoid multiple devices fighting to correct
 | 
				
			||||||
 | 
					                // the account data, only try to send the corrected
 | 
				
			||||||
 | 
					                // version once.
 | 
				
			||||||
 | 
					                if (!this._hasSentOutPatchDirectAccountDataPatch) {
 | 
				
			||||||
 | 
					                    this._hasSentOutPatchDirectAccountDataPatch = true;
 | 
				
			||||||
                    this.matrixClient.setAccountData('m.direct', userToRooms);
 | 
					                    this.matrixClient.setAccountData('m.direct', userToRooms);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            this.userToRooms = userToRooms;
 | 
					            this.userToRooms = userToRooms;
 | 
				
			||||||
            this._populateRoomToUser();
 | 
					            this._populateRoomToUser();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user