From 0e1f1bb44a7e6d0f6a72bc193d5aa7fadc9649a2 Mon Sep 17 00:00:00 2001 From: Jessica Smith Date: Fri, 11 Oct 2024 09:33:39 +0100 Subject: [PATCH 1/2] Add simple webhook endpoint --- app/Http/Controllers/Webhooks/PartyController.php | 7 +++++++ routes/webhooks.php | 1 + 2 files changed, 8 insertions(+) diff --git a/app/Http/Controllers/Webhooks/PartyController.php b/app/Http/Controllers/Webhooks/PartyController.php index 810f1e0..c0b18df 100644 --- a/app/Http/Controllers/Webhooks/PartyController.php +++ b/app/Http/Controllers/Webhooks/PartyController.php @@ -25,4 +25,11 @@ public function librespot(PartyLibrespotRequest $request, Party $party) } return response()->noContent(); } + + public function simple(Party $party) + { + Log::debug("{$party}: Received simple webhook event"); + PartyUpdate::dispatch($party)->onQueue('partyupdates')->afterResponse(); + return response()->noContent(); + } } diff --git a/routes/webhooks.php b/routes/webhooks.php index 07d788a..dcecbc1 100644 --- a/routes/webhooks.php +++ b/routes/webhooks.php @@ -5,4 +5,5 @@ Route::name('webhooks.')->middleware('auth:sanctum')->group(function () { Route::post('parties/{party}/librespot', [PartyController::class, 'librespot'])->middleware('can:update,party')->name('parties.update'); + Route::post('parties/{party}/simple', [PartyController::class, 'simple'])->middleware('can:update,party')->name('parties.simple'); }); From 8620ae73c8ec75a19c7c21ac84c650ae8007ffd0 Mon Sep 17 00:00:00 2001 From: Jessica Smith Date: Sat, 28 Dec 2024 13:48:09 +0000 Subject: [PATCH 2/2] Handle playlist not containing track data --- app/Models/Party.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Models/Party.php b/app/Models/Party.php index 6fbe7a4..efc2394 100644 --- a/app/Models/Party.php +++ b/app/Models/Party.php @@ -572,6 +572,9 @@ protected function backfillUpcomingSongs() ->toArray(); $tracks = array_filter($tracks, function ($track) use ($existingIds) { + if ($track->track === null) { + return false; + } return !in_array($track->track->id, $existingIds); });