-
-
Notifications
You must be signed in to change notification settings - Fork 680
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default licenses and license sync
- Loading branch information
Showing
3 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace App\Jobs\MediaPipeline; | ||
|
||
use App\Media; | ||
use App\User; | ||
use Cache; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
use App\Services\StatusService; | ||
|
||
class MediaSyncLicensePipeline implements ShouldQueue | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
protected $userId; | ||
protected $licenseId; | ||
|
||
public function __construct($userId, $licenseId) | ||
{ | ||
$this->userId = $userId; | ||
$this->licenseId = $licenseId; | ||
} | ||
|
||
public function handle() | ||
{ | ||
$licenseId = $this->licenseId; | ||
|
||
if(!$licenseId || !$this->userId) { | ||
return 1; | ||
} | ||
|
||
Media::whereUserId($this->userId) | ||
->chunk(100, function($medias) use($licenseId) { | ||
foreach($medias as $media) { | ||
$media->license = $licenseId; | ||
$media->save(); | ||
Cache::forget('status:transformer:media:attachments:'. $media->status_id); | ||
StatusService::del($media->status_id); | ||
} | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters