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

fix: use utc timestamps when determining raw table names

هذا الالتزام موجود في:
Adam Cooke
2024-02-01 16:41:41 +00:00
الأصل 8794a2f447
التزام ce19bf7988
3 ملفات معدلة مع 4 إضافات و4 حذوفات

عرض الملف

@@ -107,7 +107,7 @@ module Postal
#
# Insert a new raw message into a table (creating it if needed)
#
def insert_raw_message(data, date = Date.today)
def insert_raw_message(data, date = Time.now.utc.to_date)
table_name = raw_table_name_for_date(date)
begin
headers, body = data.split(/\r?\n\r?\n/, 2)

عرض الملف

@@ -263,7 +263,7 @@ module Postal
return unless @pending_raw_message
self.size = @pending_raw_message.bytesize
date = Date.today
date = Time.now.utc.to_date
table_name, headers_id, body_id = @database.insert_raw_message(@pending_raw_message, date)
self.raw_table = table_name
self.raw_headers_id = headers_id

عرض الملف

@@ -94,7 +94,7 @@ module Postal
# Return a list of raw message tables that are older than the given date
#
def raw_tables(max_age = 30)
earliest_date = max_age ? Date.today - max_age : nil
earliest_date = max_age ? Time.now.utc.to_date - max_age : nil
[].tap do |tables|
@database.query("SHOW TABLES FROM `#{@database.database_name}` LIKE 'raw-%'").each do |tbl|
tbl_name = tbl.to_a.first.last
@@ -128,7 +128,7 @@ module Postal
#  Remove messages from the messages table that are too old to retain
#
def remove_messages(max_age = 60)
time = (Date.today - max_age.days).to_time.end_of_day
time = (Time.now.utc.to_date - max_age.days).to_time.end_of_day
return unless newest_message_to_remove = @database.select(:messages, where: { timestamp: { less_than_or_equal_to: time.to_f } }, limit: 1, order: :id, direction: "DESC", fields: [:id]).first
id = newest_message_to_remove["id"]