Store datetime in UTC format now, and fix presentation of TZUTC. Also standardise message summaries on Notifications
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 42s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m51s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s

This commit is contained in:
Deon George 2024-06-28 23:27:06 +10:00
parent fc930ba6c2
commit 4d7af7c7e3
17 changed files with 51 additions and 58 deletions

View File

@ -233,7 +233,7 @@ class Message extends FTNBase
$o->mo->from = $o->header['user_from']; $o->mo->from = $o->header['user_from'];
$o->mo->subject = $o->header['subject']; $o->mo->subject = $o->header['subject'];
$o->mo->datetime = $o->datetime; $o->mo->datetime = $o->datetime->clone()->utc();
$o->mo->tzoffset = $o->datetime->utcOffset(); $o->mo->tzoffset = $o->datetime->utcOffset();
$o->mo->flags = $o->header['flags']; $o->mo->flags = $o->header['flags'];
$o->mo->cost = $o->header['cost']; $o->mo->cost = $o->header['cost'];

View File

@ -361,7 +361,7 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
$this->content .= "\00\00"; $this->content .= "\00\00";
$this->messages = $msgs->map(fn($item)=>$item->only(['id','datetime'])); $this->messages = $msgs->map(fn($item)=>$item->only(['id','date']));
return $this; return $this;
} }

View File

