fix(#124): improve timezone support
Some checks failed
tests / ci (push) Has been cancelled

This commit is contained in:
Benjamin Nussbaum 2025-12-02 16:44:41 +01:00
parent 0322ec899e
commit b10bbca774
9 changed files with 168 additions and 12 deletions

View file

@ -25,7 +25,7 @@ class ImageGenerationService
{
public static function generateImage(string $markup, $deviceId): string
{
$device = Device::with(['deviceModel', 'palette', 'deviceModel.palette'])->find($deviceId);
$device = Device::with(['deviceModel', 'palette', 'deviceModel.palette', 'user'])->find($deviceId);
$uuid = Uuid::uuid4()->toString();
try {
@ -44,6 +44,10 @@ class ImageGenerationService
$browserStage = new BrowserStage($browsershotInstance);
$browserStage->html($markup);
// Set timezone from user or fall back to app timezone
$timezone = $device->user->timezone ?? config('app.timezone');
$browserStage->timezone($timezone);
if (config('app.puppeteer_window_size_strategy') === 'v2') {
$browserStage
->width($imageSettings['width'])
@ -352,7 +356,7 @@ class ImageGenerationService
try {
// Load device with relationships
$device->load(['palette', 'deviceModel.palette']);
$device->load(['palette', 'deviceModel.palette', 'user']);
// Get image generation settings from DeviceModel if available, otherwise use device settings
$imageSettings = self::getImageSettings($device);
@ -372,6 +376,10 @@ class ImageGenerationService
$browserStage = new BrowserStage($browsershotInstance);
$browserStage->html($html);
// Set timezone from user or fall back to app timezone
$timezone = $device->user->timezone ?? config('app.timezone');
$browserStage->timezone($timezone);
if (config('app.puppeteer_window_size_strategy') === 'v2') {
$browserStage
->width($imageSettings['width'])