<commit_before>module Mailchimp
  class MandrillDeliveryHandler
    attr_accessor :settings

    def initialize(options = {})
      self.settings = {:track_opens => true, :track_clicks => true, :from_name => 'Mandrill Email Delivery Handler'}.merge(options)
    end

    def deliver!(message)

      message_payload = {
        :track_opens => settings[:track_opens],
        :track_clicks => settings[:track_clicks],
        :message => {
          :subject => message.subject,
          :from_name => settings[:from_name],
          :from_email => message.from.first,
          :to => ensure_mandrill_compatible_mail_format(message.to)
        }
      }

      [:html, :text].each do |format|
        content = get_content_for(message, format)
        message_payload[:message][format] = content if content
      end

      message_payload[:tags] = settings[:tags] if settings[:tags]

      #payload parameters that take an array but that come in as a string
      ["tags", 'google_analytics_domains', 'google_analytics_campaign'].each do |parameter|
        next if message[parameter].blank?
        message_payload[parameter] = message[parameter].split(",")
      end

      message_payload[:tags] = message["X-MC-Tags"] unless message["X-MC-Tags"].blank?
      message_payload[:google_analytics_domains] = message['X-MC-GoogleAnalytics'] unless message['X-MC-GoogleAnalytics'].blank?
      message_payload[:google_analytics_campaign] = message['X-MC-GoogleAnalyticsCampaign'] unless message['X-MC-GoogleAnalyticsCampaign'].blank?

      api_key = message.header['api-key'].blank? ? settings[:api_key] : message.header['api-key']<commit_msg>actually commit the right files<commit_after>module Mailchimp
  class MandrillDeliveryHandler
    attr_accessor :settings

    def initialize(options = {})
      self.settings = {:track_opens => true, :track_clicks => true, :from_name => 'Mandrill Email Delivery Handler'}.merge(options)
    end

    def deliver!(message)

      message_payload = {
        :track_opens => settings[:track_opens],
        :track_clicks => settings[:track_clicks],
        :message => {
          :subject => message.subject,
          :from_name => settings[:from_name],
          :from_email => message.from.first,
          :to => ensure_mandrill_compatible_mail_format(message.to)
        }
      }

      [:html, :text].each do |format|
        content = get_content_for(message, format)
        message_payload[:message][format] = content if content
      end

      message_payload[:tags] = settings[:tags] if settings[:tags]

      #payload parameters that take an array but that come in as a string
      ["tags", 'google_analytics_domains', 'google_analytics_campaign'].each do |parameter|
        next if message[parameter].blank?
        message_payload[parameter] = message[parameter].value.split(",")
      end

      api_key = message.header['api-key'].blank? ? settings[:api_key] : message.header['api-key']
{'fraction_non_alphanumeric': 0.12368688580142324, 'fraction_numerical': 0.0, 'mean_word_length': 3.412556053811659, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '1080654', 'n_tokens_mistral': 853, 'n_tokens_neox': 820, 'n_words': 173}