مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2026-01-18 13:59:47 +00:00
Consistently treat tinyint(1) fields in message database as booleans (#2380)
* Update mysql2 query call to cast booleans * Treat messages:held field as boolean * Treat messages:inspected field as boolean * Treat messages:spam field as boolean * Treat messages:threat field as boolean * Treat messages:bounce field as boolean * Treat messages:received_with_ssl field as boolean * Treat deliveries:sent_with_ssl field as boolean
هذا الالتزام موجود في:
ملتزم من قبل
GitHub
الأصل
87e9b3e346
التزام
1e3622c49a
@@ -24,7 +24,7 @@ module Postal
|
||||
message.mail_from = @message.route.description
|
||||
message.domain_id = @message.domain&.id
|
||||
message.raw_message = raw_message
|
||||
message.bounce = 1
|
||||
message.bounce = true
|
||||
message.bounce_for_id = @message.id
|
||||
message.save
|
||||
message.id
|
||||
|
||||
@@ -74,8 +74,8 @@ module Postal
|
||||
timestamp: message.timestamp.to_f,
|
||||
size: message.size,
|
||||
spam_status: message.spam_status,
|
||||
bounce: message.bounce == 1,
|
||||
received_with_ssl: message.received_with_ssl == 1,
|
||||
bounce: message.bounce,
|
||||
received_with_ssl: message.received_with_ssl,
|
||||
to: message.headers["to"]&.last,
|
||||
cc: message.headers["cc"]&.last,
|
||||
from: message.headers["from"]&.last,
|
||||
|
||||
@@ -316,7 +316,7 @@ module Postal
|
||||
|
||||
def query_on_connection(connection, query)
|
||||
start_time = Time.now.to_f
|
||||
result = connection.query(query)
|
||||
result = connection.query(query, cast_booleans: true)
|
||||
time = Time.now.to_f - start_time
|
||||
logger.debug " \e[4;34mMessageDB Query (#{time.round(2)}s) \e[0m \e[33m#{query}\e[0m"
|
||||
if time > 0.5 && query =~ /\A(SELECT|UPDATE|DELETE) /
|
||||
|
||||
@@ -123,7 +123,7 @@ module Postal
|
||||
def create_delivery(status, options = {})
|
||||
delivery = Delivery.create(self, options.merge(status: status))
|
||||
hold_expiry = status == "Held" ? Postal.config.general.maximum_hold_expiry_days.days.from_now.to_f : nil
|
||||
update(status: status, last_delivery_attempt: delivery.timestamp.to_f, held: status == "Held" ? 1 : 0, hold_expiry: hold_expiry)
|
||||
update(status: status, last_delivery_attempt: delivery.timestamp.to_f, held: status == "Held", hold_expiry: hold_expiry)
|
||||
delivery
|
||||
end
|
||||
|
||||
@@ -371,9 +371,9 @@ module Postal
|
||||
# Return the spam status
|
||||
#
|
||||
def spam_status
|
||||
return "NotChecked" unless inspected == 1
|
||||
return "NotChecked" unless inspected
|
||||
|
||||
spam == 1 ? "Spam" : "NotSpam"
|
||||
spam ? "Spam" : "NotSpam"
|
||||
end
|
||||
|
||||
#
|
||||
@@ -445,7 +445,7 @@ module Postal
|
||||
# Should bounces be sent for this message?
|
||||
#
|
||||
def send_bounces?
|
||||
bounce != 1 && mail_from.present?
|
||||
!bounce && mail_from.present?
|
||||
end
|
||||
|
||||
#
|
||||
@@ -471,7 +471,7 @@ module Postal
|
||||
# Return a message object that this message is a reply to
|
||||
#
|
||||
def original_messages
|
||||
return nil unless bounce == 1
|
||||
return nil unless bounce
|
||||
|
||||
other_message_ids = raw_message.scan(/\X-Postal-MsgID:\s*([a-z0-9]+)/i).flatten
|
||||
if other_message_ids.empty?
|
||||
@@ -495,7 +495,7 @@ module Postal
|
||||
result = MessageInspection.scan(self, scope&.to_sym)
|
||||
|
||||
# Update the messages table with the results of our inspection
|
||||
update(inspected: 1, spam_score: result.spam_score, threat: result.threat?, threat_details: result.threat_message)
|
||||
update(inspected: true, spam_score: result.spam_score, threat: result.threat, threat_details: result.threat_message)
|
||||
|
||||
# Add any spam details into the spam checks database
|
||||
database.insert_multi(:spam_checks, [:message_id, :code, :score, :description], result.spam_checks.map { |d| [id, d.code, d.score, d.description] })
|
||||
|
||||
@@ -20,10 +20,6 @@ module Postal
|
||||
@spam_checks.sum(&:score)
|
||||
end
|
||||
|
||||
def threat?
|
||||
@threat == true
|
||||
end
|
||||
|
||||
def scan
|
||||
MessageInspector.inspectors.each do |inspector|
|
||||
inspector.inspect_message(self)
|
||||
|
||||
@@ -133,7 +133,7 @@ module Postal
|
||||
end
|
||||
|
||||
begin
|
||||
if message.bounce == 1
|
||||
if message.bounce
|
||||
mail_from = ""
|
||||
elsif message.domain.return_path_status == "OK"
|
||||
mail_from = "#{message.server.token}@#{message.domain.return_path_domain}"
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم