Skip to content

Commit

Permalink
feat: early return if no email is present
Browse files Browse the repository at this point in the history
  • Loading branch information
scmmishra committed Nov 4, 2024
1 parent 1362148 commit 7ab8621
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/jobs/process_sns_webhook_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ class ProcessSNSWebhookJob < ApplicationJob
def perform(payload)
# https://docs.aws.amazon.com/ses/latest/dg/event-publishing-retrieving-sns-examples.html
@payload = payload.with_indifferent_access
@email = Email.find_by!(email_id: payload[:mail][:messageId])
@email = Email.find_by(email_id: payload[:mail][:messageId])
event_name = payload[:eventType].underscore

return unless @email.present?

if self.respond_to?("process_#{event_name}")
send("process_#{event_name}")
end
Expand Down

0 comments on commit 7ab8621

Please sign in to comment.