docbrown/app/observers/reaction_observer.rb
2020-02-03 11:18:37 -05:00

14 lines
511 B
Ruby

class ReactionObserver < ActiveRecord::Observer
def after_create(reaction)
if reaction.category == "vomit"
SlackBotPingWorker.perform_async(
message: "#{reaction.user.name} (https://dev.to#{reaction.user.path}) \nreacted with a #{reaction.category} on\nhttps://dev.to#{reaction.reactable.path}",
channel: "abuse-reports",
username: "abuse_bot",
icon_emoji: ":cry:",
)
end
rescue StandardError => e
Rails.logger.error("observer error: #{e}")
end
end