|
@@ -24,7 +24,7 @@ class ImportInstagram implements ShouldQueue
|
|
{
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
- protected $job;
|
|
|
|
|
|
+ protected $import;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Delete the job if its models no longer exist.
|
|
* Delete the job if its models no longer exist.
|
|
@@ -38,9 +38,9 @@ class ImportInstagram implements ShouldQueue
|
|
*
|
|
*
|
|
* @return void
|
|
* @return void
|
|
*/
|
|
*/
|
|
- public function __construct(ImportJob $job)
|
|
|
|
|
|
+ public function __construct(ImportJob $import)
|
|
{
|
|
{
|
|
- $this->job = $job;
|
|
|
|
|
|
+ $this->import = $import;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -50,8 +50,12 @@ class ImportInstagram implements ShouldQueue
|
|
*/
|
|
*/
|
|
public function handle()
|
|
public function handle()
|
|
{
|
|
{
|
|
- $job = $this->job;
|
|
|
|
- $profile = $this->job->profile;
|
|
|
|
|
|
+ if(config('pixelfed.import.instagram.enabled') != true) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $job = ImportJob::findOrFail($this->import->id);
|
|
|
|
+ $profile = Profile::findOrFail($job->profile_id);
|
|
$json = $job->mediaJson();
|
|
$json = $job->mediaJson();
|
|
$collection = $json['photos'];
|
|
$collection = $json['photos'];
|
|
$files = $job->files;
|
|
$files = $job->files;
|
|
@@ -74,9 +78,9 @@ class ImportInstagram implements ShouldQueue
|
|
$filename = last( explode('/', $import['path']) );
|
|
$filename = last( explode('/', $import['path']) );
|
|
$importData = ImportData::whereJobId($job->id)
|
|
$importData = ImportData::whereJobId($job->id)
|
|
->whereOriginalName($filename)
|
|
->whereOriginalName($filename)
|
|
- ->firstOrFail();
|
|
|
|
|
|
+ ->first();
|
|
|
|
|
|
- if(is_file(storage_path("app/$importData->path")) == false) {
|
|
|
|
|
|
+ if(empty($importData) || is_file(storage_path("app/$importData->path")) == false) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -88,6 +92,8 @@ class ImportInstagram implements ShouldQueue
|
|
$status->profile_id = $profile->id;
|
|
$status->profile_id = $profile->id;
|
|
$status->caption = strip_tags($caption);
|
|
$status->caption = strip_tags($caption);
|
|
$status->is_nsfw = false;
|
|
$status->is_nsfw = false;
|
|
|
|
+ $status->type = 'photo';
|
|
|
|
+ $status->scope = 'unlisted';
|
|
$status->visibility = 'unlisted';
|
|
$status->visibility = 'unlisted';
|
|
$status->created_at = $taken_at;
|
|
$status->created_at = $taken_at;
|
|
$status->save();
|
|
$status->save();
|