BINKP responding to incoming netmail pings
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user