Skip to content

Commit

Permalink
Merge pull request #274 from HiEventsDev/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
daveearley authored Oct 30, 2024
2 parents 1e71d2b + 7bc5ad1 commit 157f205
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use HiEvents\Http\Middleware\Authenticate;
use HiEvents\Http\Middleware\EncryptCookies;
use HiEvents\Http\Middleware\HandleDeprecatedTimezones;
use HiEvents\Http\Middleware\PreventRequestsDuringMaintenance;
use HiEvents\Http\Middleware\RedirectIfAuthenticated;
use HiEvents\Http\Middleware\SetAccountContext;
Expand Down Expand Up @@ -45,6 +46,7 @@ class Kernel extends HttpKernel
ValidatePostSize::class,
TrimStrings::class,
ConvertEmptyStringsToNull::class,
HandleDeprecatedTimezones::class,
];

/**
Expand Down
27 changes: 27 additions & 0 deletions backend/app/Http/Middleware/HandleDeprecatedTimezones.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace HiEvents\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class HandleDeprecatedTimezones
{
public function handle(Request $request, Closure $next)
{
$timezoneMapping = config('timezones.deprecated');

if ($request->has('timezone')) {
$timezone = $request->input('timezone');

if (array_key_exists($timezone, $timezoneMapping)) {
$request->merge(['timezone' => $timezoneMapping[$timezone]]);
} elseif (!in_array($timezone, timezone_identifiers_list(), true)) {
Log::warning("Unexpected timezone received: $timezone");
}
}

return $next($request);
}
}
18 changes: 18 additions & 0 deletions backend/config/timezones.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

return [
'deprecated' => [
'Asia/Calcutta' => 'Asia/Kolkata',
'Asia/Saigon' => 'Asia/Ho_Chi_Minh',
'America/Buenos_Aires' => 'America/Argentina/Buenos_Aires',
'Europe/Kiev' => 'Europe/Kyiv',
'Africa/Asmera' => 'Africa/Asmara',
'America/Indianapolis' => 'America/Indiana/Indianapolis',
'Asia/Chongqing' => 'Asia/Shanghai',
'Asia/Macao' => 'Asia/Macau',
'Pacific/Samoa' => 'Pacific/Pago_Pago',
'Pacific/Yap' => 'Pacific/Chuuk',
'Etc/GMT+0' => 'Etc/GMT',
'Etc/Greenwich' => 'Etc/GMT',
],
];

0 comments on commit 157f205

Please sign in to comment.