<commit_before>module EpPostmaster
  class MailgunHooksController < ApplicationController
    attr_accessor :mailgun_post
    
    before_filter :authenticate_request!, except: :test
    
    def bounced_email
      if mailgun_post.bounced_email?
        Postmaster.bounced_email(mailgun_post).deliver
        call_bounced_email_handler
        render nothing: true, status: 200
      else
        render nothing: true, status: 406 # Mailgun won't retry request if it receives a 406
      end
    end
    
  private
    
    def authenticate_request!
      @mailgun_post = MailgunPost.new(params)
      render nothing: true, status: :unauthorized unless mailgun_post.authentic?
    end
    
    def call_bounced_email_handler
      handler = EpPostmaster.configuration.bounced_email_handler
      if handler.respond_to?(:handle_bounced_email)
        handler.send(:handle_bounced_email, mailgun_post.sender, mailgun_post.recipient)
      else
        raise RuntimeError, "Expected #{handler} to define a method: handle_bounced_email"
      end
    end
    
  end
end<commit_msg>[Improvement] Modified the arguments sent to the bounced_email_handler (2m)<commit_after>module EpPostmaster
  class MailgunHooksController < ApplicationController
    attr_accessor :mailgun_post
    
    before_filter :authenticate_request!, except: :test
    
    def bounced_email
      if mailgun_post.bounced_email?
        Postmaster.bounced_email(mailgun_post).deliver
        call_bounced_email_handler
        render nothing: true, status: 200
      else
        render nothing: true, status: 406 # Mailgun won't retry request if it receives a 406
      end
    end
    
  private
    
    def authenticate_request!
      @mailgun_post = MailgunPost.new(params)
      render nothing: true, status: :unauthorized unless mailgun_post.authentic?
    end
    
    def call_bounced_email_handler
      handler = EpPostmaster.configuration.bounced_email_handler
      if handler.respond_to?(:handle_bounced_email)
        handler.send(:handle_bounced_email, mailgun_post.recipient, mailgun_post)
      else
        raise RuntimeError, "Expected #{handler} to define a method: handle_bounced_email"
      end
    end
    
  end
end
{'fraction_non_alphanumeric': 0.05472636815920398, 'fraction_numerical': 0.008593396653098146, 'mean_word_length': 3.20532319391635, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7484425', 'n_tokens_mistral': 666, 'n_tokens_neox': 629, 'n_words': 157}