module JamRuby
  class InvitedUserObserver < ActiveRecord::Observer

    observe JamRuby::InvitedUser

    @@log = Logging.logger[InvitedUserObserver]

    def after_create(invited_user)

      if invited_user.note
        # lie to spammer and say it worked. drop on floor
        @@log.info("dropping spammer " + invited_user.sender_id)
        # make spammer think we are sending email
        sleep (1)
        return
      end
      if invited_user.sender.nil?
        InvitedUserMailer.welcome_betauser(invited_user).deliver_now
      else
        InvitedUserMailer.friend_invitation(invited_user).deliver_now
      end if invited_user.email.present?
    end
  end
end
