Skip to content

Commit

Permalink
log using notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwoldatwork committed Dec 19, 2024
1 parent 0cacbff commit d853e63
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ def create

# Catch SPAMMERS
if @form && submission_params[:fba_directive].present?
Rails.logger.warn("SPAM subverted from #{request.referer}")
ActiveSupport::Notifications.instrument("spam_subverted") do |payload|
payload[:request] = request
end

head :ok and return
end

Expand Down
7 changes: 7 additions & 0 deletions config/initializers/notifications.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ActiveSupport::Notifications.subscribe("spam_subverted") do |name, start, finish, request_id, payload|
Rails.logger.warn("SPAM subverted from #{payload[:request].referer}, IP: #{payload[:request].remote_ip}, User-Agent: #{payload[:request].user_agent}")
end

ActiveSupport::Notifications.subscribe("rack.attack") do |name, start, finish, request_id, payload|
Rails.logger.info("[Rack::Attack] #{payload[:request].ip} blocked for #{payload[:discriminator]}")
end

0 comments on commit d853e63

Please sign in to comment.