mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	do_deactivate_user: Use .on_commit around send_event calls.
The previous commit did this for revoking sessions. send_events should
be handled similarly too, to correctly handle calling do_deactivate_user
inside a transaction.
(cherry picked from commit 470c0458e6)
			
			
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							a3d9297c37
						
					
				
				
					commit
					43606b6e39
				
			@@ -162,20 +162,28 @@ def do_deactivate_user(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        transaction.on_commit(lambda: delete_user_sessions(user_profile))
 | 
					        transaction.on_commit(lambda: delete_user_sessions(user_profile))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    event = dict(
 | 
					        event_remove_user = dict(
 | 
				
			||||||
        type="realm_user",
 | 
					            type="realm_user",
 | 
				
			||||||
        op="remove",
 | 
					 | 
				
			||||||
        person=dict(user_id=user_profile.id, full_name=user_profile.full_name),
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
    send_event(user_profile.realm, event, active_user_ids(user_profile.realm_id))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if user_profile.is_bot:
 | 
					 | 
				
			||||||
        event = dict(
 | 
					 | 
				
			||||||
            type="realm_bot",
 | 
					 | 
				
			||||||
            op="remove",
 | 
					            op="remove",
 | 
				
			||||||
            bot=dict(user_id=user_profile.id, full_name=user_profile.full_name),
 | 
					            person=dict(user_id=user_profile.id, full_name=user_profile.full_name),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        send_event(user_profile.realm, event, bot_owner_user_ids(user_profile))
 | 
					        transaction.on_commit(
 | 
				
			||||||
 | 
					            lambda: send_event(
 | 
				
			||||||
 | 
					                user_profile.realm, event_remove_user, active_user_ids(user_profile.realm_id)
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if user_profile.is_bot:
 | 
				
			||||||
 | 
					            event_remove_bot = dict(
 | 
				
			||||||
 | 
					                type="realm_bot",
 | 
				
			||||||
 | 
					                op="remove",
 | 
				
			||||||
 | 
					                bot=dict(user_id=user_profile.id, full_name=user_profile.full_name),
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					            transaction.on_commit(
 | 
				
			||||||
 | 
					                lambda: send_event(
 | 
				
			||||||
 | 
					                    user_profile.realm, event_remove_bot, bot_owner_user_ids(user_profile)
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@transaction.atomic(durable=True)
 | 
					@transaction.atomic(durable=True)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user