docbrown/app/controllers/admin/reactions_controller.rb
Josh Puetz 1c566e0ec4
[deploy] Move /internal to `/admin (#9639)
* First draft - all the big changes

* Changing some more references to 'internal'

* Relocate internal request tests to admin

* Relocate internal system tests to admin

* Fix trailing space

* Test fix

* Move queries from internal to admin

* Docs updates

* Rename internal stimuls controllers to admin (plus docs)

* Rename admin layout

* Fix routing after rebase

* Fixes for latest added admin interfaces

* Serviceworker ignore paths
2020-08-07 10:36:26 -04:00

23 lines
720 B
Ruby

module Admin
class ReactionsController < Admin::ApplicationController
after_action only: [:update] do
Audit::Logger.log(:moderator, current_user, params.dup)
end
def update
@reaction = Reaction.find(params[:id])
if @reaction.update(status: params[:status])
Moderator::SinkArticles.call(@reaction.reactable_id) if confirmed_vomit_reaction?
render json: { outcome: "Success" }
else
render json: { error: @reaction.errors_as_sentence }, status: :unprocessable_entity
end
end
private
def confirmed_vomit_reaction?
@reaction.reactable_type == "User" && @reaction.status == "confirmed" && @reaction.category == "vomit"
end
end
end