Complete of logging received and sent packet names, and display them in the web ui for each node

This commit is contained in:
2023-07-15 22:10:05 +10:00
parent 61ab0614b6
commit a3302b4012
14 changed files with 257 additions and 121 deletions

View File

@@ -6,7 +6,6 @@ use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
@@ -598,9 +597,9 @@ class Address extends Model
->whereIn('echomail_id',$x->pluck('id'))
->where('address_id',$this->id)
->whereNull('sent_at')
->whereNull('packet')
->whereNull('sent_pkt')
->whereNotNull('echomail_seenby.export_at')
->update(['sent_at'=>Carbon::now(),'packet'=>$pkt->name]);
->update(['sent_pkt'=>$pkt->name]);
}
return $pkt;
@@ -638,21 +637,28 @@ class Address extends Model
* @param bool $update
* @return Packet|null
*/
public function getNetmail(bool $update=TRUE): ?Packet
public function getNetmail(bool $update=FALSE): ?Packet
{
$pkt = NULL;
$s = Setup::findOrFail(config('app.id'));
if (($x=$this->netmailWaiting())
->count())
{
Log::debug(sprintf('%s:= Got [%d] netmails for [%s] for sending',self::LOGKEY,$x->count(),$this->ftn));
if ($x->count() > $s->msgs_pkt) {
$x = $x->take($s->msgs_pkt);
Log::alert(sprintf('%s:= Only sending [%d] netmails for [%s]',self::LOGKEY,$x->count(),$this->ftn));
}
$pkt = $this->getPacket($x);
if ($pkt && $pkt->count() && $update)
DB::table('netmails')
->whereIn('id',$x->pluck('id'))
->update(['sent_at'=>Carbon::now(),'sent_pkt'=>$pkt->name]);
->update(['sent_pkt'=>$pkt->name]);
}
return $pkt;