mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
36 lines
850 B
PHP
36 lines
850 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\GraphQL\Controllers\List;
|
|
|
|
use App\Exceptions\GraphQL\ClientForbiddenException;
|
|
use App\GraphQL\Controllers\BaseController;
|
|
use App\Models\List\ExternalProfile;
|
|
use Illuminate\Support\Arr;
|
|
|
|
class SyncExternalProfileController extends BaseController
|
|
{
|
|
/**
|
|
* Start a new sync job.
|
|
*
|
|
* @param null $root
|
|
* @param array<string, mixed> $args
|
|
*/
|
|
public function store($root, array $args): array
|
|
{
|
|
/** @var ExternalProfile $profile */
|
|
$profile = Arr::pull($args, self::MODEL);
|
|
|
|
if (! $profile->canBeSynced()) {
|
|
throw new ClientForbiddenException('This external profile cannot be synced at the moment.');
|
|
}
|
|
|
|
$profile->dispatchSyncJob();
|
|
|
|
return [
|
|
'message' => 'Job dispatched.',
|
|
];
|
|
}
|
|
}
|