Now correctly showing packet receive time, and sending Notifications based on the packet address, not the node address
This commit is contained in:
parent
c8a2affbfa
commit
74a56d1e17
app
Classes/File
Console/Commands
Jobs
Models
Notifications/Netmails
database/migrations
resources/views/system
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Classes\File;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
@ -100,6 +101,8 @@ class Receive extends Base
|
||||
throw new \Exception('No file to close');
|
||||
|
||||
if ($this->f) {
|
||||
$rcvd_time = Carbon::now();
|
||||
|
||||
if ($this->pos !== $this->receiving->recvsize)
|
||||
Log::warning(sprintf('%s:- Closing [%s], but missing [%d] bytes',self::LOGKEY,$this->receiving->nameas,$this->receiving->recvsize-$this->pos));
|
||||
else
|
||||
@ -175,9 +178,9 @@ class Receive extends Base
|
||||
try {
|
||||
// Dispatch job.
|
||||
if ($queue)
|
||||
MessageProcess::dispatch($msg,$f->pktName(),$this->ao);
|
||||
MessageProcess::dispatch($msg,$f->pktName(),$this->ao,$po->fftn_o,$rcvd_time);
|
||||
else
|
||||
MessageProcess::dispatchSync($msg,$f->pktName(),$this->ao);
|
||||
MessageProcess::dispatchSync($msg,$f->pktName(),$this->ao,$po->fftn_o,$rcvd_time);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error(sprintf('%s:! Got error dispatching message [%s] (%d:%s-%s).',self::LOGKEY,$msg->msgid,$e->getLine(),$e->getFile(),$e->getMessage()));
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use App\Classes\File;
|
||||
@ -47,7 +48,7 @@ class PacketProcess extends Command
|
||||
$this->info(sprintf('Processing message from [%s] with msgid [%s] in (%s)',$msg->fboss,$msg->msgid,$f->pktName()));
|
||||
|
||||
// Dispatch job.
|
||||
Job::dispatchSync($msg,$f->pktName(),$a,$this->option('nobot'));
|
||||
Job::dispatchSync($msg,$f->pktName(),$a,$packet->fftn_o,Carbon::now(),$this->option('nobot'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,14 +23,18 @@ class MessageProcess implements ShouldQueue
|
||||
|
||||
private Address $sender;
|
||||
private Message $msg;
|
||||
private Address $pktsrc;
|
||||
private Carbon $recvtime;
|
||||
private bool $skipbot;
|
||||
private string $packet;
|
||||
|
||||
public function __construct(Message $msg,string $packet,Address $sender,bool $skipbot=FALSE)
|
||||
public function __construct(Message $msg,string $packet,Address $sender,Address $pktsrc,Carbon $recvtime,bool $skipbot=FALSE)
|
||||
{
|
||||
$this->msg = $msg;
|
||||
$this->packet = $packet;
|
||||
$this->sender = $sender;
|
||||
$this->pktsrc = $pktsrc;
|
||||
$this->recvtime = $recvtime;
|
||||
$this->skipbot = $skipbot;
|
||||
}
|
||||
|
||||
@ -111,6 +115,7 @@ class MessageProcess implements ShouldQueue
|
||||
$o->set_pkt = $this->packet;
|
||||
$o->set_sender = $this->sender;
|
||||
$o->set_path = $this->msg->pathaddress;
|
||||
$o->set_recvtime = $this->recvtime;
|
||||
// Strip any local/transit flags
|
||||
$o->flags &= ~(Message::FLAG_LOCAL|Message::FLAG_INTRANSIT);
|
||||
|
||||
@ -222,7 +227,7 @@ class MessageProcess implements ShouldQueue
|
||||
if (! $ea) {
|
||||
Log::alert(sprintf('%s:! Echoarea [%s] doesnt exist for zone [%d]',self::LOGKEY,$this->msg->echoarea,$this->msg->fboss_o->zone->zone_id));
|
||||
|
||||
Notification::route('netmail',$this->sender)->notify(new EchoareaNotExist($this->msg));
|
||||
Notification::route('netmail',$this->pktsrc)->notify(new EchoareaNotExist($this->msg));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -281,14 +286,14 @@ class MessageProcess implements ShouldQueue
|
||||
// @todo Can the sender create it if it doesnt exist?
|
||||
|
||||
// Can the system send messages to this area?
|
||||
if (! $ea->sec_write || ($this->sender->security < $ea->sec_write)) {
|
||||
Notification::route('netmail',$this->sender)->notify(new EchoareaNoWrite($this->msg));
|
||||
if (! $ea->sec_write || ($this->pktsrc->security < $ea->sec_write)) {
|
||||
Notification::route('netmail',$this->pktsrc)->notify(new EchoareaNoWrite($this->msg));
|
||||
return;
|
||||
}
|
||||
|
||||
// If the node is not subsccribed
|
||||
if ($this->sender->echoareas->search(function($item) use ($ea) { return $item->id === $ea->id; }) === FALSE)
|
||||
Notification::route('netmail',$this->sender)->notify(new EchoareaNotSubscribed($this->msg));
|
||||
// If the node is not subscribed
|
||||
if ($this->pktsrc->echoareas->search(function($item) use ($ea) { return $item->id === $ea->id; }) === FALSE)
|
||||
Notification::route('netmail',$this->pktsrc)->notify(new EchoareaNotSubscribed($this->msg));
|
||||
|
||||
// We know about this area, store it
|
||||
$o = new Echomail;
|
||||
@ -312,6 +317,7 @@ class MessageProcess implements ShouldQueue
|
||||
$o->rogue_path = $this->msg->rogue_path;
|
||||
$o->set_path = $this->msg->pathaddress;
|
||||
$o->set_seenby = $this->msg->seenaddress;
|
||||
$o->set_recvtime = $this->recvtime;
|
||||
// Record receiving packet and sender
|
||||
$o->set_pkt = $this->packet;
|
||||
|
||||
|
@ -22,6 +22,7 @@ final class Echomail extends Model implements Packet
|
||||
private const LOGKEY = 'ME-';
|
||||
private Collection $set_seenby;
|
||||
private Collection $set_path;
|
||||
private Carbon $set_recvtime;
|
||||
private string $set_pkt;
|
||||
private bool $no_export = FALSE;
|
||||
|
||||
@ -51,6 +52,7 @@ final class Echomail extends Model implements Packet
|
||||
case 'no_export':
|
||||
case 'set_path':
|
||||
case 'set_pkt':
|
||||
case 'set_recvtime':
|
||||
case 'set_seenby':
|
||||
$this->{$key} = $value;
|
||||
break;
|
||||
@ -87,9 +89,10 @@ final class Echomail extends Model implements Packet
|
||||
}
|
||||
|
||||
// Our last node in the path is our sender
|
||||
if (isset($model->set_pkt)) {
|
||||
DB::update('UPDATE echomail_path set recv_pkt=? where address_id=? and echomail_id=?',[
|
||||
if (isset($model->set_pkt) && isset($model->set_recvtime)) {
|
||||
DB::update('UPDATE echomail_path set recv_pkt=?,recv_at=? where address_id=? and echomail_id=?',[
|
||||
$model->set_pkt,
|
||||
$model->set_recvtime,
|
||||
$model->set_path->last(),
|
||||
$model->id,
|
||||
]);
|
||||
|
@ -25,6 +25,7 @@ final class Netmail extends Model implements Packet
|
||||
|
||||
private Collection $set_path;
|
||||
private Address $set_sender;
|
||||
private Carbon $set_recvtime;
|
||||
private string $set_pkt;
|
||||
|
||||
private const cast_utf8 = [
|
||||
@ -50,6 +51,7 @@ final class Netmail extends Model implements Packet
|
||||
switch ($key) {
|
||||
case 'set_path':
|
||||
case 'set_pkt':
|
||||
case 'set_recvtime':
|
||||
case 'set_sender':
|
||||
$this->{$key} = $value;
|
||||
break;
|
||||
@ -86,9 +88,10 @@ final class Netmail extends Model implements Packet
|
||||
}
|
||||
|
||||
// Our last node in the path is our sender
|
||||
if (isset($model->set_pkt) && isset($model->set_sender)) {
|
||||
DB::update('UPDATE netmail_path set recv_pkt=?,recv_id=? where address_id=? and netmail_id=?',[
|
||||
if (isset($model->set_pkt) && isset($model->set_sender) && isset($model->set_recvtime)) {
|
||||
DB::update('UPDATE netmail_path set recv_pkt=?,recv_at=?,recv_id=? where address_id=? and netmail_id=?',[
|
||||
$model->set_pkt,
|
||||
$model->set_recvtime,
|
||||
$model->set_sender->id,
|
||||
Arr::get($model->set_path->last(),'node')->id,
|
||||
$model->id,
|
||||
|
@ -59,7 +59,7 @@ class EchoareaNoWrite extends Netmails
|
||||
)
|
||||
);
|
||||
|
||||
$msg->addText("It appears that you do not have permission to post in this echoarea, so the message from your system was rejected.\r\r");
|
||||
$msg->addText(sprintf("It appears that you do not have permission to post in this echoarea using the address [%s], so the message from your system was rejected.\r\r",$ao->ftn));
|
||||
$msg->addText("Please contact the ZC if you think this is a mistake.\r\r");
|
||||
|
||||
$msg->addText($this->message_path($this->mo));
|
||||
|
@ -59,7 +59,7 @@ class EchoareaNotSubscribed extends Netmails
|
||||
)
|
||||
);
|
||||
|
||||
$msg->addText("It appears that you havent been previously subscribed to this echoarea.\r\r");
|
||||
$msg->addText(sprintf("It appears that you havent been previously subscribed to this echoarea using the address [%s].\r\r",$ao->ftn));
|
||||
|
||||
$msg->addText("Even though your post was accepted, I'm not configured to export any posts to you when others respond, you might like to log in to the web interface and do that.\r\r");
|
||||
|
||||
|
34
database/migrations/2023_08_05_205920_mail_recvtime.php
Normal file
34
database/migrations/2023_08_05_205920_mail_recvtime.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('netmail_path',function (Blueprint $table) {
|
||||
$table->datetime('recv_at')->nullable();
|
||||
});
|
||||
|
||||
DB::statement('UPDATE netmail_path SET recv_at=created_at FROM netmails WHERE netmails.id=netmail_path.netmail_id');
|
||||
|
||||
Schema::table('echomail_path',function (Blueprint $table) {
|
||||
$table->datetime('recv_at')->nullable();
|
||||
});
|
||||
|
||||
DB::statement('UPDATE echomail_path SET recv_at=created_at FROM echomails WHERE echomails.id=echomail_path.echomail_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
@ -521,11 +521,11 @@
|
||||
<div class="col-4">
|
||||
The last Netmails received (you sent):
|
||||
|
||||
@if(($x=\App\Models\Netmail::select(['recv_pkt','created_at',DB::raw('count(*) AS count')])
|
||||
@if(($x=\App\Models\Netmail::select(['recv_pkt','recv_at',DB::raw('count(*) AS count')])
|
||||
->join('netmail_path',['netmail_path.netmail_id'=>'netmails.id'])
|
||||
->whereIn('address_id',$o->addresses->pluck('id'))
|
||||
->groupBy(['recv_pkt','created_at'])
|
||||
->orderBy('created_at','DESC')
|
||||
->groupBy(['recv_pkt','recv_at'])
|
||||
->orderBy('recv_at','DESC')
|
||||
->limit(10)
|
||||
->get())->count())
|
||||
<table class="table monotable">
|
||||
@ -541,7 +541,7 @@
|
||||
@foreach ($x as $oo)
|
||||
<tr>
|
||||
<td class="packet">{{ $oo->recv_pkt }}</td>
|
||||
<td>{{ $oo->created_at }}</td>
|
||||
<td>{{ $oo->recv_at }}</td>
|
||||
<td class="text-end">{{ $oo->count }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@ -555,12 +555,12 @@
|
||||
<div class="col-4">
|
||||
The last Echomails received (you sent):
|
||||
|
||||
@if(($x=\App\Models\Echomail::select(['recv_pkt','created_at',DB::raw('count(*) AS count')])
|
||||
@if(($x=\App\Models\Echomail::select(['recv_pkt','recv_at',DB::raw('count(*) AS count')])
|
||||
->join('echomail_path',['echomail_path.echomail_id'=>'echomails.id'])
|
||||
->whereNotNull('recv_pkt')
|
||||
->whereIn('address_id',$o->addresses->pluck('id'))
|
||||
->groupBy(['recv_pkt','created_at'])
|
||||
->orderBy('created_at','DESC')
|
||||
->groupBy(['recv_pkt','recv_at'])
|
||||
->orderBy('recv_at','DESC')
|
||||
->limit(10)
|
||||
->get())->count())
|
||||
<table class="table monotable">
|
||||
@ -576,7 +576,7 @@
|
||||
@foreach ($x as $oo)
|
||||
<tr>
|
||||
<td class="packet">{{ $oo->recv_pkt }}</td>
|
||||
<td>{{ $oo->created_at }}</td>
|
||||
<td>{{ $oo->recv_at }}</td>
|
||||
<td class="text-end">{{ $oo->count }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
Loading…
Reference in New Issue
Block a user