forked from mirror/pixelfed
Update SendUpdateActor command
This commit is contained in:
parent
1d52ad0b27
commit
04a498af9c
1 changed files with 28 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Storage;
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
use App\User;
|
use App\User;
|
||||||
use App\Instance;
|
use App\Instance;
|
||||||
|
@ -64,6 +65,7 @@ class SendUpdateActor extends Command
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->touchStorageCache($domain);
|
||||||
$this->line(' ');
|
$this->line(' ');
|
||||||
$this->error('Keep this window open during this process or it will not complete!');
|
$this->error('Keep this window open during this process or it will not complete!');
|
||||||
$sharedInbox = Profile::whereDomain($domain)->whereNotNull('sharedInbox')->first();
|
$sharedInbox = Profile::whereDomain($domain)->whereNotNull('sharedInbox')->first();
|
||||||
|
@ -76,8 +78,13 @@ class SendUpdateActor extends Command
|
||||||
$this->info('Found sharedInbox: ' . $url);
|
$this->info('Found sharedInbox: ' . $url);
|
||||||
$bar = $this->output->createProgressBar($totalUserCount);
|
$bar = $this->output->createProgressBar($totalUserCount);
|
||||||
$bar->start();
|
$bar->start();
|
||||||
User::whereNull('status')->chunk(50, function($users) use($bar, $url) {
|
|
||||||
|
$startCache = $this->getStorageCache($domain);
|
||||||
|
User::whereNull('status')->when($startCache, function($query, $startCache) {
|
||||||
|
return $query->where('id', '>', $startCache);
|
||||||
|
})->chunk(50, function($users) use($bar, $url, $domain) {
|
||||||
foreach($users as $user) {
|
foreach($users as $user) {
|
||||||
|
$this->updateStorageCache($domain, $user->id);
|
||||||
$profile = Profile::find($user->profile_id);
|
$profile = Profile::find($user->profile_id);
|
||||||
if(!$profile) {
|
if(!$profile) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -120,6 +127,26 @@ class SendUpdateActor extends Command
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function touchStorageCache($domain)
|
||||||
|
{
|
||||||
|
$path = 'actor-update-cache/' . $domain;
|
||||||
|
if(!Storage::exists($path)) {
|
||||||
|
Storage::put($path, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getStorageCache($domain)
|
||||||
|
{
|
||||||
|
$path = 'actor-update-cache/' . $domain;
|
||||||
|
return Storage::get($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function updateStorageCache($domain, $value)
|
||||||
|
{
|
||||||
|
$path = 'actor-update-cache/' . $domain;
|
||||||
|
Storage::put($path, $value);
|
||||||
|
}
|
||||||
|
|
||||||
protected function actorObject($profile)
|
protected function actorObject($profile)
|
||||||
{
|
{
|
||||||
$permalink = $profile->permalink();
|
$permalink = $profile->permalink();
|
||||||
|
|
Loading…
Reference in a new issue