@ -65,7 +65,7 @@ final class FSC39 extends Packet
*/ */
protected function header(Collection $msgs): string protected function header(Collection $msgs): string
{ {
$oldest = $this->messages->sortBy('datetime')->last(); $oldest = $this->messages->sortBy('date')->last();
return pack(collect(self::HEADER)->pluck(1)->join(''), return pack(collect(self::HEADER)->pluck(1)->join(''),
$this->fftn_p->node_id, // Orig Node $this->fftn_p->node_id, // Orig Node

View File

@ -65,7 +65,7 @@ final class FSC48 extends Packet
*/ */
protected function header(Collection $msgs): string protected function header(Collection $msgs): string
{ {
$oldest = $msgs->sortBy('datetime')->last(); $oldest = $msgs->sortBy('date')->last();
return pack(collect(self::HEADER)->pluck(1)->join(''), return pack(collect(self::HEADER)->pluck(1)->join(''),
$this->fftn_p->node_id, // Orig Node $this->fftn_p->node_id, // Orig Node

View File

@ -116,6 +116,6 @@ final class Mail extends Send
private function youngest(): Carbon private function youngest(): Carbon
{ {
return $this->f->messages->pluck('datetime')->sort()->last(); return $this->f->messages->pluck('date')->sort()->last();
} }
} }

View File

@ -68,7 +68,7 @@ class PacketInfo extends Command
echo "\n"; echo "\n";
try { try {
$this->warn(sprintf('- Date : %s (%s)',$msg->datetime,$msg->datetime->tz->toOffsetName())); $this->warn(sprintf('- Date : %s (%s)',$msg->date,$msg->date->tz->toOffsetName()));
$this->warn(sprintf(' - Errors : %s',$msg->errors->count() ? 'YES' : 'No')); $this->warn(sprintf(' - Errors : %s',$msg->errors->count() ? 'YES' : 'No'));
$this->warn(sprintf(' - Flags : %s',$msg->flags()->keys()->join(', '))); $this->warn(sprintf(' - Flags : %s',$msg->flags()->keys()->join(', ')));
$this->warn(sprintf(' - Cost : %d',$msg->cost)); $this->warn(sprintf(' - Cost : %d',$msg->cost));
@ -97,7 +97,7 @@ class PacketInfo extends Command
} }
foreach ($pkt->errors as $msg) { 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(' - FLAGS: %s',$msg->flags()->filter()->keys()->join(', ')));
$this->error(sprintf(' - From: %s (%s)',$msg->from,$msg->fftn)); $this->error(sprintf(' - From: %s (%s)',$msg->from,$msg->fftn));
$this->error(sprintf(' - To: %s (%s)',$msg->to,$msg->tftn)); $this->error(sprintf(' - To: %s (%s)',$msg->to,$msg->tftn));

View File

@ -228,16 +228,18 @@ class MessageProcess implements ShouldQueue
if ($this->mo->msgid) { if ($this->mo->msgid) {
$o = Echomail::where('msgid',$this->mo->msgid) $o = Echomail::where('msgid',$this->mo->msgid)
->where('fftn_id',$this->mo->fftn->id) ->where('fftn_id',$this->mo->fftn->id)
->where('datetime','>=',$this->mo->date->subYears(3)) ->where('datetime','>=',$this->mo->date->clone()->subYears(3))
->where('datetime','<=',$this->mo->date) ->where('datetime','<=',$this->mo->date)
->dontCache()
->single(); ->single();
Log::debug(sprintf('%s:- Checking for duplicate from host id [%d].',self::LOGKEY,$this->mo->fftn->id)); Log::debug(sprintf('%s:- Checking for duplicate from host id [%d].',self::LOGKEY,$this->mo->fftn->id));
if ($o) { if ($o) {
// @todo Actually update seenby // @todo Actually update seenby
Log::alert(sprintf('%s:! Duplicate echomail [%s] in [%s] from (%s) [%s] to (%s) - updating seenby.', Log::alert(sprintf('%s:! Duplicate echomail [%d] (%s) in [%s] from (%s) [%s] to (%s) - updating seenby.',
self::LOGKEY, self::LOGKEY,
$o->id,
$this->mo->msgid, $this->mo->msgid,
$this->mo->echoarea->name, $this->mo->echoarea->name,
$this->mo->from,$this->mo->fftn->ftn, $this->mo->from,$this->mo->fftn->ftn,
@ -284,6 +286,7 @@ class MessageProcess implements ShouldQueue
$o = Echomail::where('msg_crc',$xx=md5($this->mo->msg_crc)) $o = Echomail::where('msg_crc',$xx=md5($this->mo->msg_crc))
->where('fftn_id',$this->mo->fftn->id) ->where('fftn_id',$this->mo->fftn->id)
->where('datetime','>',Carbon::now()->subWeek()) ->where('datetime','>',Carbon::now()->subWeek())
->dontCache()
->get(); ->get();
if ($o->count()) if ($o->count())

View File

@ -269,7 +269,8 @@ class System extends Model
*/ */
public function packet(Address $ao,string $password=NULL): Packet public function packet(Address $ao,string $password=NULL): Packet
{ {
// @todo Check that the address is one of the system's addresses if ($ao->system_id !== $this->id)
throw new \Exception('Packet for [%s] is not for system [%d]',$ao->ftn,$this->id);
return return
(new (collect(Packet::PACKET_TYPES) (new (collect(Packet::PACKET_TYPES)

View File

@ -8,7 +8,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification; use Illuminate\Notifications\Notification;
use App\Classes\FTN\Message; use App\Classes\FTN\Message;
use App\Models\{Echoarea,Echomail,Setup}; use App\Models\{Echoarea,Echomail,Netmail,Setup};
abstract class Echomails extends Notification //implements ShouldQueue abstract class Echomails extends Notification //implements ShouldQueue
{ {
@ -53,8 +53,8 @@ abstract class Echomails extends Notification //implements ShouldQueue
$o->echoarea_id = $eo->id; $o->echoarea_id = $eo->id;
$o->datetime = Carbon::now(); $o->datetime = Carbon::now()->utc();
$o->tzoffset = $o->datetime->utcOffset(); $o->tzoffset = Carbon::now()->utcOffset();
$o->flags = (Message::FLAG_LOCAL); $o->flags = (Message::FLAG_LOCAL);
@ -62,4 +62,13 @@ abstract class Echomails extends Notification //implements ShouldQueue
return $o; return $o;
} }
protected function sourceSummary(Echomail|Netmail $o,string $item=NULL): string
{
return sprintf("Your %s was received here on [%s] and it looks like you sent it on [%s].",
$item ?: sprintf('%s with ID [%s] to [%s]',$o instanceof Netmail ? 'Netmail' : 'Echomail',$o->msgid,$o->to),
Carbon::now()->utc()->toDateTimeString(),
$o->date->utc()->toDateTimeString(),
);
}
} }

View File

@ -8,7 +8,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification; use Illuminate\Notifications\Notification;
use App\Classes\FTN\Message; use App\Classes\FTN\Message;
use App\Models\{Netmail,Setup,System}; use App\Models\{Echomail,Netmail,Setup};
abstract class Netmails extends Notification //implements ShouldQueue abstract class Netmails extends Notification //implements ShouldQueue
{ {
@ -57,8 +57,8 @@ abstract class Netmails extends Notification //implements ShouldQueue
$o->to = $ao->system->sysop; $o->to = $ao->system->sysop;
$o->from = Setup::PRODUCT_NAME; $o->from = Setup::PRODUCT_NAME;
$o->datetime = Carbon::now(); $o->datetime = Carbon::now()->utc();
$o->tzoffset = $o->datetime->utcOffset(); $o->tzoffset = Carbon::now()->utcOffset();
$o->fftn_id = our_address($ao)->id; $o->fftn_id = our_address($ao)->id;
$o->tftn_id = $ao->id; $o->tftn_id = $ao->id;
@ -69,4 +69,13 @@ abstract class Netmails extends Notification //implements ShouldQueue
return $o; return $o;
} }
protected function sourceSummary(Echomail|Netmail $o,string $item=NULL): string
{
return sprintf("Your %s was received here on [%s] and it looks like you sent it on [%s].",
$item ?: sprintf('%s with ID [%s] to [%s]',$o instanceof Netmail ? 'Netmail' : 'Echomail',$o->msgid,$o->to),
Carbon::now()->utc()->toDateTimeString(),
$o->date->utc()->toDateTimeString(),
);
}
} }

View File

@ -48,14 +48,7 @@ class EchoareaNoWrite extends Netmails
// Message // Message
$msg = $this->page(FALSE,'nowrite'); $msg = $this->page(FALSE,'nowrite');
$msg->addText( $msg->addText($this->sourceSummary($this->mo)."\r\r");
sprintf("Your echomail with ID [%s] to [%s] here was received here on [%s] and it looks like you sent it on [%s].\r\r",
$this->mo->msgid,
$this->mo->to,
Carbon::now()->utc()->toDateTimeString(),
$this->mo->date->utc()->toDateTimeString(),
)
);
$msg->addText(sprintf("It appears that you do not have permission to post in [%s] using the address [%s], so the message from your system was rejected.\r\r",$this->mo->echoarea->name,$ao->ftn)); $msg->addText(sprintf("It appears that you do not have permission to post in [%s] using the address [%s], so the message from your system was rejected.\r\r",$this->mo->echoarea->name,$ao->ftn));
$msg->addText("Please contact the ZC if you think this is a mistake.\r\r"); $msg->addText("Please contact the ZC if you think this is a mistake.\r\r");

View File

@ -50,14 +50,7 @@ class EchoareaNotExist extends Netmails
// Message // Message
$msg = $this->page(FALSE,'nothere'); $msg = $this->page(FALSE,'nothere');
$msg->addText( $msg->addText($this->sourceSummary($this->mo)."\r\r");
sprintf("Your echomail with ID [%s] to [%s] here was received here on [%s] and it looks like you sent it on [%s].\r\r",
$this->mo->msgid,
$this->mo->to,
Carbon::now()->utc()->toDateTimeString(),
$this->mo->date->utc()->toDateTimeString(),
)
);
$msg->addText(sprintf("It appears that the echoarea [%s] that this message is for doesnt exist, so the message from your system was rejected.\r\r",$this->mo->set->get('set_echoarea'))); $msg->addText(sprintf("It appears that the echoarea [%s] that this message is for doesnt exist, so the message from your system was rejected.\r\r",$this->mo->set->get('set_echoarea')));
$msg->addText("Please contact the ZC if you think this is a mistake.\r\r"); $msg->addText("Please contact the ZC if you think this is a mistake.\r\r");

View File

@ -48,14 +48,7 @@ class EchoareaNotSubscribed extends Netmails
// Message // Message
$msg = $this->page(FALSE,'nosub'); $msg = $this->page(FALSE,'nosub');
$msg->addText( $msg->addText($this->sourceSummary($this->mo)."\r\r");
sprintf("Your echomail with ID [%s] to [%s] here was received here on [%s] and it looks like you sent it on [%s].\r\r",
$this->mo->msgid,
$this->mo->to,
Carbon::now()->utc()->toDateTimeString(),
$this->mo->date->utc()->toDateTimeString(),
)
);
$msg->addText(sprintf("It appears that you havent been previously subscribed to this echoarea using the address [%s].\r\r",$ao->ftn)); $msg->addText(sprintf("It appears that you havent been previously subscribed to this echoarea using the address [%s].\r\r",$ao->ftn));

View File

@ -48,14 +48,7 @@ class EchomailBadAddress extends Netmails
// Message // Message
$msg = $this->page(FALSE,'badmsg'); $msg = $this->page(FALSE,'badmsg');
$msg->addText( $msg->addText($this->sourceSummary($this->mo)."\r\r");
sprintf("Your echomail with ID [%s] to [%s] here was received here on [%s] and it looks like you sent it on [%s].\r\r",
$this->mo->msgid,
$this->mo->to,
Carbon::now()->utc()->toDateTimeString(),
$this->mo->date->utc()->toDateTimeString(),
)
);
$msg->addText(sprintf("The address in this echomail [%s] is the wrong address for this domain [%s].\r\r",$this->mo->fftn,$ao->zone->domain->name)); $msg->addText(sprintf("The address in this echomail [%s] is the wrong address for this domain [%s].\r\r",$this->mo->fftn,$ao->zone->domain->name));

View File

@ -50,14 +50,7 @@ class NetmailHubNoUser extends Netmails
// Message // Message
$msg = $this->page(FALSE,'Reject'); $msg = $this->page(FALSE,'Reject');
$msg->addText( $msg->addText($this->sourceSummary($this->mo)."\r\r");
sprintf("Your netmail with ID [%s] to [%s] here was received here on [%s] and it looks like you sent it on [%s].\r\r",
$this->mo->msgid,
$this->mo->to,
Carbon::now()->utc()->toDateTimeString(),
$this->mo->date->utc()->toDateTimeString(),
)
);
$msg->addText("This hub is not attended, so no user will be able to read your message. You may like to try and contact them another way.\r\r"); $msg->addText("This hub is not attended, so no user will be able to read your message. You may like to try and contact them another way.\r\r");

View File

@ -59,9 +59,15 @@ trait MessageAttributes
return ($this->msg_src) ? $this->msg_src : $this->rebuildMessage(); return ($this->msg_src) ? $this->msg_src : $this->rebuildMessage();
} }
/**
* This is used to build our data in a timezone date, so that when exported, we include the right TZUTC
*
* @return Carbon
*/
public function getDateAttribute(): Carbon public function getDateAttribute(): Carbon
{ {
return $this->datetime->utcOffset($this->tzoffset); // Datetime is in utc, and tzoffset describes what that local time is
return $this->datetime->clone()->utcOffset($this->tzoffset);
} }
public function getOriginAttribute(string $val=NULL): ?string public function getOriginAttribute(string $val=NULL): ?string

View File

@ -8,7 +8,7 @@ use App\Models\{Echomail,Netmail};
TO: <strong class="highlight">{!! Message::tr($msg->to) !!}</strong> @if ($msg instanceof Netmail)(<strong class="highlight">{{ $msg->tftn->ftn }}</strong>)@endif TO: <strong class="highlight">{!! Message::tr($msg->to) !!}</strong> @if ($msg instanceof Netmail)(<strong class="highlight">{{ $msg->tftn->ftn }}</strong>)@endif
</div> </div>
<div class="col-4"> <div class="col-4">
DATE: <strong class="highlight">{{ $msg->datetime->format('Y-m-d H:i:s') }}</strong> DATE: <strong class="highlight">{{ $msg->date->format('Y-m-d H:i:s') }}</strong>
</div> </div>
</div> </div>