docbrown/app/observers/reaction_observer.rb
Anna Buianova 18d1300341 Moved SlackBot.delay.ping calls to ActiveJob #3136 (#3139)
* Moved SlackBot.delay.ping calls to ActiveJob

* Removed unused user creation from the spec
2019-06-12 09:23:37 -04:00

14 lines
507 B
Ruby

class ReactionObserver < ActiveRecord::Observer
def after_create(reaction)
if reaction.category == "vomit"
SlackBotPingJob.perfom_later(
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