1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-11-30 21:32:30 +00:00

style(rubocop): remaining offences

هذا الالتزام موجود في:
Adam Cooke
2024-02-10 23:51:09 +00:00
الأصل c6326a6524
التزام ec636661d5
19 ملفات معدلة مع 49 إضافات و44 حذوفات

عرض الملف

@@ -11,8 +11,10 @@ require_relative "version"
module Postal
# rubocop:disable Lint/EmptyClass
class Config
end
# rubocop:enable Lint/EmptyClass
def self.host
@host ||= config.web.host || "localhost:5000"

عرض الملف

@@ -34,14 +34,14 @@ module Postal
def normalized_headers
[].tap do |new_headers|
dkim_headers = headers.select { |h|
h.match(%r{
dkim_headers = headers.select do |h|
h.match(/
^(
from|sender|reply-to|subject|date|message-id|to|cc|mime-version|content-type|content-transfer-encoding|
resent-to|resent-cc|resent-from|resent-sender|resent-message-id|in-reply-to|references|list-id|list-help|
list-owner|list-unsubscribe|list-subscribe|list-post
):}ix)
}
):/ix)
end
dkim_headers.each do |h|
new_headers << normalize_header(h)
end

عرض الملف

@@ -2,10 +2,24 @@
module Postal
module Errors
end
class Error < StandardError
end
module Errors
class AuthenticationError < Error
attr_reader :error
def initialize(error)
super()
@error = error
end
def to_s
"Authentication Failed: #{@error}"
end
end
end
end

عرض الملف

@@ -27,7 +27,7 @@ module Postal
log "Sending request to #{@endpoint.url}"
response = Postal::HTTP.post(@endpoint.url, request_options)
result.secure = !!response[:secure]
result.secure = !!response[:secure] # rubocop:disable Style/DoubleNegation
result.details = "Received a #{response[:code]} from #{@endpoint.url}"
log " -> Received: #{response[:code]}"
if response[:body]

عرض الملف

@@ -295,9 +295,7 @@ module Postal
end
def stringify_keys(hash)
hash.each_with_object({}) do |(key, value), h|
h[key.to_s] = value
end
hash.transform_keys(&:to_s)
end
def escape(value)

عرض الملف

@@ -61,6 +61,7 @@ module Postal
}
end
# rubocop:disable Style/HashLikeCase
def webhook_event
@webhook_event ||= case status
when "Sent" then "MessageSent"
@@ -69,6 +70,7 @@ module Postal
when "Held" then "MessageHeld"
end
end
# rubocop:enable Style/HashLikeCase
end
end

عرض الملف

@@ -32,7 +32,7 @@ module Postal
raise Postal::Error, "You must provide at least one type to return" if options[:types].empty?
time = minutes.minutes.ago.beginning_of_minute.utc.to_f
types = options[:types].map { |t| "#{@database.escape(t.to_s)}" }.join(", ")
types = options[:types].map { |t| @database.escape(t.to_s) }.join(", ")
result = @database.query("SELECT SUM(count) as count FROM `#{@database.database_name}`.`live_stats` WHERE `type` IN (#{types}) AND timestamp > #{time}").first
result["count"] || 0
end

عرض الملف

@@ -56,7 +56,7 @@ module Postal
response = nil
begin
response = http.request(request)
rescue Exception => e
rescue StandardError => e
logger.error "Error talking to rspamd: #{e.class} (#{e.message})"
logger.error e.backtrace[0, 5]

عرض الملف

@@ -63,15 +63,16 @@ module Postal
def parse_parts(parts)
parts.each do |part|
if part.content_type =~ /text\/html/
case part.content_type
when /text\/html/
part.body = parse(part.body.decoded.dup, :html)
part.content_transfer_encoding = nil
part.charset = "UTF-8"
elsif part.content_type =~ /text\/plain/
when /text\/plain/
part.body = parse(part.body.decoded.dup, :text)
part.content_transfer_encoding = nil
part.charset = "UTF-8"
elsif part.content_type =~ /multipart\/(alternative|related)/
when /multipart\/(alternative|related)/
unless part.parts.empty?
parse_parts(part.parts)
end

عرض الملف

@@ -65,8 +65,6 @@ module Postal
smtp_client.enable_starttls(self.class.ssl_context_with_verify)
when "TLS"
smtp_client.enable_tls(self.class.ssl_context_with_verify)
else
# Nothing
end
smtp_client.start(@source_ip_address ? @source_ip_address.hostname : self.class.default_helo_hostname)

عرض الملف

@@ -309,7 +309,7 @@ module Postal
"550 Route does not accept incoming messages"
else
log "Added route #{route.id} to recipients (tag: #{tag.inspect})"
actual_rcpt_to = "#{route.name}" + (tag ? "+#{tag}" : "") + "@#{route.domain.name}"
actual_rcpt_to = "#{route.name}#{tag ? "+#{tag}" : ''}@#{route.domain.name}"
@recipients << [:route, actual_rcpt_to, route.server, { route: route }]
"250 OK"
end
@@ -415,7 +415,7 @@ module Postal
if @data.bytesize > Postal.config.smtp_server.max_message_size.megabytes.to_i
transaction_reset
@state = :welcomed
return "552 Message too large (maximum size %dMB)" % Postal.config.smtp_server.max_message_size
return format("552 Message too large (maximum size %dMB)", Postal.config.smtp_server.max_message_size)
end
if @headers["received"].grep(/by #{Postal.config.dns.smtp_server_hostname}/).count > 4

عرض الملف

@@ -39,7 +39,7 @@ module Postal
@ssl_context ||= begin
ssl_context = OpenSSL::SSL::SSLContext.new
ssl_context.cert = Postal.smtp_certificates[0]
ssl_context.extra_chain_cert = Postal.smtp_certificates[1..-1]
ssl_context.extra_chain_cert = Postal.smtp_certificates[1..]
ssl_context.key = Postal.smtp_private_key
ssl_context.ssl_version = Postal.config.smtp_server.ssl_version if Postal.config.smtp_server.ssl_version
ssl_context.ciphers = Postal.config.smtp_server.tls_ciphers if Postal.config.smtp_server.tls_ciphers