From 527b8eb594c212397175d5fba2fcb0cd6212f475 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 12 Apr 2019 22:13:36 -0600 Subject: [PATCH] Update InstagramImport Controller --- app/Http/Controllers/Import/Instagram.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Import/Instagram.php b/app/Http/Controllers/Import/Instagram.php index 0b1486f31..936f10b4c 100644 --- a/app/Http/Controllers/Import/Instagram.php +++ b/app/Http/Controllers/Import/Instagram.php @@ -82,9 +82,10 @@ trait Instagram ->whereStage(1) ->firstOrFail(); + $limit = config('pixelfed.import.instagram.limits.posts'); foreach ($media as $k => $v) { $original = $v->getClientOriginalName(); - if(strlen($original) < 32 || $k > 100) { + if(strlen($original) < 32 || $k > $limit) { continue; } $storagePath = "import/{$job->uuid}"; @@ -105,7 +106,6 @@ trait Instagram $job->save(); }); return redirect($job->url()); - return view('settings.import.instagram.step-one', compact('profile', 'job')); } public function instagramStepTwo(Request $request, $uuid) @@ -148,6 +148,7 @@ trait Instagram { $profile = Auth::user()->profile; $job = ImportJob::whereProfileId($profile->id) + ->whereService('instagram') ->whereNull('completed_at') ->whereUuid($uuid) ->whereStage(3) @@ -159,14 +160,21 @@ trait Instagram { $profile = Auth::user()->profile; - $job = ImportJob::whereProfileId($profile->id) + + try { + $import = ImportJob::whereProfileId($profile->id) + ->where('uuid', $uuid) + ->whereNotNull('media_json') ->whereNull('completed_at') - ->whereUuid($uuid) ->whereStage(3) ->firstOrFail(); + ImportInstagram::dispatch($import); + } catch (Exception $e) { + \Log::info($e); + } - ImportInstagram::dispatchNow($job); - - return redirect($profile->url()); + return redirect(route('settings'))->with(['status' => [ + 'Import successful! It may take a few minutes to finish.' + ]]); } }