Sha256: 5f7d4c896398ca8111c160bb496d37dad1e3d1b485a80e2ac1a63adeb1f1dd6a

Contents?: true

Size: 867 Bytes

Versions: 1

Compression:

Stored size: 867 Bytes

Contents

namespace :effective_postmark do
  desc 'Assign email delivery errors to postmark users from suppressions API'
  task assign_email_delivery_errors: :environment do
    table = ActiveRecord::Base.connection.table_exists?(:users)
    blank_tenant = defined?(Tenant) && Tenant.current.blank?

    if table && !blank_tenant && EffectivePostmark.api_present?
      puts "Assigning postmark email delivery errors"

      klass = User.all
      raise("expected an effective_postmark_user User class") unless klass.try(:effective_postmark_user?)

      api = EffectivePostmark.api

      begin
        api.assign_email_delivery_errors!(klass)
      rescue StandardError => e
        ExceptionNotifier.notify_exception(e) if defined?(ExceptionNotifier)
        puts "Error with effective_postmark:assign_email_delivery_errors"
      end
    end

    puts 'All done'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
effective_postmark-0.4.0 lib/tasks/effective_postmark_tasks.rake