mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 22:41:27 +00:00
Update MovePipeline
This commit is contained in:
parent
5cc34b161b
commit
15a4e53382
2 changed files with 14 additions and 9 deletions
|
@ -10,22 +10,25 @@ use DB;
|
||||||
use Exception;
|
use Exception;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Pool;
|
use GuzzleHttp\Pool;
|
||||||
|
use GuzzleHttp\Psr7\Request;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Queue\Queueable;
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
use Illuminate\Queue\Middleware\ThrottlesExceptionsWithRedis;
|
use Illuminate\Queue\Middleware\ThrottlesExceptionsWithRedis;
|
||||||
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use GuzzleHttp\Psr7\Request;
|
|
||||||
|
|
||||||
class MoveMigrateFollowersPipeline implements ShouldQueue
|
class MoveMigrateFollowersPipeline implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
public string $target;
|
public string $target;
|
||||||
|
|
||||||
public string $activity;
|
public string $activity;
|
||||||
|
|
||||||
public int $tries = 15;
|
public int $tries = 15;
|
||||||
|
|
||||||
public int $maxExceptions = 5;
|
public int $maxExceptions = 5;
|
||||||
|
|
||||||
public int $timeout = 900;
|
public int $timeout = 900;
|
||||||
|
|
||||||
public function __construct(string $target, string $activity)
|
public function __construct(string $target, string $activity)
|
||||||
|
@ -55,7 +58,7 @@ class MoveMigrateFollowersPipeline implements ShouldQueue
|
||||||
$targetAccount = $this->fetchProfile($this->target);
|
$targetAccount = $this->fetchProfile($this->target);
|
||||||
$actorAccount = $this->fetchProfile($this->activity);
|
$actorAccount = $this->fetchProfile($this->activity);
|
||||||
|
|
||||||
if (!$targetAccount || !$actorAccount) {
|
if (! $targetAccount || ! $actorAccount) {
|
||||||
throw new Exception('Invalid move accounts');
|
throw new Exception('Invalid move accounts');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +79,7 @@ class MoveMigrateFollowersPipeline implements ShouldQueue
|
||||||
Log::error('MoveMigrateFollowersPipeline failed', [
|
Log::error('MoveMigrateFollowersPipeline failed', [
|
||||||
'target' => $this->target,
|
'target' => $this->target,
|
||||||
'activity' => $this->activity,
|
'activity' => $this->activity,
|
||||||
'error' => $e->getMessage()
|
'error' => $e->getMessage(),
|
||||||
]);
|
]);
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +87,7 @@ class MoveMigrateFollowersPipeline implements ShouldQueue
|
||||||
|
|
||||||
private function validateEnvironment(): void
|
private function validateEnvironment(): void
|
||||||
{
|
{
|
||||||
if (config('app.env') !== 'production' || !(bool)config('federation.activitypub.enabled')) {
|
if (config('app.env') !== 'production' || ! (bool) config('federation.activitypub.enabled')) {
|
||||||
throw new Exception('ActivityPub not enabled');
|
throw new Exception('ActivityPub not enabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +124,7 @@ class MoveMigrateFollowersPipeline implements ShouldQueue
|
||||||
private function generateRequests($followers, string $targetInbox, int $targetPid): \Generator
|
private function generateRequests($followers, string $targetInbox, int $targetPid): \Generator
|
||||||
{
|
{
|
||||||
foreach ($followers as $follower) {
|
foreach ($followers as $follower) {
|
||||||
if (!$this->isValidFollower($follower)) {
|
if (! $this->isValidFollower($follower)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,11 @@ class UnfollowLegacyAccountMovePipeline implements ShouldQueue
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
public string $target;
|
public string $target;
|
||||||
|
|
||||||
public string $activity;
|
public string $activity;
|
||||||
|
|
||||||
public int $tries = 6;
|
public int $tries = 6;
|
||||||
|
|
||||||
public int $maxExceptions = 3;
|
public int $maxExceptions = 3;
|
||||||
|
|
||||||
public function __construct(string $target, string $activity)
|
public function __construct(string $target, string $activity)
|
||||||
|
@ -53,7 +55,7 @@ class UnfollowLegacyAccountMovePipeline implements ShouldQueue
|
||||||
$targetAccount = $this->fetchProfile($this->target);
|
$targetAccount = $this->fetchProfile($this->target);
|
||||||
$actorAccount = $this->fetchProfile($this->activity);
|
$actorAccount = $this->fetchProfile($this->activity);
|
||||||
|
|
||||||
if (!$targetAccount || !$actorAccount) {
|
if (! $targetAccount || ! $actorAccount) {
|
||||||
throw new Exception('Invalid move accounts');
|
throw new Exception('Invalid move accounts');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +68,7 @@ class UnfollowLegacyAccountMovePipeline implements ShouldQueue
|
||||||
Log::error('UnfollowLegacyAccountMovePipeline failed', [
|
Log::error('UnfollowLegacyAccountMovePipeline failed', [
|
||||||
'target' => $this->target,
|
'target' => $this->target,
|
||||||
'activity' => $this->activity,
|
'activity' => $this->activity,
|
||||||
'error' => $e->getMessage()
|
'error' => $e->getMessage(),
|
||||||
]);
|
]);
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +76,7 @@ class UnfollowLegacyAccountMovePipeline implements ShouldQueue
|
||||||
|
|
||||||
private function validateEnvironment(): void
|
private function validateEnvironment(): void
|
||||||
{
|
{
|
||||||
if (config('app.env') !== 'production' || !(bool)config('federation.activitypub.enabled')) {
|
if (config('app.env') !== 'production' || ! (bool) config('federation.activitypub.enabled')) {
|
||||||
throw new Exception('ActivityPub not enabled');
|
throw new Exception('ActivityPub not enabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +126,7 @@ class UnfollowLegacyAccountMovePipeline implements ShouldQueue
|
||||||
private function generateRequests($followers, string $targetInbox, int $targetPid): \Generator
|
private function generateRequests($followers, string $targetInbox, int $targetPid): \Generator
|
||||||
{
|
{
|
||||||
foreach ($followers as $follower) {
|
foreach ($followers as $follower) {
|
||||||
if (!$this->isValidFollower($follower)) {
|
if (! $this->isValidFollower($follower)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue