From 0222970ab27612f041f0ca4a67bf41ca0e6b3014 Mon Sep 17 00:00:00 2001 From: trwnh Date: Tue, 8 Nov 2022 23:06:20 -0600 Subject: [PATCH] Fix some actions being logged on idempotent calls --- .../api/v1/admin/accounts_controller.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/v1/admin/accounts_controller.rb b/app/controllers/api/v1/admin/accounts_controller.rb index ae7f7d0762b..f54e96bec8b 100644 --- a/app/controllers/api/v1/admin/accounts_controller.rb +++ b/app/controllers/api/v1/admin/accounts_controller.rb @@ -46,8 +46,10 @@ class Api::V1::Admin::AccountsController < Api::BaseController def enable authorize @account.user, :enable? - @account.user.enable! - log_action :enable, @account.user + if @account.user.disabled + @account.user.enable! + log_action :enable, @account.user + end render json: @account, serializer: REST::Admin::AccountSerializer end @@ -71,15 +73,19 @@ class Api::V1::Admin::AccountsController < Api::BaseController def unsensitive authorize @account, :unsensitive? - @account.unsensitize! - log_action :unsensitive, @account + if @account.sensitized? + @account.unsensitize! + log_action :unsensitive, @account + end render json: @account, serializer: REST::Admin::AccountSerializer end def unsilence authorize @account, :unsilence? - @account.unsilence! - log_action :unsilence, @account + if @account.silenced? + @account.unsilence! + log_action :unsilence, @account + end render json: @account, serializer: REST::Admin::AccountSerializer end