receive( $request->getContent(), $request->header('Authorization'), ); } catch (\Throwable $e) { Log::warning('LiveKit webhook rejected.', ['error' => $e->getMessage()]); return response()->json(['error' => 'invalid webhook'], 401); } if ($event->getEvent() !== 'egress_ended' || ! $event->hasEgressInfo()) { return response()->json(['status' => 'ignored']); } $info = $event->getEgressInfo(); $egressId = $info->getEgressId(); if ($egressId === '') { return response()->json(['status' => 'ignored']); } $recording = Recording::query() ->whereIn('status', ['recording', 'processing']) ->where('metadata->egress_id', $egressId) ->first(); if (! $recording) { return response()->json(['status' => 'not_found']); } $recordings->completeFromEgress($recording, $info); return response()->json(['status' => 'accepted']); } }