2022-12-04 02:32:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
2024-05-19 13:28:45 +00:00
|
|
|
use App\Models\Address;
|
2022-12-04 02:32:46 +00:00
|
|
|
|
|
|
|
class PacketSystem extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'packet:system'
|
2024-05-19 13:28:45 +00:00
|
|
|
.' {ftn : System address}';
|
2022-12-04 02:32:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Show mail waiting for a system';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
2024-05-23 06:27:24 +00:00
|
|
|
* @return int
|
|
|
|
* @throws \Exception
|
2022-12-04 02:32:46 +00:00
|
|
|
*/
|
2024-05-27 05:08:39 +00:00
|
|
|
public function handle(): int
|
2022-12-04 02:32:46 +00:00
|
|
|
{
|
2024-05-19 13:28:45 +00:00
|
|
|
$ao = Address::findFTN($this->argument('ftn'));
|
2022-12-04 02:32:46 +00:00
|
|
|
|
2024-05-23 06:27:24 +00:00
|
|
|
foreach ($ao->system->addresses->where('validated',TRUE) as $o) {
|
2024-05-19 13:28:45 +00:00
|
|
|
$pkt = $o->getEchomail();
|
2024-05-23 06:27:24 +00:00
|
|
|
$this->info(sprintf('System address [%s] has [%d] echomail messages.',$o->ftn,$pkt?->count()));
|
|
|
|
|
|
|
|
if ($pkt) {
|
|
|
|
foreach ($pkt as $msg)
|
|
|
|
$this->warn(sprintf('- %s (%s)',$msg->msgid,$msg->id));
|
|
|
|
}
|
|
|
|
|
|
|
|
$pkt = $o->getNetmail();
|
|
|
|
$this->info(sprintf('System address [%s] has [%d] netmail messages.',$o->ftn,$pkt?->count()));
|
2022-12-04 02:32:46 +00:00
|
|
|
|
|
|
|
if ($pkt) {
|
|
|
|
foreach ($pkt as $msg)
|
2024-05-19 13:28:45 +00:00
|
|
|
$this->warn(sprintf('- %s (%s)',$msg->msgid,$msg->id));
|
2022-12-04 02:32:46 +00:00
|
|
|
}
|
|
|
|
}
|
2024-05-23 06:27:24 +00:00
|
|
|
|
|
|
|
return self::SUCCESS;
|
2022-12-04 02:32:46 +00:00
|
|
|
}
|
|
|
|
}
|