diff --git a/app/models/concerns/has_dns_checks.rb b/app/models/concerns/has_dns_checks.rb index 3147e89..4ec4ad7 100644 --- a/app/models/concerns/has_dns_checks.rb +++ b/app/models/concerns/has_dns_checks.rb @@ -5,7 +5,7 @@ require "resolv" module HasDNSChecks def dns_ok? - spf_status == "OK" && dkim_status == "OK" && ["OK", "Missing"].include?(mx_status) && ["OK", "Missing"].include?(return_path_status) + spf_status == "OK" && dkim_status == "OK" && %w[OK Missing].include?(mx_status) && %w[OK Missing].include?(return_path_status) end def dns_checked? diff --git a/app/models/credential.rb b/app/models/credential.rb index 2c37593..18e3266 100644 --- a/app/models/credential.rb +++ b/app/models/credential.rb @@ -23,7 +23,7 @@ class Credential < ApplicationRecord belongs_to :server - TYPES = ["SMTP", "API", "SMTP-IP"].freeze + TYPES = %w[SMTP API SMTP-IP].freeze validates :key, presence: true, uniqueness: { case_sensitive: false } validates :type, inclusion: { in: TYPES } diff --git a/app/models/domain.rb b/app/models/domain.rb index ba61992..bcfb263 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -44,8 +44,8 @@ class Domain < ApplicationRecord include HasDNSChecks - VERIFICATION_EMAIL_ALIASES = ["webmaster", "postmaster", "admin", "administrator", "hostmaster"].freeze - VERIFICATION_METHODS = ["DNS", "Email"].freeze + VERIFICATION_EMAIL_ALIASES = %w[webmaster postmaster admin administrator hostmaster].freeze + VERIFICATION_METHODS = %w[DNS Email].freeze belongs_to :server, optional: true belongs_to :owner, optional: true, polymorphic: true diff --git a/app/models/http_endpoint.rb b/app/models/http_endpoint.rb index ff33a24..8cd9044 100644 --- a/app/models/http_endpoint.rb +++ b/app/models/http_endpoint.rb @@ -31,8 +31,8 @@ class HTTPEndpoint < ApplicationRecord has_many :routes, as: :endpoint has_many :additional_route_endpoints, dependent: :destroy, as: :endpoint - ENCODINGS = ["BodyAsJSON", "FormData"].freeze - FORMATS = ["Hash", "RawMessage"].freeze + ENCODINGS = %w[BodyAsJSON FormData].freeze + FORMATS = %w[Hash RawMessage].freeze before_destroy :update_routes diff --git a/app/models/organization.rb b/app/models/organization.rb index 57e16cd..60841dc 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -25,7 +25,7 @@ class Organization < ApplicationRecord - RESERVED_PERMALINKS = ["new", "edit", "remove", "delete", "destroy", "admin", "mail", "org", "server"].freeze + RESERVED_PERMALINKS = %w[new edit remove delete destroy admin mail org server].freeze INITIAL_QUOTA = 10 INITIAL_SUPER_QUOTA = 10_000 diff --git a/app/models/route.rb b/app/models/route.rb index cd837d0..9d59f5c 100644 --- a/app/models/route.rb +++ b/app/models/route.rb @@ -24,9 +24,9 @@ class Route < ApplicationRecord - MODES = ["Endpoint", "Accept", "Hold", "Bounce", "Reject"].freeze - SPAM_MODES = ["Mark", "Quarantine", "Fail"].freeze - ENDPOINT_TYPES = ["SMTPEndpoint", "HTTPEndpoint", "AddressEndpoint"].freeze + MODES = %w[Endpoint Accept Hold Bounce Reject].freeze + SPAM_MODES = %w[Mark Quarantine Fail].freeze + ENDPOINT_TYPES = %w[SMTPEndpoint HTTPEndpoint AddressEndpoint].freeze include HasUUID diff --git a/app/models/server.rb b/app/models/server.rb index c2f39a6..e14b53c 100644 --- a/app/models/server.rb +++ b/app/models/server.rb @@ -43,8 +43,8 @@ class Server < ApplicationRecord - RESERVED_PERMALINKS = ["new", "all", "search", "stats", "edit", "manage", "delete", "destroy", "remove"].freeze - MODES = ["Live", "Development"].freeze + RESERVED_PERMALINKS = %w[new all search stats edit manage delete destroy remove].freeze + MODES = %w[Live Development].freeze include HasUUID include HasSoftDestroy diff --git a/app/models/smtp_endpoint.rb b/app/models/smtp_endpoint.rb index 84c40aa..b063f80 100644 --- a/app/models/smtp_endpoint.rb +++ b/app/models/smtp_endpoint.rb @@ -26,7 +26,7 @@ class SMTPEndpoint < ApplicationRecord has_many :routes, as: :endpoint has_many :additional_route_endpoints, dependent: :destroy, as: :endpoint - SSL_MODES = ["None", "Auto", "STARTTLS", "TLS"].freeze + SSL_MODES = %w[None Auto STARTTLS TLS].freeze before_destroy :update_routes diff --git a/app/models/webhook_event.rb b/app/models/webhook_event.rb index a54da56..29295e7 100644 --- a/app/models/webhook_event.rb +++ b/app/models/webhook_event.rb @@ -16,15 +16,15 @@ class WebhookEvent < ApplicationRecord - EVENTS = [ - "MessageSent", - "MessageDelayed", - "MessageDeliveryFailed", - "MessageHeld", - "MessageBounced", - "MessageLinkClicked", - "MessageLoaded", - "DomainDNSError" + EVENTS = %w[ + MessageSent + MessageDelayed + MessageDeliveryFailed + MessageHeld + MessageBounced + MessageLinkClicked + MessageLoaded + DomainDNSError ].freeze belongs_to :webhook diff --git a/lib/postal/message_db/database.rb b/lib/postal/message_db/database.rb index 97376d7..f61ffbe 100644 --- a/lib/postal/message_db/database.rb +++ b/lib/postal/message_db/database.rb @@ -160,7 +160,7 @@ module Postal end if options[:order] direction = (options[:direction] || "ASC").upcase - raise Postal::Error, "Invalid direction #{options[:direction]}" unless ["ASC", "DESC"].include?(direction) + raise Postal::Error, "Invalid direction #{options[:direction]}" unless %w[ASC DESC].include?(direction) sql_query << " ORDER BY `#{options[:order]}` #{direction}" end diff --git a/lib/postal/message_db/provisioner.rb b/lib/postal/message_db/provisioner.rb index 31619db..743bb84 100644 --- a/lib/postal/message_db/provisioner.rb +++ b/lib/postal/message_db/provisioner.rb @@ -70,9 +70,9 @@ module Postal # environment and can be quite dangerous in production. # def clean - ["clicks", "deliveries", "links", "live_stats", "loads", "messages", - "raw_message_sizes", "spam_checks", "stats_daily", "stats_hourly", - "stats_monthly", "stats_yearly", "suppressions", "webhook_requests"].each do |table| + %w[clicks deliveries links live_stats loads messages + raw_message_sizes spam_checks stats_daily stats_hourly + stats_monthly stats_yearly suppressions webhook_requests].each do |table| @database.query("TRUNCATE `#{@database.database_name}`.`#{table}`") end end