1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-12-01 05:43:04 +00:00

style(rubocop): Style/MutableConstant

هذا الالتزام موجود في:
Adam Cooke
2024-02-10 17:34:29 +00:00
الأصل d508772a40
التزام 129dffab9e
14 ملفات معدلة مع 21 إضافات و24 حذوفات

عرض الملف

@@ -23,7 +23,7 @@ class Credential < ApplicationRecord
belongs_to :server belongs_to :server
TYPES = ["SMTP", "API", "SMTP-IP"] TYPES = ["SMTP", "API", "SMTP-IP"].freeze
validates :key, presence: true, uniqueness: { case_sensitive: false } validates :key, presence: true, uniqueness: { case_sensitive: false }
validates :type, inclusion: { in: TYPES } validates :type, inclusion: { in: TYPES }

عرض الملف

@@ -44,15 +44,14 @@ class Domain < ApplicationRecord
include HasDNSChecks include HasDNSChecks
VERIFICATION_EMAIL_ALIASES = ["webmaster", "postmaster", "admin", "administrator", "hostmaster"] VERIFICATION_EMAIL_ALIASES = ["webmaster", "postmaster", "admin", "administrator", "hostmaster"].freeze
VERIFICATION_METHODS = ["DNS", "Email"].freeze
belongs_to :server, optional: true belongs_to :server, optional: true
belongs_to :owner, optional: true, polymorphic: true belongs_to :owner, optional: true, polymorphic: true
has_many :routes, dependent: :destroy has_many :routes, dependent: :destroy
has_many :track_domains, dependent: :destroy has_many :track_domains, dependent: :destroy
VERIFICATION_METHODS = ["DNS", "Email"]
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 :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 } validates :verification_method, inclusion: { in: VERIFICATION_METHODS }

عرض الملف

@@ -31,8 +31,8 @@ class HTTPEndpoint < ApplicationRecord
has_many :routes, as: :endpoint has_many :routes, as: :endpoint
has_many :additional_route_endpoints, dependent: :destroy, as: :endpoint has_many :additional_route_endpoints, dependent: :destroy, as: :endpoint
ENCODINGS = ["BodyAsJSON", "FormData"] ENCODINGS = ["BodyAsJSON", "FormData"].freeze
FORMATS = ["Hash", "RawMessage"] FORMATS = ["Hash", "RawMessage"].freeze
before_destroy :update_routes before_destroy :update_routes

عرض الملف

@@ -25,7 +25,7 @@
class Organization < ApplicationRecord class Organization < ApplicationRecord
RESERVED_PERMALINKS = ["new", "edit", "remove", "delete", "destroy", "admin", "mail", "org", "server"] RESERVED_PERMALINKS = ["new", "edit", "remove", "delete", "destroy", "admin", "mail", "org", "server"].freeze
INITIAL_QUOTA = 10 INITIAL_QUOTA = 10
INITIAL_SUPER_QUOTA = 10_000 INITIAL_SUPER_QUOTA = 10_000

عرض الملف

@@ -24,7 +24,9 @@
class Route < ApplicationRecord class Route < ApplicationRecord
MODES = ["Endpoint", "Accept", "Hold", "Bounce", "Reject"] MODES = ["Endpoint", "Accept", "Hold", "Bounce", "Reject"].freeze
SPAM_MODES = ["Mark", "Quarantine", "Fail"].freeze
ENDPOINT_TYPES = ["SMTPEndpoint", "HTTPEndpoint", "AddressEndpoint"].freeze
include HasUUID include HasUUID
@@ -33,9 +35,6 @@ class Route < ApplicationRecord
belongs_to :endpoint, polymorphic: true, optional: true belongs_to :endpoint, polymorphic: true, optional: true
has_many :additional_route_endpoints, dependent: :destroy has_many :additional_route_endpoints, dependent: :destroy
SPAM_MODES = ["Mark", "Quarantine", "Fail"]
ENDPOINT_TYPES = ["SMTPEndpoint", "HTTPEndpoint", "AddressEndpoint"]
validates :name, presence: true, format: /\A(([a-z0-9\-.]*)|(\*)|(__returnpath__))\z/ validates :name, presence: true, format: /\A(([a-z0-9\-.]*)|(\*)|(__returnpath__))\z/
validates :spam_mode, inclusion: { in: SPAM_MODES } validates :spam_mode, inclusion: { in: SPAM_MODES }
validates :endpoint, presence: { if: proc { mode == "Endpoint" } } validates :endpoint, presence: { if: proc { mode == "Endpoint" } }

عرض الملف

