app/models/spotlight/contact_email.rb in blacklight-spotlight-0.4.1 vs app/models/spotlight/contact_email.rb in blacklight-spotlight-0.5.0

- old
+ new

@@ -1,6 +1,8 @@ module Spotlight + ## + # Exhibit feedback contacts class ContactEmail < ActiveRecord::Base extend Devise::Models devise :confirmable belongs_to :exhibit validate :valid_email @@ -14,18 +16,20 @@ def recently_sent? confirmation_sent_at > 3.days.ago if confirmation_sent_at? end - protected + protected def valid_email begin parsed = Mail::Address.new(email) rescue Mail::Field::ParseError => e + Rails.logger.debug "Failed to parse email #{email}: #{e}" end - errors.add :email, "is not valid" unless !parsed.nil? && parsed.address == email && parsed.local != email #cannot be a local address + + errors.add :email, 'is not valid' if parsed.nil? || parsed.address != email || parsed.local == email end def send_devise_notification(notification, *args) notice = notification_mailer.send(notification, self, *args) if notice.respond_to? :deliver_now @@ -36,8 +40,7 @@ end def notification_mailer Spotlight::ConfirmationMailer end - end end