mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
Use transaction around deleting a user and logging that action
This commit is contained in:
@ -16,10 +16,12 @@ class UserDestroyer
|
|||||||
def destroy(user)
|
def destroy(user)
|
||||||
raise Discourse::InvalidParameters.new('user is nil') unless user and user.is_a?(User)
|
raise Discourse::InvalidParameters.new('user is nil') unless user and user.is_a?(User)
|
||||||
raise PostsExistError if user.post_count != 0
|
raise PostsExistError if user.post_count != 0
|
||||||
user.destroy.tap do |u|
|
User.transaction do
|
||||||
if u
|
user.destroy.tap do |u|
|
||||||
AdminLogger.new(@admin).log_user_deletion(user)
|
if u
|
||||||
MessageBus.publish "/file-change", ["refresh"], user_ids: [user.id]
|
AdminLogger.new(@admin).log_user_deletion(user)
|
||||||
|
MessageBus.publish "/file-change", ["refresh"], user_ids: [user.id]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user