FEATURE: Log user approvals. (#7121)

This commit is contained in:
Bianca Nenciu 2019-03-12 10:16:56 +02:00 committed by Sam
parent da941840d4
commit 191e31dccf
5 changed files with 15 additions and 2 deletions

View File

@ -421,6 +421,8 @@ class User < ActiveRecord::Base
DiscourseEvent.trigger(:user_approved, self)
end
StaffActionLogger.new(approved_by).log_user_approve(self)
result
end

View File

@ -84,7 +84,8 @@ class UserHistory < ActiveRecord::Base
merge_user: 65,
entity_export: 66,
change_password: 67,
topic_timestamps_changed: 68
topic_timestamps_changed: 68,
approve_user: 69
)
end
@ -147,7 +148,8 @@ class UserHistory < ActiveRecord::Base
:merge_user,
:entity_export,
:change_name,
:topic_timestamps_changed
:topic_timestamps_changed,
:approve_user
]
end

View File

@ -503,6 +503,13 @@ class StaffActionLogger
))
end
def log_user_approve(user, opts = {})
UserHistory.create!(params(opts).merge(
action: UserHistory.actions[:approve_user],
target_user_id: user.id
))
end
def log_user_deactivate(user, reason, opts = {})
raise Discourse::InvalidParameters.new(:user) unless user
UserHistory.create!(params(opts).merge(

View File

@ -3689,6 +3689,7 @@ en:
entity_export: "export entity"
change_name: "change name"
topic_timestamps_changed: "topic timestamps changed"
approve_user: "approved user"
screened_emails:
title: "Screened Emails"
description: "When someone tries to create a new account, the following email addresses will be checked and the registration will be blocked, or some other action performed."

View File

@ -71,6 +71,7 @@ RSpec.describe Admin::UsersController do
expect(response.status).to eq(200)
evil_trout.reload
expect(evil_trout.approved).to eq(true)
expect(UserHistory.where(action: UserHistory.actions[:approve_user], target_user_id: evil_trout.id).count).to eq(1)
end
end