Fixed: basePath self→static binding, namespace detection, event wiring,
SQLite cache, file cache driver. All Mod Boot classes converted to
$listens pattern for lifecycle event discovery.
Working endpoints:
- /v1/explorer/info — live chain height, difficulty, aliases
- /v1/explorer/stats — formatted chain statistics
- /v1/names/directory — alias directory grouped by type
- /v1/names/available/{name} — name availability check
- /v1/names/lookup/{name} — name details
Co-Authored-By: Charon <charon@lethean.io>
126 lines
3 KiB
PHP
126 lines
3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Core PHP Framework
|
|
*
|
|
* Licensed under the European Union Public Licence (EUPL) v1.2.
|
|
* See LICENSE file for details.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Seo\Jobs;
|
|
|
|
use Core\Mod\Web\Models\Page;
|
|
use Core\Mod\Web\Services\DynamicOgImageService;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
/**
|
|
* Generate OG Image Job
|
|
*
|
|
* Queue-based generation of Open Graph images for pages.
|
|
* Regenerates images when page settings change.
|
|
*/
|
|
class GenerateOgImageJob implements ShouldQueue
|
|
{
|
|
use Dispatchable;
|
|
use InteractsWithQueue;
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
/**
|
|
* The number of times the job may be attempted.
|
|
*
|
|
* @var int
|
|
*/
|
|
public $tries = 3;
|
|
|
|
/**
|
|
* The number of seconds to wait before retrying the job.
|
|
*
|
|
* @var int
|
|
*/
|
|
public $backoff = 60;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*/
|
|
public function __construct(
|
|
public int $pageId,
|
|
public string $template = 'default',
|
|
public bool $force = false
|
|
) {
|
|
$this->onQueue('default');
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* Requires Core\Mod\Web module to be installed for full functionality.
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
// Check if required Web module classes exist
|
|
if (! class_exists(Page::class)) {
|
|
Log::warning('OG image generation skipped: Web module not installed');
|
|
|
|
return;
|
|
}
|
|
|
|
if (! class_exists(DynamicOgImageService::class)) {
|
|
Log::warning('OG image generation skipped: DynamicOgImageService not available');
|
|
|
|
return;
|
|
}
|
|
|
|
$ogService = app(DynamicOgImageService::class);
|
|
$page = Page::find($this->pageId);
|
|
|
|
if (! $page) {
|
|
Log::warning("OG image generation skipped: page {$this->pageId} not found");
|
|
|
|
return;
|
|
}
|
|
|
|
// Skip if disabled globally
|
|
if (! config('bio.og_images.enabled', true)) {
|
|
return;
|
|
}
|
|
|
|
// Skip if image exists and is not stale (unless forced)
|
|
if (! $this->force && $ogService->exists($page) && ! $ogService->isStale($page)) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
$url = $ogService->generate($page, $this->template);
|
|
|
|
Log::info("OG image generated for page {$page->id}", [
|
|
'url' => $url,
|
|
'template' => $this->template,
|
|
]);
|
|
} catch (\Exception $e) {
|
|
Log::error("Failed to generate OG image for page {$page->id}", [
|
|
'error' => $e->getMessage(),
|
|
'trace' => $e->getTraceAsString(),
|
|
]);
|
|
|
|
throw $e;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get the tags that should be assigned to the job.
|
|
*
|
|
* @return array<int, string>
|
|
*/
|
|
public function tags(): array
|
|
{
|
|
return ['og-image', "page:{$this->pageId}"];
|
|
}
|
|
}
|