مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-11-30 21:32:30 +00:00
style(rubocop): Lint/ShadowingOuterLocalVariable
هذا الالتزام موجود في:
21
.rubocop.yml
21
.rubocop.yml
@@ -118,17 +118,6 @@ Lint/BooleanSymbol:
|
||||
Style/SymbolProc:
|
||||
Enabled: false
|
||||
|
||||
# Excluding specs from block lengths
|
||||
Metrics/BlockLength:
|
||||
Exclude:
|
||||
- "spec/**/*.rb"
|
||||
- "db/schema.rb"
|
||||
- "db/migrate/**/*.rb"
|
||||
- "lib/tasks/auto_annotate_models.rake"
|
||||
- "config/routes.rb"
|
||||
- "lib/tasks/*.rake"
|
||||
- "app/apis/core_api/base.rb"
|
||||
|
||||
Metrics/ModuleLength:
|
||||
Exclude:
|
||||
- "spec/factories/**/*.rb"
|
||||
@@ -150,10 +139,6 @@ Style/MultilineBlockChain:
|
||||
Exclude:
|
||||
- "spec/**/*.rb"
|
||||
|
||||
# Increase class lengths to a more reasonable place
|
||||
Metrics/ClassLength:
|
||||
Max: 250
|
||||
|
||||
Metrics/AbcSize:
|
||||
Enabled: false
|
||||
|
||||
@@ -188,3 +173,9 @@ Metrics/BlockNesting:
|
||||
|
||||
Style/StringConcatenation:
|
||||
Enabled: false
|
||||
|
||||
Metrics/BlockLength:
|
||||
Enabled: false
|
||||
|
||||
Metrics/ClassLength:
|
||||
Enabled: false
|
||||
|
||||
@@ -6,7 +6,7 @@ class SendWebhookJob < Postal::Job
|
||||
if server = Server.find(params["server_id"])
|
||||
new_items = {}
|
||||
if params["payload"]
|
||||
for key, value in params["payload"]
|
||||
params["payload"].each do |key, value|
|
||||
next unless key.to_s =~ /\A_(\w+)/
|
||||
|
||||
begin
|
||||
|
||||
@@ -424,7 +424,7 @@ class UnqueueMessageJob < Postal::Job
|
||||
end
|
||||
rescue StandardError => e
|
||||
log "#{log_prefix} Internal error: #{e.class}: #{e.message}"
|
||||
e.backtrace.each { |e| log("#{log_prefix} #{e}") }
|
||||
e.backtrace.each { |line| log("#{log_prefix} #{line}") }
|
||||
queued_message.retry_later
|
||||
log "#{log_prefix} Queued message was unlocked"
|
||||
if defined?(Sentry)
|
||||
|
||||
@@ -245,7 +245,7 @@ module Postal
|
||||
sql_query = "INSERT INTO `#{database_name}`.`#{table}`"
|
||||
sql_query << (" (" + keys.map { |k| "`#{k}`" }.join(", ") + ")")
|
||||
sql_query << " VALUES "
|
||||
sql_query << values.map { |v| "(" + v.map { |v| escape(v) }.join(", ") + ")" }.join(", ")
|
||||
sql_query << values.map { |v| "(" + v.map { |r| escape(r) }.join(", ") + ")" }.join(", ")
|
||||
query(sql_query)
|
||||
end
|
||||
end
|
||||
@@ -295,8 +295,8 @@ module Postal
|
||||
end
|
||||
|
||||
def stringify_keys(hash)
|
||||
hash.each_with_object({}) do |(key, value), hash|
|
||||
hash[key.to_s] = value
|
||||
hash.each_with_object({}) do |(key, value), h|
|
||||
h[key.to_s] = value
|
||||
end
|
||||
end
|
||||
|
||||
@@ -365,16 +365,16 @@ module Postal
|
||||
"`#{key}` IN (#{escaped_values})"
|
||||
elsif value.is_a?(Hash)
|
||||
sql = []
|
||||
value.each do |operator, value|
|
||||
value.each do |operator, inner_value|
|
||||
case operator
|
||||
when :less_than
|
||||
sql << "`#{key}` < #{escape(value)}"
|
||||
sql << "`#{key}` < #{escape(inner_value)}"
|
||||
when :greater_than
|
||||
sql << "`#{key}` > #{escape(value)}"
|
||||
sql << "`#{key}` > #{escape(inner_value)}"
|
||||
when :less_than_or_equal_to
|
||||
sql << "`#{key}` <= #{escape(value)}"
|
||||
sql << "`#{key}` <= #{escape(inner_value)}"
|
||||
when :greater_than_or_equal_to
|
||||
sql << "`#{key}` >= #{escape(value)}"
|
||||
sql << "`#{key}` >= #{escape(inner_value)}"
|
||||
end
|
||||
end
|
||||
sql.empty? ? "1=1" : sql.join(joiner)
|
||||
|
||||
@@ -8,7 +8,7 @@ module Postal
|
||||
class Client
|
||||
|
||||
CRAM_MD5_DIGEST = OpenSSL::Digest.new("md5")
|
||||
LOG_REDACTION_STRING = "[redacted]".freeze
|
||||
LOG_REDACTION_STRING = "[redacted]"
|
||||
|
||||
attr_reader :logging_enabled
|
||||
|
||||
@@ -158,10 +158,10 @@ module Postal
|
||||
end
|
||||
|
||||
def auth_plain(data)
|
||||
handler = proc do |data|
|
||||
handler = proc do |idata|
|
||||
@proc = nil
|
||||
data = Base64.decode64(data)
|
||||
parts = data.split("\0")
|
||||
idata = Base64.decode64(idata)
|
||||
parts = idata.split("\0")
|
||||
username = parts[-2]
|
||||
password = parts[-1]
|
||||
unless username && password
|
||||
@@ -182,9 +182,9 @@ module Postal
|
||||
end
|
||||
|
||||
def auth_login(data)
|
||||
password_handler = proc do |data|
|
||||
password_handler = proc do |idata|
|
||||
@proc = nil
|
||||
password = Base64.decode64(data)
|
||||
password = Base64.decode64(idata)
|
||||
authenticate(password)
|
||||
end
|
||||
|
||||
@@ -217,9 +217,9 @@ module Postal
|
||||
challenge = Digest::SHA1.hexdigest(Time.now.to_i.to_s + rand(100_000).to_s)
|
||||
challenge = "<#{challenge[0, 20]}@#{Postal.config.dns.smtp_server_hostname}>"
|
||||
|
||||
handler = proc do |data|
|
||||
handler = proc do |idata|
|
||||
@proc = nil
|
||||
username, password = Base64.decode64(data).split(" ", 2).map { |a| a.chomp }
|
||||
username, password = Base64.decode64(idata).split(" ", 2).map { |a| a.chomp }
|
||||
org_permlink, server_permalink = username.split(/[\/_]/, 2)
|
||||
server = ::Server.includes(:organization).where(organizations: { permalink: org_permlink }, permalink: server_permalink).first
|
||||
if server.nil?
|
||||
@@ -357,7 +357,7 @@ module Postal
|
||||
end
|
||||
end
|
||||
|
||||
def data(data)
|
||||
def data(_data)
|
||||
unless in_state(:rcpt_to_received)
|
||||
return "503 HELO/EHLO, MAIL FROM and RCPT TO before sending data"
|
||||
end
|
||||
@@ -372,13 +372,13 @@ module Postal
|
||||
@data << "Received: #{received_header}\r\n"
|
||||
@headers["received"] = [received_header]
|
||||
|
||||
handler = proc do |data|
|
||||
if data == "."
|
||||
handler = proc do |idata|
|
||||
if idata == "."
|
||||
@logging_enabled = true
|
||||
@proc = nil
|
||||
finished
|
||||
else
|
||||
data = data.to_s.sub(/\A\.\./, ".")
|
||||
idata = idata.to_s.sub(/\A\.\./, ".")
|
||||
|
||||
if @credential && @credential.server.log_smtp_data?
|
||||
# We want to log if enabled
|
||||
@@ -388,20 +388,20 @@ module Postal
|
||||
end
|
||||
|
||||
if @receiving_headers
|
||||
if data.blank?
|
||||
if idata.blank?
|
||||
@receiving_headers = false
|
||||
elsif data.to_s =~ /^\s/
|
||||
elsif idata.to_s =~ /^\s/
|
||||
# This is a continuation of a header
|
||||
if @header_key && @headers[@header_key.downcase] && @headers[@header_key.downcase].last
|
||||
@headers[@header_key.downcase].last << data.to_s
|
||||
@headers[@header_key.downcase].last << idata.to_s
|
||||
end
|
||||
else
|
||||
@header_key, value = data.split(/:\s*/, 2)
|
||||
@header_key, value = idata.split(/:\s*/, 2)
|
||||
@headers[@header_key.downcase] ||= []
|
||||
@headers[@header_key.downcase] << value
|
||||
end
|
||||
end
|
||||
@data << data
|
||||
@data << idata
|
||||
@data << "\r\n"
|
||||
nil
|
||||
end
|
||||
@@ -453,11 +453,11 @@ module Postal
|
||||
when :bounce
|
||||
if rp_route = server.routes.where(name: "__returnpath__").first
|
||||
# If there's a return path route, we can use this to create the message
|
||||
rp_route.create_messages do |message|
|
||||
message.rcpt_to = rcpt_to
|
||||
message.mail_from = @mail_from
|
||||
message.raw_message = @data
|
||||
message.received_with_ssl = @tls
|
||||
rp_route.create_messages do |msg|
|
||||
msg.rcpt_to = rcpt_to
|
||||
msg.mail_from = @mail_from
|
||||
msg.raw_message = @data
|
||||
msg.received_with_ssl = @tls
|
||||
end
|
||||
else
|
||||
# There's no return path route, we just need to insert the mesage
|
||||
|
||||
@@ -188,10 +188,10 @@ module Postal
|
||||
next if result.nil?
|
||||
|
||||
result = [result] unless result.is_a?(Array)
|
||||
result.compact.each do |line|
|
||||
client.log "\e[34m=> #{line.strip}\e[0m"
|
||||
result.compact.each do |iline|
|
||||
client.log "\e[34m=> #{iline.strip}\e[0m"
|
||||
begin
|
||||
io.write(line.to_s + "\r\n")
|
||||
io.write(iline.to_s + "\r\n")
|
||||
io.flush
|
||||
rescue Errno::ECONNRESET
|
||||
# Client disconnected before we could write response
|
||||
@@ -238,8 +238,8 @@ module Postal
|
||||
end
|
||||
logger.error "[#{client_id}] An error occurred while processing data from a client."
|
||||
logger.error "[#{client_id}] #{e.class}: #{e.message}"
|
||||
e.backtrace.each do |line|
|
||||
logger.error "[#{client_id}] #{line}"
|
||||
e.backtrace.each do |iline|
|
||||
logger.error "[#{client_id}] #{iline}"
|
||||
end
|
||||
# Close all IO and forget this client
|
||||
begin
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم