docbrown/app/services/ping_admins.rb

25 lines
450 B
Ruby

class PingAdmins
def initialize(user, action = "unknown")
@user = user
@action = action
end
def self.call(*args)
new(*args).call
end
def call
return unless user && Rails.env.production?
SlackBot.ping(
"Rate limit exceeded (#{action}). https://dev.to#{user.path}",
channel: "abuse-reports",
username: "rate_limit",
icon_emoji: ":hand:",
)
end
private
attr_reader :user, :action
end