مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-11-30 21:32:30 +00:00
chore: Upgrade to Ruby 3.2.1 & Rails 6.0
* chore: upgrade to rails 6.0 * chore: upgrade ruby to 3.2.1 * chore: upgrade bundler * chore: upgrade execjs * chore: upgrade to rails 6.1 * chore: switch to sentry-ruby from raven * chore: add extra platforms to gemfile
هذا الالتزام موجود في:
@@ -1,3 +1,5 @@
|
||||
//= link_tree ../images
|
||||
//= link_directory ../javascripts .js
|
||||
//= link_directory ../stylesheets .css
|
||||
//= link application/application.css
|
||||
//= link application/application.js
|
||||
|
||||
@@ -424,8 +424,8 @@ class UnqueueMessageJob < Postal::Job
|
||||
e.backtrace.each { |e| log("#{log_prefix} #{e}") }
|
||||
queued_message.retry_later
|
||||
log "#{log_prefix} Queued message was unlocked"
|
||||
if defined?(Raven)
|
||||
Raven.capture_exception(e, extra: { job_id: self.id, server_id: queued_message.server_id, message_id: queued_message.message_id })
|
||||
if defined?(Sentry)
|
||||
Sentry.capture_exception(e, extra: { job_id: self.id, server_id: queued_message.server_id, message_id: queued_message.message_id })
|
||||
end
|
||||
if queued_message.message
|
||||
queued_message.message.create_delivery("Error", details: "An internal error occurred while sending this message. This message will be retried automatically. If this persists, contact support for assistance.", output: "#{e.class}: #{e.message}", log_id: "J-#{self.id}")
|
||||
|
||||
@@ -19,7 +19,7 @@ class AddressEndpoint < ApplicationRecord
|
||||
has_many :routes, as: :endpoint
|
||||
has_many :additional_route_endpoints, dependent: :destroy, as: :endpoint
|
||||
|
||||
validates :address, presence: true, format: { with: /@/ }, uniqueness: { scope: [:server_id], message: "has already been added" }
|
||||
validates :address, presence: true, format: { with: /@/ }, uniqueness: { scope: [:server_id], message: "has already been added", case_sensitive: false }
|
||||
|
||||
before_destroy :update_routes
|
||||
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
class User
|
||||
module HasAuthentication
|
||||
|
||||
has_secure_password
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
validates :password, length: { minimum: 8, allow_blank: true }
|
||||
included do
|
||||
has_secure_password
|
||||
|
||||
when_attribute :password_digest, changes_to: :anything do
|
||||
before_save do
|
||||
self.password_reset_token = nil
|
||||
self.password_reset_token_valid_until = nil
|
||||
validates :password, length: { minimum: 8, allow_blank: true }
|
||||
|
||||
when_attribute :password_digest, changes_to: :anything do
|
||||
before_save do
|
||||
self.password_reset_token = nil
|
||||
self.password_reset_token_valid_until = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.authenticate(email_address, password)
|
||||
user = where(email_address: email_address).first
|
||||
raise Postal::Errors::AuthenticationError, "InvalidEmailAddress" if user.nil?
|
||||
raise Postal::Errors::AuthenticationError, "InvalidPassword" unless user.authenticate(password)
|
||||
class_methods do
|
||||
def authenticate(email_address, password)
|
||||
user = where(email_address: email_address).first
|
||||
raise Postal::Errors::AuthenticationError, "InvalidEmailAddress" if user.nil?
|
||||
raise Postal::Errors::AuthenticationError, "InvalidPassword" unless user.authenticate(password)
|
||||
|
||||
user
|
||||
user
|
||||
end
|
||||
end
|
||||
|
||||
def authenticate_with_previous_password_first(unencrypted_password)
|
||||
@@ -1,6 +1,6 @@
|
||||
require "resolv"
|
||||
|
||||
class Domain
|
||||
module HasDNSChecks
|
||||
|
||||
def dns_ok?
|
||||
spf_status == "OK" && dkim_status == "OK" && ["OK", "Missing"].include?(mx_status) && ["OK", "Missing"].include?(return_path_status)
|
||||
@@ -23,7 +23,7 @@ class Credential < ApplicationRecord
|
||||
|
||||
TYPES = ["SMTP", "API", "SMTP-IP"]
|
||||
|
||||
validates :key, presence: true, uniqueness: true
|
||||
validates :key, presence: true, uniqueness: { case_sensitive: false }
|
||||
validates :type, inclusion: { in: TYPES }
|
||||
validates :name, presence: true
|
||||
validate :validate_key_cannot_be_changed
|
||||
|
||||
@@ -40,8 +40,7 @@ class Domain < ApplicationRecord
|
||||
|
||||
include HasUUID
|
||||
|
||||
require_dependency "domain/dns_checks"
|
||||
require_dependency "domain/dns_verification"
|
||||
include HasDNSChecks
|
||||
|
||||
VERIFICATION_EMAIL_ALIASES = ["webmaster", "postmaster", "admin", "administrator", "hostmaster"]
|
||||
|
||||
@@ -52,7 +51,7 @@ class Domain < ApplicationRecord
|
||||
|
||||
VERIFICATION_METHODS = ["DNS", "Email"]
|
||||
|
||||
validates :name, presence: true, format: { with: /\A[a-z0-9\-.]*\z/ }, uniqueness: { scope: [:owner_type, :owner_id], message: "is already added" }
|
||||
validates :name, presence: true, format: { with: /\A[a-z0-9\-.]*\z/ }, uniqueness: { case_sensitive: false, scope: [:owner_type, :owner_id], message: "is already added" }
|
||||
validates :verification_method, inclusion: { in: VERIFICATION_METHODS }
|
||||
|
||||
random_string :dkim_identifier_string, type: :chars, length: 6, unique: true, upper_letters_only: true
|
||||
@@ -138,6 +137,22 @@ class Domain < ApplicationRecord
|
||||
@resolver ||= Postal.config.general.use_local_ns_for_domains? ? Resolv::DNS.new : Resolv::DNS.new(nameserver: nameservers)
|
||||
end
|
||||
|
||||
def dns_verification_string
|
||||
"#{Postal.config.dns.domain_verify_prefix} #{verification_token}"
|
||||
end
|
||||
|
||||
def verify_with_dns
|
||||
return false unless verification_method == "DNS"
|
||||
|
||||
result = resolver.getresources(name, Resolv::DNS::Resource::IN::TXT)
|
||||
if result.map { |d| d.data.to_s.strip }.include?(dns_verification_string)
|
||||
self.verified_at = Time.now
|
||||
save
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_nameservers
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
require "resolv"
|
||||
|
||||
class Domain
|
||||
|
||||
def dns_verification_string
|
||||
"#{Postal.config.dns.domain_verify_prefix} #{verification_token}"
|
||||
end
|
||||
|
||||
def verify_with_dns
|
||||
return false unless verification_method == "DNS"
|
||||
|
||||
result = resolver.getresources(name, Resolv::DNS::Resource::IN::TXT)
|
||||
if result.map { |d| d.data.to_s.strip }.include?(dns_verification_string)
|
||||
self.verified_at = Time.now
|
||||
save
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# -*- SkipSchemaAnnotations
|
||||
@@ -31,7 +31,7 @@ class Organization < ApplicationRecord
|
||||
include HasSoftDestroy
|
||||
|
||||
validates :name, presence: true
|
||||
validates :permalink, presence: true, format: { with: /\A[a-z0-9-]*\z/ }, uniqueness: true, exclusion: { in: RESERVED_PERMALINKS }
|
||||
validates :permalink, presence: true, format: { with: /\A[a-z0-9-]*\z/ }, uniqueness: { case_sensitive: false }, exclusion: { in: RESERVED_PERMALINKS }
|
||||
validates :time_zone, presence: true
|
||||
|
||||
default_value :time_zone, -> { "UTC" }
|
||||
|
||||
@@ -72,9 +72,9 @@ class Server < ApplicationRecord
|
||||
default_value :spam_threshold, -> { Postal.config.general.default_spam_threshold }
|
||||
default_value :spam_failure_threshold, -> { Postal.config.general.default_spam_failure_threshold }
|
||||
|
||||
validates :name, presence: true, uniqueness: { scope: :organization_id }
|
||||
validates :name, presence: true, uniqueness: { scope: :organization_id, case_sensitive: false }
|
||||
validates :mode, inclusion: { in: MODES }
|
||||
validates :permalink, presence: true, uniqueness: { scope: :organization_id }, format: { with: /\A[a-z0-9-]*\z/ }, exclusion: { in: RESERVED_PERMALINKS }
|
||||
validates :permalink, presence: true, uniqueness: { scope: :organization_id, case_sensitive: false }, format: { with: /\A[a-z0-9-]*\z/ }, exclusion: { in: RESERVED_PERMALINKS }
|
||||
validate :validate_ip_pool_belongs_to_organization
|
||||
|
||||
before_validation(on: :create) do
|
||||
|
||||
@@ -27,8 +27,8 @@ class TrackDomain < ApplicationRecord
|
||||
belongs_to :server
|
||||
belongs_to :domain
|
||||
|
||||
validates :name, presence: true, format: { with: /\A[a-z0-9-]+\z/ }, uniqueness: { scope: :domain_id, message: "is already added" }
|
||||
validates :domain_id, uniqueness: { scope: :server_id, message: "already has a track domain for this server" }
|
||||
validates :name, presence: true, format: { with: /\A[a-z0-9-]+\z/ }, uniqueness: { scope: :domain_id, case_sensitive: false, message: "is already added" }
|
||||
validates :domain_id, uniqueness: { scope: :server_id, case_sensitive: false, message: "already has a track domain for this server" }
|
||||
validate :validate_domain_belongs_to_server
|
||||
|
||||
scope :ok, -> { where(dns_status: "OK") }
|
||||
|
||||
@@ -27,11 +27,11 @@ class User < ApplicationRecord
|
||||
|
||||
include HasUUID
|
||||
|
||||
require_dependency "user/authentication"
|
||||
include HasAuthentication
|
||||
|
||||
validates :first_name, presence: true
|
||||
validates :last_name, presence: true
|
||||
validates :email_address, presence: true, uniqueness: true, format: { with: /@/, allow_blank: true }
|
||||
validates :email_address, presence: true, uniqueness: { case_sensitive: false }, format: { with: /@/, allow_blank: true }
|
||||
validates :time_zone, presence: true
|
||||
|
||||
default_value :time_zone, -> { "UTC" }
|
||||
|
||||
@@ -18,7 +18,7 @@ class UserInvite < ApplicationRecord
|
||||
|
||||
include HasUUID
|
||||
|
||||
validates :email_address, presence: true, uniqueness: true, format: { with: /@/, allow_blank: true }
|
||||
validates :email_address, presence: true, uniqueness: { case_sensitive: false }, format: { with: /@/, allow_blank: true }
|
||||
|
||||
has_many :organization_users, dependent: :destroy, as: :user
|
||||
has_many :organizations, through: :organization_users
|
||||
|
||||
@@ -58,4 +58,3 @@
|
||||
Powered by #{link_to "Postal", "https://postalserver.io", target: '_blank'} #{Postal.version}.
|
||||
%li= link_to "Documentation", "https://docs.postalserver.io", target: '_blank'
|
||||
%li= link_to "Ask for help", "https://discussions.postalserver.io", target: '_blank'
|
||||
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم