Compare commits

...

3 Commits

Author SHA1 Message Date
4d7af7c7e3 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
2024-06-28 23:27:06 +10:00
fc930ba6c2 Revert "Fix date being used in mail packets, timezone was effectively being to a timestamp with the timezone already"
This function is used to get the true date of a message (taking into account the TZ), and needed when creating the TZUTC

This reverts commit ad0ad73b0c.
2024-06-28 18:30:34 +10:00
7f4540f5ec For some reason addresses.nodes_hub is passed a blank object, thus not retrieving hub's nodes 2024-06-28 18:30:34 +10:00
21 changed files with 59 additions and 68 deletions

View File

@ -233,7 +233,7 @@ class Message extends FTNBase
$o->mo->from = $o->header['user_from'];
$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->flags = $o->header['flags'];
$o->mo->cost = $o->header['cost'];
@ -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->datetime->format('d M y H:i:s'),
$this->mo->date->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->datetime->getOffsetString('')));
$return .= sprintf("\01TZUTC: %s\r",str_replace('+','',$this->mo->date->getOffsetString('')));
if ($this->mo->msgid)
$return .= sprintf("\01MSGID: %s\r",$this->mo->msgid);

View File

@ -361,7 +361,7 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
$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;
}

View File

@ -65,7 +65,7 @@ final class FSC39 extends Packet
*/
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(''),
$this->fftn_p->node_id, // Orig Node

View File

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

View File

@ -116,6 +116,6 @@ final class Mail extends Send
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";
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(' - Flags : %s',$msg->flags()->keys()->join(', ')));
$this->warn(sprintf(' - Cost : %d',$msg->cost));
@ -112,4 +112,4 @@ class PacketInfo extends Command
return self::SUCCESS;
}
}
}

View File

@ -66,7 +66,7 @@ class SystemController extends Controller
->with('saved',TRUE);
}
$o->load(['addresses.zone.domain','addresses.nodes_hub','addresses.system','sessions.domain','sessions.systems']);
$o->load(['addresses.zone.domain','addresses.system','sessions.domain','sessions.systems']);
return view('system.addedit')
->with('action',$o->exists ? 'update_nn' : 'create')

View File

@ -228,16 +228,18 @@ class MessageProcess implements ShouldQueue
if ($this->mo->msgid) {
$o = Echomail::where('msgid',$this->mo->msgid)
->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)
->dontCache()
->single();
Log::debug(sprintf('%s:- Checking for duplicate from host id [%d].',self::LOGKEY,$this->mo->fftn->id));
if ($o) {
// @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,
$o->id,
$this->mo->msgid,
$this->mo->echoarea->name,
$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))
->where('fftn_id',$this->mo->fftn->id)
->where('datetime','>',Carbon::now()->subWeek())
->dontCache()
->get();
if ($o->count())

View File

@ -269,7 +269,8 @@ class System extends Model
*/
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
(new (collect(Packet::PACKET_TYPES)

View File

@ -8,7 +8,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
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
{
@ -53,8 +53,8 @@ abstract class Echomails extends Notification //implements ShouldQueue
$o->echoarea_id = $eo->id;
$o->datetime = Carbon::now();
$o->tzoffset = $o->datetime->utcOffset();
$o->datetime = Carbon::now()->utc();
$o->tzoffset = Carbon::now()->utcOffset();
$o->flags = (Message::FLAG_LOCAL);
@ -62,4 +62,13 @@ abstract class Echomails extends Notification //implements ShouldQueue
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

@ -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->datetime->utc()->toDateTimeString(),
$this->mo->datetime->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE])
$this->mo->date->utc()->toDateTimeString(),
$this->mo->date->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE])
)
);

View File

@ -8,7 +8,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
use App\Classes\FTN\Message;
use App\Models\{Netmail,Setup,System};
use App\Models\{Echomail,Netmail,Setup};
abstract class Netmails extends Notification //implements ShouldQueue
{
@ -57,8 +57,8 @@ abstract class Netmails extends Notification //implements ShouldQueue
$o->to = $ao->system->sysop;
$o->from = Setup::PRODUCT_NAME;
$o->datetime = Carbon::now();
$o->tzoffset = $o->datetime->utcOffset();
$o->datetime = Carbon::now()->utc();
$o->tzoffset = Carbon::now()->utcOffset();
$o->fftn_id = our_address($ao)->id;
$o->tftn_id = $ao->id;
@ -69,4 +69,13 @@ abstract class Netmails extends Notification //implements ShouldQueue
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
$msg = $this->page(FALSE,'nowrite');
$msg->addText(
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->datetime->utc()->toDateTimeString(),
)
);
$msg->addText($this->sourceSummary($this->mo)."\r\r");
$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");

View File

@ -50,14 +50,7 @@ class EchoareaNotExist extends Netmails
// Message
$msg = $this->page(FALSE,'nothere');
$msg->addText(
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->datetime->utc()->toDateTimeString(),
)
);
$msg->addText($this->sourceSummary($this->mo)."\r\r");
$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");

View File

@ -48,14 +48,7 @@ class EchoareaNotSubscribed extends Netmails
// Message
$msg = $this->page(FALSE,'nosub');
$msg->addText(
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->datetime->utc()->toDateTimeString(),
)
);
$msg->addText($this->sourceSummary($this->mo)."\r\r");
$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
$msg = $this->page(FALSE,'badmsg');
$msg->addText(
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->datetime->utc()->toDateTimeString(),
)
);
$msg->addText($this->sourceSummary($this->mo)."\r\r");
$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
$msg = $this->page(FALSE,'Reject');
$msg->addText(
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->datetime->utc()->toDateTimeString(),
)
);
$msg->addText($this->sourceSummary($this->mo)."\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

@ -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->datetime->utc()->toDateTimeString(),
$this->mo->datetime->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE])
$this->mo->date->utc()->toDateTimeString(),
$this->mo->date->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE])
)
);

View File

@ -59,11 +59,15 @@ trait MessageAttributes
return ($this->msg_src) ? $this->msg_src : $this->rebuildMessage();
}
/** @deprecated use datetime? */
/**
* 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
{
Log::alert(sprintf('%s:! This function is deprecated',self::LOGKEY),['class'=>get_class($this)]);
return $this->datetime;
// 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

View File

@ -19,7 +19,7 @@ trait MessagePath
$reply .= str_replace("\r---","\r#--",$mo->msg)."\r";
$reply .= "+------------------------------------[ CONTROL LINES ]-+\r";
$reply .= sprintf("DATE: %s\r",$mo->datetime->format('Y-m-d H:i:s'));
$reply .= sprintf("DATE: %s\r",$mo->date->format('Y-m-d H:i:s'));
if ($mo->msgid)
$reply .= sprintf("MSGID: %s\r",$mo->msgid);
if ($mo->replyid)

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
</div>
<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>