Verify param integrity for bounces

This commit is contained in:
Karl Erik Õunapuu 2020-09-17 15:55:37 +03:00
parent 834b2c95bc
commit b2c5a9a5ec
No known key found for this signature in database
GPG key ID: C9DD647298A34764

View file

@ -1,11 +1,20 @@
module Api
module V1
class BouncesController < BaseController
before_action :authenticate
# POST api/v1/bounces/
def create
bounced_mail_address = BouncedMailAddress.record(json)
bounced_mail_address ? render(head: :ok) : render(head: :failed)
BouncedMailAddress.record(bounce_params)
head(:ok)
rescue ActionController::ParameterMissing
head(:bad_request)
end
def bounce_params
params.require(:data).require(:bounce).require(:bouncedRecipients).each do |r|
r.require(:emailAddress)
end
params.require(:data)
end
end
end