diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php index a4ecb766..2e7d5ead 100644 --- a/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundClipGeometryController.php @@ -86,6 +86,7 @@ public function clipOverlappingPolygons(Request $request) $allPolygonUuids = array_merge($allPolygonUuids, $polygonUuids); } $uniquePolygonUuids = array_unique($allPolygonUuids); + $delayedJob = null; if (! empty($uniquePolygonUuids)) { $user = Auth::user(); $delayedJob = DelayedJob::create(); @@ -93,7 +94,11 @@ public function clipOverlappingPolygons(Request $request) dispatch($job); } - return new DelayedJobResource($delayedJob); + if ($delayedJob) { + return new DelayedJobResource($delayedJob); + } else { + return response()->json(['message' => 'No overlapping polygons found or processed.'], 204); + } } public function clipOverlappingPolygon(string $uuid)