BINKP responding to incoming netmail pings

This commit is contained in:
Deon George
2021-07-18 22:10:21 +10:00
parent 7bb3e12f66
commit 9dcfe6b17d
19 changed files with 145 additions and 54 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use Carbon\Carbon;
use Exception;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -157,13 +158,22 @@ class Address extends Model
*/
public function getNetmail(): ?Packet
{
if (($x=Netmail::whereIn('tftn_id',$this->children->pluck('id')->push($this->id)))->count()) {
if (($x=Netmail::whereIn('tftn_id',$this->children->pluck('id')->push($this->id))
->where(function($q) {
return $q->whereNull('sent')
->orWhere('sent',FALSE);
}))
->count())
{
$o = new Packet($this);
foreach ($x->get() as $oo) {
$o->addNetmail($oo->packet());
// @todo We need to mark the netmail as sent
$oo->packet = $o->name;
$oo->sent = TRUE;
$oo->sent_at = Carbon::now();
$oo->save();
}
return $o;