diff --git a/app/models/queued_message.rb b/app/models/queued_message.rb index 94bc44a..84027b1 100644 --- a/app/models/queued_message.rb +++ b/app/models/queued_message.rb @@ -64,7 +64,7 @@ class QueuedMessage < ApplicationRecord end def allocate_ip_address - if Postal.config.general.use_ip_pools && self.message && pool = self.server.ip_pool_for_message(self.message) + if Postal.ip_pools? && self.message && pool = self.server.ip_pool_for_message(self.message) self.ip_address = pool.ip_addresses.order("RAND()").first end end diff --git a/app/models/server.rb b/app/models/server.rb index c6c43d7..4be4370 100644 --- a/app/models/server.rb +++ b/app/models/server.rb @@ -47,7 +47,7 @@ class Server < ApplicationRecord include HasSoftDestroy belongs_to :organization - belongs_to :ip_pool + belongs_to :ip_pool, :optional => true has_many :domains, :dependent => :destroy, :as => :owner has_many :credentials, :dependent => :destroy has_many :smtp_endpoints, :dependent => :destroy @@ -280,7 +280,6 @@ class Server < ApplicationRecord def ip_pool_for_message(message) if message.scope == 'outgoing' - [self, self.organization].each do |scope| rules = scope.ip_pool_rules.order(:created_at => :desc) rules.each do |rule| @@ -289,7 +288,6 @@ class Server < ApplicationRecord end end end - self.ip_pool else nil diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 17594d1..013a29e 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -39,7 +39,7 @@ %li.siteHeader__subMenuItem= link_to "Switch organization", root_path, :class => 'siteHeader__subMenuLink' %li.siteHeader__navItem.siteHeader__navItem--user= current_user.name %li.siteHeader__navItem= link_to "My Settings", settings_path, :class => 'sideHeader__navItemLink' - - if current_user.admin? + - if current_user.admin? && Postal.ip_pools? %li.siteHeader__navItem= link_to "IP Pools", ip_pools_path, :class => 'sideHeader__navItemLink' %li.siteHeader__navItem= link_to "Logout", logout_path, :method => :delete, :class => 'sideHeader__navItemLink' diff --git a/app/views/servers/_form.html.haml b/app/views/servers/_form.html.haml index 4ead7b0..4b63e2d 100644 --- a/app/views/servers/_form.html.haml +++ b/app/views/servers/_form.html.haml @@ -21,12 +21,13 @@ outgoing & incoming mail will be held and only visible in the web interface and will not be sent to any recipients or HTTP endpoints. - .fieldSet__field - = f.label :ip_pool_id, :class => 'fieldSet__label' - .fieldSet__input - = f.collection_select :ip_pool_id, organization.ip_pools.includes(:ip_addresses).order("`default` desc, name asc"), :id, :description, {}, :class => 'input input--select' - %p.fieldSet__text - This is the set of IP addresses which outbound e-mails will be delivered from. + - if Postal.ip_pools? + .fieldSet__field + = f.label :ip_pool_id, :class => 'fieldSet__label' + .fieldSet__input + = f.collection_select :ip_pool_id, organization.ip_pools.includes(:ip_addresses).order("`default` desc, name asc"), :id, :description, {}, :class => 'input input--select' + %p.fieldSet__text + This is the set of IP addresses which outbound e-mails will be delivered from. - if @server.persisted? .fieldSet__field diff --git a/app/views/servers/_header.html.haml b/app/views/servers/_header.html.haml index 0a2eff0..f90ffde 100644 --- a/app/views/servers/_header.html.haml +++ b/app/views/servers/_header.html.haml @@ -14,7 +14,8 @@ %li.serverHeader__list--warning= link_to "#{pluralize bad_dns, 'domain'} has misconfigured DNS records", [organization, @server, :domains] - if unverified > 0 %li= link_to "#{pluralize unverified, 'domain'} is awaiting verification", [organization, @server, :domains] - %li Sending via #{@server.ip_pool.name} + - if Postal.ip_pools? + %li Sending via #{@server.ip_pool.name} .serverHeader__stats{"data-turbolinks-permanent" => true, :id => "serverStats-#{@server.uuid}"} %ul.serverHeader__statsList diff --git a/db/seeds.rb b/db/seeds.rb index 45ed7a5..2e840db 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,7 +1,3 @@ -ip_pool = IPPool.create!(:name => "Shared IP Pool", :type => 'Transactional', :default => true) -ip_pool.ip_addresses.create!(:ipv4 => "10.1.1.1", :ipv6 => "2a03:1234:a:1::1", :hostname => "i2.mx.example.com") -ip_pool.ip_addresses.create!(:ipv4 => "10.1.1.2", :ipv6 => "2a03:1234:a:1::2", :hostname => "i3.mx.example.com") - user = User.create!(:first_name => "Example", :last_name => "Admin", :email_address => "admin@example.com", :password => "password", :time_zone => "London", :email_verified_at => Time.now, :admin => true) org = Organization.create!(:name => "Acme Inc", :permalink => "acme", :time_zone => "London", :owner => user)