From ad0ad73b0cde623801c6ee0081e37df1d2a38bf1 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 25 Jun 2024 13:09:48 +1000 Subject: [PATCH] Fix date being used in mail packets, timezone was effectively being to a timestamp with the timezone already --- app/Classes/FTN/Message.php | 4 ++-- app/Console/Commands/PacketInfo.php | 4 ++-- app/Notifications/Echomails/Test.php | 4 ++-- app/Notifications/Netmails/EchoareaNoWrite.php | 2 +- app/Notifications/Netmails/EchoareaNotExist.php | 2 +- app/Notifications/Netmails/EchoareaNotSubscribed.php | 2 +- app/Notifications/Netmails/EchomailBadAddress.php | 2 +- app/Notifications/Netmails/NetmailHubNoUser.php | 2 +- app/Notifications/Netmails/Ping.php | 4 ++-- app/Traits/MessageAttributes.php | 4 +++- app/Traits/MessagePath.php | 2 +- 11 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/Classes/FTN/Message.php b/app/Classes/FTN/Message.php index 695c975..dbbce2b 100644 --- a/app/Classes/FTN/Message.php +++ b/app/Classes/FTN/Message.php @@ -497,7 +497,7 @@ class Message extends FTNBase $this->mo->tftn->host_id, // Destination Net $this->mo->flags&~(self::FLAG_INTRANSIT|self::FLAG_LOCAL), // Turn off our local/intransit bits $this->mo->cost, - $this->mo->date->format('d M y H:i:s'), + $this->mo->datetime->format('d M y H:i:s'), ); $return .= $this->mo->to."\00"; @@ -523,7 +523,7 @@ class Message extends FTNBase $return .= sprintf("AREA:%s\r",strtoupper($this->mo->echoarea->name)); // Add some kludges - $return .= sprintf("\01TZUTC: %s\r",str_replace('+','',$this->mo->date->getOffsetString(''))); + $return .= sprintf("\01TZUTC: %s\r",str_replace('+','',$this->mo->datetime->getOffsetString(''))); if ($this->mo->msgid) $return .= sprintf("\01MSGID: %s\r",$this->mo->msgid); diff --git a/app/Console/Commands/PacketInfo.php b/app/Console/Commands/PacketInfo.php index dad84fe..b164464 100644 --- a/app/Console/Commands/PacketInfo.php +++ b/app/Console/Commands/PacketInfo.php @@ -97,7 +97,7 @@ class PacketInfo extends Command } foreach ($pkt->errors as $msg) { - $this->error(sprintf('- Date: %s',$msg->date)); + $this->error(sprintf('- Date: %s',$msg->datetime)); $this->error(sprintf(' - FLAGS: %s',$msg->flags()->filter()->keys()->join(', '))); $this->error(sprintf(' - From: %s (%s)',$msg->from,$msg->fftn)); $this->error(sprintf(' - To: %s (%s)',$msg->to,$msg->tftn)); @@ -112,4 +112,4 @@ class PacketInfo extends Command return self::SUCCESS; } -} +} \ No newline at end of file diff --git a/app/Notifications/Echomails/Test.php b/app/Notifications/Echomails/Test.php index fd19a42..af11013 100644 --- a/app/Notifications/Echomails/Test.php +++ b/app/Notifications/Echomails/Test.php @@ -62,8 +62,8 @@ class Test extends Echomails $msg->addText( sprintf("Your test was received here on %s and it looks like you sent it on %s. If that is correct, then it took %s to get here.\r\r", Carbon::now()->utc()->toDateTimeString(), - $this->mo->date->utc()->toDateTimeString(), - $this->mo->date->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE]) + $this->mo->datetime->utc()->toDateTimeString(), + $this->mo->datetime->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE]) ) ); diff --git a/app/Notifications/Netmails/EchoareaNoWrite.php b/app/Notifications/Netmails/EchoareaNoWrite.php index d599b09..a738b78 100644 --- a/app/Notifications/Netmails/EchoareaNoWrite.php +++ b/app/Notifications/Netmails/EchoareaNoWrite.php @@ -53,7 +53,7 @@ class EchoareaNoWrite extends Netmails $this->mo->msgid, $this->mo->to, Carbon::now()->utc()->toDateTimeString(), - $this->mo->date->utc()->toDateTimeString(), + $this->mo->datetime->utc()->toDateTimeString(), ) ); diff --git a/app/Notifications/Netmails/EchoareaNotExist.php b/app/Notifications/Netmails/EchoareaNotExist.php index 30b7ffa..07d8e04 100644 --- a/app/Notifications/Netmails/EchoareaNotExist.php +++ b/app/Notifications/Netmails/EchoareaNotExist.php @@ -55,7 +55,7 @@ class EchoareaNotExist extends Netmails $this->mo->msgid, $this->mo->to, Carbon::now()->utc()->toDateTimeString(), - $this->mo->date->utc()->toDateTimeString(), + $this->mo->datetime->utc()->toDateTimeString(), ) ); diff --git a/app/Notifications/Netmails/EchoareaNotSubscribed.php b/app/Notifications/Netmails/EchoareaNotSubscribed.php index 3f0ac04..02cf6a0 100644 --- a/app/Notifications/Netmails/EchoareaNotSubscribed.php +++ b/app/Notifications/Netmails/EchoareaNotSubscribed.php @@ -53,7 +53,7 @@ class EchoareaNotSubscribed extends Netmails $this->mo->msgid, $this->mo->to, Carbon::now()->utc()->toDateTimeString(), - $this->mo->date->utc()->toDateTimeString(), + $this->mo->datetime->utc()->toDateTimeString(), ) ); diff --git a/app/Notifications/Netmails/EchomailBadAddress.php b/app/Notifications/Netmails/EchomailBadAddress.php index 6b38d3d..a9d0711 100644 --- a/app/Notifications/Netmails/EchomailBadAddress.php +++ b/app/Notifications/Netmails/EchomailBadAddress.php @@ -53,7 +53,7 @@ class EchomailBadAddress extends Netmails $this->mo->msgid, $this->mo->to, Carbon::now()->utc()->toDateTimeString(), - $this->mo->date->utc()->toDateTimeString(), + $this->mo->datetime->utc()->toDateTimeString(), ) ); diff --git a/app/Notifications/Netmails/NetmailHubNoUser.php b/app/Notifications/Netmails/NetmailHubNoUser.php index 0fec377..30629b6 100644 --- a/app/Notifications/Netmails/NetmailHubNoUser.php +++ b/app/Notifications/Netmails/NetmailHubNoUser.php @@ -55,7 +55,7 @@ class NetmailHubNoUser extends Netmails $this->mo->msgid, $this->mo->to, Carbon::now()->utc()->toDateTimeString(), - $this->mo->date->utc()->toDateTimeString(), + $this->mo->datetime->utc()->toDateTimeString(), ) ); diff --git a/app/Notifications/Netmails/Ping.php b/app/Notifications/Netmails/Ping.php index 38c327e..7230e96 100644 --- a/app/Notifications/Netmails/Ping.php +++ b/app/Notifications/Netmails/Ping.php @@ -55,8 +55,8 @@ class Ping extends Netmails $msg->addText( sprintf("Your ping was received here on %s and it looks like you sent it on %s. If that is correct, then it took %s to get here.\r\r", Carbon::now()->utc()->toDateTimeString(), - $this->mo->date->utc()->toDateTimeString(), - $this->mo->date->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE]) + $this->mo->datetime->utc()->toDateTimeString(), + $this->mo->datetime->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE]) ) ); diff --git a/app/Traits/MessageAttributes.php b/app/Traits/MessageAttributes.php index bc5becd..c9f49d0 100644 --- a/app/Traits/MessageAttributes.php +++ b/app/Traits/MessageAttributes.php @@ -59,9 +59,11 @@ trait MessageAttributes return ($this->msg_src) ? $this->msg_src : $this->rebuildMessage(); } + /** @deprecated use datetime? */ public function getDateAttribute(): Carbon { - return $this->datetime->utcOffset($this->tzoffset); + Log::alert(sprintf('%s:! This function is deprecated',self::LOGKEY),['class'=>get_class($this)]); + return $this->datetime; } public function getOriginAttribute(string $val=NULL): ?string diff --git a/app/Traits/MessagePath.php b/app/Traits/MessagePath.php index 946775f..c8d7687 100644 --- a/app/Traits/MessagePath.php +++ b/app/Traits/MessagePath.php @@ -19,7 +19,7 @@ trait MessagePath $reply .= str_replace("\r---","\r#--",$mo->msg)."\r"; $reply .= "+------------------------------------[ CONTROL LINES ]-+\r"; - $reply .= sprintf("DATE: %s\r",$mo->date->format('Y-m-d H:i:s')); + $reply .= sprintf("DATE: %s\r",$mo->datetime->format('Y-m-d H:i:s')); if ($mo->msgid) $reply .= sprintf("MSGID: %s\r",$mo->msgid); if ($mo->replyid)