Correctly storing netmail flags (intransit, local, recv) with senders ID and packet name
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Models;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -14,6 +15,8 @@ use App\Classes\FTN\Message;
|
||||
use App\Interfaces\Packet;
|
||||
use App\Traits\{EncodeUTF8,MsgID};
|
||||
|
||||
// @deprecated recv_pkt now in netmail_path
|
||||
// @deprecated local - use flags
|
||||
final class Netmail extends Model implements Packet
|
||||
{
|
||||
private const LOGKEY = 'MN-';
|
||||
@@ -21,6 +24,8 @@ final class Netmail extends Model implements Packet
|
||||
use SoftDeletes,EncodeUTF8,MsgID;
|
||||
|
||||
private Collection $set_path;
|
||||
private Address $set_sender;
|
||||
private string $set_pkt;
|
||||
|
||||
private const cast_utf8 = [
|
||||
'to',
|
||||
@@ -44,6 +49,8 @@ final class Netmail extends Model implements Packet
|
||||
{
|
||||
switch ($key) {
|
||||
case 'set_path':
|
||||
case 'set_pkt':
|
||||
case 'set_sender':
|
||||
$this->{$key} = $value;
|
||||
break;
|
||||
|
||||
@@ -60,7 +67,12 @@ final class Netmail extends Model implements Packet
|
||||
// Save the Path
|
||||
$ppoid = NULL;
|
||||
|
||||
if (isset($model->set_path))
|
||||
if (isset($model->set_path)) {
|
||||
// If there are no details (Mystic), we'll create a blank
|
||||
if (! $model->set_path->count()) {
|
||||
$model->set_path->push(['node'=>$model->set_sender,'datetime'=>Carbon::now(),'program'=>'Unknown']);
|
||||
}
|
||||
|
||||
foreach ($model->set_path as $path) {
|
||||
$po = DB::select('INSERT INTO netmail_path (netmail_id,address_id,parent_id,datetime,program) VALUES (?,?,?,?,?) RETURNING id',[
|
||||
$model->id,
|
||||
@@ -72,6 +84,15 @@ final class Netmail extends Model implements Packet
|
||||
|
||||
$ppoid = $po[0]->id;
|
||||
}
|
||||
|
||||
if (isset($model->set_pkt) && isset($model->set_sender)) {
|
||||
DB::update('UPDATE netmail_path set recv_pkt=?,recv_id=? where address_id=?',[
|
||||
$model->set_pkt,
|
||||
$model->set_sender->id,
|
||||
Arr::get($model->set_path->last(),'node')->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -87,7 +108,13 @@ final class Netmail extends Model implements Packet
|
||||
public function path()
|
||||
{
|
||||
return $this->belongsToMany(Address::class,'netmail_path')
|
||||
->withPivot(['id','parent_id','datetime','program']);
|
||||
->withPivot(['id','parent_id','datetime','program','recv_pkt','recv_id']);
|
||||
}
|
||||
|
||||
public function received()
|
||||
{
|
||||
return $this->belongsToMany(Address::class,'netmail_path','netmail_id','recv_id')
|
||||
->withPivot(['id','parent_id','datetime','program','recv_pkt','recv_id']);
|
||||
}
|
||||
|
||||
public function tftn()
|
||||
|
Reference in New Issue
Block a user