@@ -43,7 +43,8 @@
class Server < ApplicationRecord class Server < ApplicationRecord
RESERVED_PERMALINKS = ["new", "all", "search", "stats", "edit", "manage", "delete", "destroy", "remove"] RESERVED_PERMALINKS = ["new", "all", "search", "stats", "edit", "manage", "delete", "destroy", "remove"].freeze
MODES = ["Live", "Development"].freeze
include HasUUID include HasUUID
include HasSoftDestroy include HasSoftDestroy
@@ -64,8 +65,6 @@ class Server < ApplicationRecord
has_many :track_domains, dependent: :destroy has_many :track_domains, dependent: :destroy
has_many :ip_pool_rules, dependent: :destroy, as: :owner has_many :ip_pool_rules, dependent: :destroy, as: :owner
MODES = ["Live", "Development"]
random_string :token, type: :chars, length: 6, unique: true, upper_letters_only: true random_string :token, type: :chars, length: 6, unique: true, upper_letters_only: true
default_value :permalink, -> { name ? name.parameterize : nil } default_value :permalink, -> { name ? name.parameterize : nil }
default_value :raw_message_retention_days, -> { 30 } default_value :raw_message_retention_days, -> { 30 }

عرض الملف

@@ -26,7 +26,7 @@ class SMTPEndpoint < ApplicationRecord
has_many :routes, as: :endpoint has_many :routes, as: :endpoint
has_many :additional_route_endpoints, dependent: :destroy, as: :endpoint has_many :additional_route_endpoints, dependent: :destroy, as: :endpoint
SSL_MODES = ["None", "Auto", "STARTTLS", "TLS"] SSL_MODES = ["None", "Auto", "STARTTLS", "TLS"].freeze
before_destroy :update_routes before_destroy :update_routes

عرض الملف

@@ -25,7 +25,7 @@ class WebhookEvent < ApplicationRecord
"MessageLinkClicked", "MessageLinkClicked",
"MessageLoaded", "MessageLoaded",
"DomainDNSError" "DomainDNSError"
] ].freeze
belongs_to :webhook belongs_to :webhook

عرض الملف

@@ -21,7 +21,7 @@ class WebhookRequest < ApplicationRecord
include HasUUID include HasUUID
RETRIES = { 1 => 2.minutes, 2 => 3.minutes, 3 => 6.minutes, 4 => 10.minutes, 5 => 15.minutes } RETRIES = { 1 => 2.minutes, 2 => 3.minutes, 3 => 6.minutes, 4 => 10.minutes, 5 => 15.minutes }.freeze
belongs_to :server belongs_to :server
belongs_to :webhook, optional: true belongs_to :webhook, optional: true

عرض الملف

@@ -45,8 +45,8 @@ module Postal
class LogFormatter class LogFormatter
TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%3N".freeze TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%3N"
COLORS = [32, 34, 35, 31, 32, 33] COLORS = [32, 34, 35, 31, 32, 33].freeze
def call(severity, datetime, progname, msg) def call(severity, datetime, progname, msg)
time = datetime.strftime(TIME_FORMAT) time = datetime.strftime(TIME_FORMAT)

عرض الملف

@@ -8,8 +8,8 @@ module Postal
@database = database @database = database
end end
STATS_GAPS = { hourly: :hour, daily: :day, monthly: :month, yearly: :year } STATS_GAPS = { hourly: :hour, daily: :day, monthly: :month, yearly: :year }.freeze
COUNTERS = [:incoming, :outgoing, :spam, :bounces, :held] COUNTERS = [:incoming, :outgoing, :spam, :bounces, :held].freeze
# #
# Increment an appropriate counter # Increment an appropriate counter

عرض الملف

@@ -7,7 +7,7 @@ module Postal
EXCLUSIONS = { EXCLUSIONS = {
outgoing: ["NO_RECEIVED", "NO_RELAYS", "ALL_TRUSTED", "FREEMAIL_FORGED_REPLYTO", "RDNS_DYNAMIC", "CK_HELO_GENERIC", /^SPF_/, /^HELO_/, /DKIM_/, /^RCVD_IN_/], outgoing: ["NO_RECEIVED", "NO_RELAYS", "ALL_TRUSTED", "FREEMAIL_FORGED_REPLYTO", "RDNS_DYNAMIC", "CK_HELO_GENERIC", /^SPF_/, /^HELO_/, /DKIM_/, /^RCVD_IN_/],
incoming: [] incoming: []
} }.freeze
def inspect_message(inspection) def inspect_message(inspection)
data = nil data = nil

عرض الملف

@@ -6,7 +6,7 @@ module Postal
OUR_HOSTNAMES = { OUR_HOSTNAMES = {
smtp: Postal.config.dns.smtp_server_hostname, smtp: Postal.config.dns.smtp_server_hostname,
http: Postal.config.web.host http: Postal.config.web.host
} }.freeze
class << self class << self

عرض الملف

@@ -15,7 +15,7 @@ module Postal
/^>*\s*Sent from my.*/m, /^>*\s*Sent from my.*/m,
/^>*\s*=== Please reply above this line ===.*/m, /^>*\s*=== Please reply above this line ===.*/m,
/(^>.*\n?){10,}/ /(^>.*\n?){10,}/
] ].freeze
def self.separate(text) def self.separate(text)
return "" unless text.is_a?(String) return "" unless text.is_a?(String)