NodesNew also now sends an Echomail
This commit is contained in:
@@ -12,7 +12,8 @@ use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
use App\Models\{Address,Domain};
|
||||
use App\Notifications\Netmails\NodesNew as NotificationNodesNew;
|
||||
use App\Notifications\Echomails\NodesNew as NodesNewEchomail;
|
||||
use App\Notifications\Netmails\NodesNew as NodesNewNetmail;
|
||||
|
||||
class NodesNew implements ShouldQueue
|
||||
{
|
||||
@@ -21,7 +22,7 @@ class NodesNew implements ShouldQueue
|
||||
private const LOGKEY = 'JNN';
|
||||
|
||||
private ?Carbon $since; // New nodes since this date
|
||||
private Address $ao; // Domain we are processing
|
||||
private ?Address $ao; // Domain we are processing
|
||||
private Domain $do; // Domain we are processing
|
||||
|
||||
/**
|
||||
@@ -39,7 +40,7 @@ class NodesNew implements ShouldQueue
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$since = ($this->since ?: Carbon::parse('last saturday'))->startOfDay();
|
||||
$since = ($this->since ?: Carbon::parse('last monday'))->startOfDay();
|
||||
|
||||
$result = Address::FTN()
|
||||
->ActiveFTN()
|
||||
@@ -48,18 +49,19 @@ class NodesNew implements ShouldQueue
|
||||
->join('system_zone',['system_zone.system_id'=>'systems.id','system_zone.zone_id'=>'zones.id'])
|
||||
->whereIn('zones.id',$this->do->zones->pluck('id'))
|
||||
->where('systems.active',TRUE)
|
||||
->where('systems.created_at','>=',$since)
|
||||
->where('addresses.created_at','>=',$since)
|
||||
->orderBy('addresses.created_at')
|
||||
->get();
|
||||
|
||||
if ($result->count()) {
|
||||
Log::notice(sprintf('%s:- Sending new nodes since [%s] (%d)',self::LOGKEY,$since,$result->count()));
|
||||
|
||||
Notification::route('netmail',$this->ao->withoutRelations())
|
||||
->notify(new NotificationNodesNew(
|
||||
$since,
|
||||
$result,
|
||||
));
|
||||
if ($this->ao)
|
||||
Notification::route('netmail',$this->ao->withoutRelations())
|
||||
->notify(new NodesNewNetmail($since,$result));
|
||||
else
|
||||
Notification::route('echomail',$this->do->nodestatus_echoarea)
|
||||
->notify(new NodesNewEchomail($since,$result));
|
||||
|
||||
} else
|
||||
Log::notice(sprintf('%s:- No nodes since [%s]',self::LOGKEY,$since));
|
||||
|
Reference in New Issue
Block a user