. */ declare(strict_types=1); namespace FireflyIII\Console\Commands; use FireflyIII\Events\Test\OwnerTestsNotificationChannel; use FireflyIII\Notifications\Notifiables\OwnerNotifiable; use FireflyIII\Support\Facades\FireflyConfig; use Illuminate\Console\Command; class SendTestEmail extends Command { use ShowsFriendlyMessages; use VerifiesAccessToken; /** * The name and signature of the console command. * * @var string */ protected $signature = 'firefly-iii:send-test-email {--user=1 : The user ID.} {--token= : The user\'s access token.}'; /** * The console command description. * * @var string */ protected $description = 'Send test email'; /** * Execute the console command. */ public function handle(): int { $user = $this->getUser(); if (!$user->hasRole('owner')) { $this->friendlyError((string) trans('firefly.must_be_owner')); return Command::FAILURE; } /** @var int $lastNotification */ $lastNotification = FireflyConfig::get('last_test_notification', 123)->data; if ((time() - $lastNotification) < 120) { $this->friendlyError((string) trans('firefly.test_rate_limited')); return Command::FAILURE; } $owner = new OwnerNotifiable(); event(new OwnerTestsNotificationChannel('email', $owner)); FireflyConfig::set('last_test_notification', time()); return Command::SUCCESS; } }