diff --git a/src/app/Console/Commands/ScheduleEventReminders.php b/src/app/Console/Commands/ScheduleEventReminders.php index 54dc8c8..2562020 100644 --- a/src/app/Console/Commands/ScheduleEventReminders.php +++ b/src/app/Console/Commands/ScheduleEventReminders.php @@ -28,7 +28,7 @@ class ScheduleEventReminders extends Command $this->processTaskReminders($minuteStart, $minuteEnd); $events = Event::with('user') - ->where('starts_at', '>', $now) + ->where('starts_at', '>', $now->copy()->subDay()) ->where('starts_at', '<', $now->copy()->addDay()) ->get(); @@ -212,21 +212,25 @@ class ScheduleEventReminders extends Command private function calculateSendTime(Event $event, array $reminder, string $tz): ?Carbon { - $startUtc = $event->starts_at; + $startUtc = $event->starts_at; + $startLocal = $startUtc->copy()->setTimezone($tz); $sendAt = match ($reminder['type']) { 'before' => $startUtc->copy()->subMinutes($reminder['minutes'] ?? 30), + // Stored time is UTC → convert to local first, then combine with local event date → back to UTC 'time_of_day' => Carbon::createFromFormat( 'Y-m-d H:i', - $event->starts_at->setTimezone($tz)->format('Y-m-d') . ' ' . ($reminder['time'] ?? '08:00'), - 'UTC' + $startLocal->format('Y-m-d') . ' ' . + Carbon::createFromFormat('H:i', $reminder['time'] ?? '08:00', 'UTC')->setTimezone($tz)->format('H:i'), + $tz )->utc(), 'day_before' => Carbon::createFromFormat( 'Y-m-d H:i', - $event->starts_at->setTimezone($tz)->subDay()->format('Y-m-d') . ' ' . ($reminder['time'] ?? '18:00'), - 'UTC' + $startLocal->copy()->subDay()->format('Y-m-d') . ' ' . + Carbon::createFromFormat('H:i', $reminder['time'] ?? '18:00', 'UTC')->setTimezone($tz)->format('H:i'), + $tz )->utc(), 'specific' => isset($reminder['datetime']) diff --git a/src/app/Services/PushService.php b/src/app/Services/PushService.php index 5e064c7..5a357fe 100644 --- a/src/app/Services/PushService.php +++ b/src/app/Services/PushService.php @@ -42,10 +42,14 @@ class PushService ])->values()->toArray(); try { - $response = Http::withHeaders([ - 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - ])->post(self::EXPO_PUSH_URL, $messages); + $expoToken = config('services.expo.token'); + + $response = Http::asJson() + ->withHeaders(array_filter([ + 'Accept' => 'application/json', + 'Authorization' => $expoToken ? 'Bearer ' . $expoToken : null, + ])) + ->post(self::EXPO_PUSH_URL, $messages); $receipts = $response->json(); diff --git a/src/config/services.php b/src/config/services.php index d00a529..7228119 100644 --- a/src/config/services.php +++ b/src/config/services.php @@ -42,6 +42,10 @@ return [ 'currency' => env('STRIPE_CURRENCY', 'eur'), ], + 'expo' => [ + 'token' => env('EXPO_TOKEN'), + ], + 'openai' => [ 'key' => env('OPENAI_API_KEY'), 'model' => env('OPENAI_MODEL', 'gpt-4o-mini'),