FIX: invite approval `StaffActionLogger` bug (#7151)

FIX: invite approval StaffActionLogger bug (#7151)

  • FIX: invite approval StaffActionLogger bug
diff --git a/app/models/invite_redeemer.rb b/app/models/invite_redeemer.rb
index bbf40ef..2f63d50 100644
--- a/app/models/invite_redeemer.rb
+++ b/app/models/invite_redeemer.rb
@@ -133,7 +133,7 @@ InviteRedeemer = Struct.new(:invite, :username, :name, :password, :user_custom_f
 
   def approve_account_if_needed
     if get_existing_user
-      invited_user.approve(invite.invited_by_id, false)
+      invited_user.approve(invite.invited_by, false)
     end
   end
 
diff --git a/app/models/user.rb b/app/models/user.rb
index 09ae5c6..4c27103 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -405,23 +405,17 @@ class User < ActiveRecord::Base
   end
 
   # Approve this user
-  def approve(approved_by, send_mail = true)
+  def approve(approver, send_mail = true)
     self.approved = true
-
-    if approved_by.is_a?(Integer)
-      self.approved_by_id = approved_by
-    else
-      self.approved_by = approved_by
-    end
-
     self.approved_at = Time.zone.now
+    self.approved_by = approver
 
     if result = save
       send_approval_email if send_mail
       DiscourseEvent.trigger(:user_approved, self)
     end
 
-    StaffActionLogger.new(approved_by).log_user_approve(self)
+    StaffActionLogger.new(approver).log_user_approve(self)
 
     result
   end

GitHub sha: 4a00772c