mirror of
				https://github.com/matrix-org/synapse.git
				synced 2025-11-04 02:01:03 +01:00 
			
		
		
		
	add check to only add a new filter if the same filter does not exist previously
Signed-off-by: Matthias Kesler <krombel@krombel.de>
This commit is contained in:
		
							parent
							
								
									29ded770b1
								
							
						
					
					
						commit
						6b95e35e96
					
				@ -51,6 +51,15 @@ class FilteringStore(SQLBaseStore):
 | 
			
		||||
        # Need an atomic transaction to SELECT the maximal ID so far then
 | 
			
		||||
        # INSERT a new one
 | 
			
		||||
        def _do_txn(txn):
 | 
			
		||||
            sql = (
 | 
			
		||||
                "SELECT filter_id FROM user_filters "
 | 
			
		||||
                "WHERE user_id = ? AND filter_json = ?"
 | 
			
		||||
            )
 | 
			
		||||
            txn.execute(sql, (user_localpart,def_json))
 | 
			
		||||
            filter_id = txn.fetchone()[0]
 | 
			
		||||
            if filter_id is not None:
 | 
			
		||||
                return filter_id
 | 
			
		||||
 | 
			
		||||
            sql = (
 | 
			
		||||
                "SELECT MAX(filter_id) FROM user_filters "
 | 
			
		||||
                "WHERE user_id = ?"
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user