Update ig import, use config_cache

This commit is contained in:
Daniel Supernault 2024-03-12 06:11:20 -06:00
parent 2d113de536
commit da0e0ffabf
No known key found for this signature in database
GPG Key ID: 23740873EE6F76A1
1 changed files with 25 additions and 1 deletions

View File

@ -17,7 +17,7 @@ trait Instagram
{ {
public function instagram() public function instagram()
{ {
if(config_cache('pixelfed.import.instagram.enabled') != true) { if((bool) config_cache('pixelfed.import.instagram.enabled') != true) {
abort(404, 'Feature not enabled'); abort(404, 'Feature not enabled');
} }
return view('settings.import.instagram.home'); return view('settings.import.instagram.home');
@ -25,6 +25,9 @@ trait Instagram
public function instagramStart(Request $request) public function instagramStart(Request $request)
{ {
if((bool) config_cache('pixelfed.import.instagram.enabled') != true) {
abort(404, 'Feature not enabled');
}
$completed = ImportJob::whereProfileId(Auth::user()->profile->id) $completed = ImportJob::whereProfileId(Auth::user()->profile->id)
->whereService('instagram') ->whereService('instagram')
->whereNotNull('completed_at') ->whereNotNull('completed_at')
@ -38,6 +41,9 @@ trait Instagram
protected function instagramRedirectOrNew() protected function instagramRedirectOrNew()
{ {
if((bool) config_cache('pixelfed.import.instagram.enabled') != true) {
abort(404, 'Feature not enabled');
}
$profile = Auth::user()->profile; $profile = Auth::user()->profile;
$exists = ImportJob::whereProfileId($profile->id) $exists = ImportJob::whereProfileId($profile->id)
->whereService('instagram') ->whereService('instagram')
@ -61,6 +67,9 @@ trait Instagram
public function instagramStepOne(Request $request, $uuid) public function instagramStepOne(Request $request, $uuid)
{ {
if((bool) config_cache('pixelfed.import.instagram.enabled') != true) {
abort(404, 'Feature not enabled');
}
$profile = Auth::user()->profile; $profile = Auth::user()->profile;
$job = ImportJob::whereProfileId($profile->id) $job = ImportJob::whereProfileId($profile->id)
->whereNull('completed_at') ->whereNull('completed_at')
@ -72,6 +81,9 @@ trait Instagram
public function instagramStepOneStore(Request $request, $uuid) public function instagramStepOneStore(Request $request, $uuid)
{ {
if((bool) config_cache('pixelfed.import.instagram.enabled') != true) {
abort(404, 'Feature not enabled');
}
$max = 'max:' . config('pixelfed.import.instagram.limits.size'); $max = 'max:' . config('pixelfed.import.instagram.limits.size');
$this->validate($request, [ $this->validate($request, [
'media.*' => 'required|mimes:bin,jpeg,png,gif|'.$max, 'media.*' => 'required|mimes:bin,jpeg,png,gif|'.$max,
@ -114,6 +126,9 @@ trait Instagram
public function instagramStepTwo(Request $request, $uuid) public function instagramStepTwo(Request $request, $uuid)
{ {
if((bool) config_cache('pixelfed.import.instagram.enabled') != true) {
abort(404, 'Feature not enabled');
}
$profile = Auth::user()->profile; $profile = Auth::user()->profile;
$job = ImportJob::whereProfileId($profile->id) $job = ImportJob::whereProfileId($profile->id)
->whereNull('completed_at') ->whereNull('completed_at')
@ -125,6 +140,9 @@ trait Instagram
public function instagramStepTwoStore(Request $request, $uuid) public function instagramStepTwoStore(Request $request, $uuid)
{ {
if((bool) config_cache('pixelfed.import.instagram.enabled') != true) {
abort(404, 'Feature not enabled');
}
$this->validate($request, [ $this->validate($request, [
'media' => 'required|file|max:1000' 'media' => 'required|file|max:1000'
]); ]);
@ -150,6 +168,9 @@ trait Instagram
public function instagramStepThree(Request $request, $uuid) public function instagramStepThree(Request $request, $uuid)
{ {
if((bool) config_cache('pixelfed.import.instagram.enabled') != true) {
abort(404, 'Feature not enabled');
}
$profile = Auth::user()->profile; $profile = Auth::user()->profile;
$job = ImportJob::whereProfileId($profile->id) $job = ImportJob::whereProfileId($profile->id)
->whereService('instagram') ->whereService('instagram')
@ -162,6 +183,9 @@ trait Instagram
public function instagramStepThreeStore(Request $request, $uuid) public function instagramStepThreeStore(Request $request, $uuid)
{ {
if((bool) config_cache('pixelfed.import.instagram.enabled') != true) {
abort(404, 'Feature not enabled');
}
$profile = Auth::user()->profile; $profile = Auth::user()->profile;
try { try {