مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-12-01 05:43:04 +00:00
initial commit from appmail
هذا الالتزام موجود في:
48
app/models/smtp_endpoint.rb
Normal file
48
app/models/smtp_endpoint.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: smtp_endpoints
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# server_id :integer
|
||||
# uuid :string(255)
|
||||
# name :string(255)
|
||||
# hostname :string(255)
|
||||
# ssl_mode :string(255)
|
||||
# port :integer
|
||||
# error :text(65535)
|
||||
# disabled_until :datetime
|
||||
# last_used_at :datetime
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
#
|
||||
|
||||
class SMTPEndpoint < ApplicationRecord
|
||||
|
||||
include HasUUID
|
||||
|
||||
belongs_to :server
|
||||
has_many :routes, :as => :endpoint
|
||||
has_many :additional_route_endpoints, :dependent => :destroy, :as => :endpoint
|
||||
|
||||
SSL_MODES = ['None', 'Auto', 'STARTTLS', 'TLS']
|
||||
|
||||
before_destroy :update_routes
|
||||
|
||||
validates :name, :presence => true
|
||||
validates :hostname, :presence => true, :format => /\A[a-z0-9\.\-]*\z/
|
||||
validates :ssl_mode, :inclusion => {:in => SSL_MODES}
|
||||
validates :port, :numericality => {:only_integer => true, :allow_blank => true}
|
||||
|
||||
def description
|
||||
"#{name} (#{hostname})"
|
||||
end
|
||||
|
||||
def mark_as_used
|
||||
update_column(:last_used_at, Time.now)
|
||||
end
|
||||
|
||||
def update_routes
|
||||
self.routes.each { |r| r.update(:endpoint => nil, :mode => 'Reject') }
|
||||
end
|
||||
|
||||
end
|
||||
المرجع في مشكلة جديدة
حظر مستخدم