pixelfed/app/Console/Commands/PushGatewayRefresh.php

75 lines
1.9 KiB
PHP
Raw Normal View History

2024-09-28 09:51:39 +00:00
<?php
namespace App\Console\Commands;
use App\Services\NotificationAppGatewayService;
2024-10-04 03:13:35 +00:00
use App\Services\PushNotificationService;
2024-09-28 09:52:58 +00:00
use Illuminate\Console\Command;
2024-09-28 09:51:39 +00:00
use function Laravel\Prompts\select;
class PushGatewayRefresh extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:push-gateway-refresh';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Refresh push notification gateway support';
/**
* Execute the console command.
*/
public function handle()
{
$this->info('Checking Push Notification support...');
$this->line(' ');
$currentState = NotificationAppGatewayService::enabled();
2024-09-28 09:52:58 +00:00
if ($currentState) {
2024-09-28 09:51:39 +00:00
$this->info('Push Notification support is active!');
2024-09-28 09:52:58 +00:00
2024-09-28 09:51:39 +00:00
return;
} else {
$this->error('Push notification support is NOT active');
$action = select(
label: 'Do you want to force re-check?',
options: ['Yes', 'No'],
required: true
);
2024-09-28 09:52:58 +00:00
if ($action === 'Yes') {
2024-09-28 09:51:39 +00:00
$recheck = NotificationAppGatewayService::forceSupportRecheck();
2024-09-28 09:52:58 +00:00
if ($recheck) {
2024-09-28 09:51:39 +00:00
$this->info('Success! Push Notifications are now active!');
2024-10-04 03:13:35 +00:00
PushNotificationService::warmList('like');
2024-09-28 09:52:58 +00:00
2024-09-28 09:51:39 +00:00
return;
} else {
$this->error('Error, please ensure you have a valid API key.');
$this->line(' ');
$this->line('For more info, visit https://docs.pixelfed.org/running-pixelfed/push-notifications.html');
$this->line(' ');
2024-09-28 09:52:58 +00:00
2024-09-28 09:51:39 +00:00
return;
}
2024-09-28 09:52:58 +00:00
2024-09-28 09:51:39 +00:00
return;
} else {
exit;
}
2024-09-28 09:52:58 +00:00
2024-09-28 09:51:39 +00:00
return;
}
}
}