From 498b46f70f162747307bd07c25e570a3bb664d90 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 30 Jan 2023 23:35:10 -0700 Subject: [PATCH 1/2] Update AccountService, fix actor cache invalidation --- app/Http/Controllers/Settings/HomeSettings.php | 5 +++-- app/Services/AccountService.php | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Settings/HomeSettings.php b/app/Http/Controllers/Settings/HomeSettings.php index e8d3d195e..a9592d7ce 100644 --- a/app/Http/Controllers/Settings/HomeSettings.php +++ b/app/Http/Controllers/Settings/HomeSettings.php @@ -17,6 +17,7 @@ use Mail; use Purify; use App\Mail\PasswordChange; use Illuminate\Http\Request; +use App\Services\AccountService; use App\Services\PronounService; trait HomeSettings @@ -99,10 +100,10 @@ trait HomeSettings } if ($changes === true) { - Cache::forget('user:account:id:'.$user->id); $user->save(); $profile->save(); - + Cache::forget('user:account:id:'.$user->id); + AccountService::del($profile->id); return redirect('/settings/home')->with('status', 'Profile successfully updated!'); } diff --git a/app/Services/AccountService.php b/app/Services/AccountService.php index eb744ff9d..ea64855ce 100644 --- a/app/Services/AccountService.php +++ b/app/Services/AccountService.php @@ -71,6 +71,7 @@ class AccountService public static function del($id) { + Cache::forget('pf:activitypub:user-object:by-id:' . $id); return Cache::forget(self::CACHE_KEY . $id); } From 5a5d00b9470442dd1dfdfe3e71301d7136682cb2 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 31 Jan 2023 00:15:41 -0700 Subject: [PATCH 2/2] Update ap pipelines --- app/Jobs/SharePipeline/SharePipeline.php | 10 ++++++---- app/Jobs/SharePipeline/UndoSharePipeline.php | 10 ++++++---- app/Jobs/StatusPipeline/StatusActivityPubDeliver.php | 10 ++++++---- app/Jobs/StatusPipeline/StatusDelete.php | 10 ++++++---- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/app/Jobs/SharePipeline/SharePipeline.php b/app/Jobs/SharePipeline/SharePipeline.php index 1534a9f07..cd54b90eb 100644 --- a/app/Jobs/SharePipeline/SharePipeline.php +++ b/app/Jobs/SharePipeline/SharePipeline.php @@ -127,13 +127,15 @@ class SharePipeline implements ShouldQueue 'timeout' => config('federation.activitypub.delivery.timeout') ]); - $requests = function($audience) use ($client, $activity, $profile, $payload) { + $version = config('pixelfed.version'); + $appUrl = config('app.url'); + $userAgent = "(Pixelfed/{$version}; +{$appUrl})"; + + $requests = function($audience) use ($client, $activity, $profile, $payload, $userAgent) { foreach($audience as $url) { - $version = config('pixelfed.version'); - $appUrl = config('app.url'); $headers = HttpSignature::sign($profile, $url, $activity, [ 'Content-Type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', - 'User-Agent' => "(Pixelfed/{$version}; +{$appUrl})", + 'User-Agent' => $userAgent, ]); yield function() use ($client, $url, $headers, $payload) { return $client->postAsync($url, [ diff --git a/app/Jobs/SharePipeline/UndoSharePipeline.php b/app/Jobs/SharePipeline/UndoSharePipeline.php index 589a34fef..596d4d2da 100644 --- a/app/Jobs/SharePipeline/UndoSharePipeline.php +++ b/app/Jobs/SharePipeline/UndoSharePipeline.php @@ -90,13 +90,15 @@ class UndoSharePipeline implements ShouldQueue 'timeout' => config('federation.activitypub.delivery.timeout') ]); - $requests = function($audience) use ($client, $activity, $profile, $payload) { + $version = config('pixelfed.version'); + $appUrl = config('app.url'); + $userAgent = "(Pixelfed/{$version}; +{$appUrl})"; + + $requests = function($audience) use ($client, $activity, $profile, $payload, $userAgent) { foreach($audience as $url) { - $version = config('pixelfed.version'); - $appUrl = config('app.url'); $headers = HttpSignature::sign($profile, $url, $activity, [ 'Content-Type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', - 'User-Agent' => "(Pixelfed/{$version}; +{$appUrl})", + 'User-Agent' => $userAgent, ]); yield function() use ($client, $url, $headers, $payload) { return $client->postAsync($url, [ diff --git a/app/Jobs/StatusPipeline/StatusActivityPubDeliver.php b/app/Jobs/StatusPipeline/StatusActivityPubDeliver.php index 21295beb2..ca77ff7fc 100644 --- a/app/Jobs/StatusPipeline/StatusActivityPubDeliver.php +++ b/app/Jobs/StatusPipeline/StatusActivityPubDeliver.php @@ -85,13 +85,15 @@ class StatusActivityPubDeliver implements ShouldQueue 'timeout' => config('federation.activitypub.delivery.timeout') ]); - $requests = function($audience) use ($client, $activity, $profile, $payload) { + $version = config('pixelfed.version'); + $appUrl = config('app.url'); + $userAgent = "(Pixelfed/{$version}; +{$appUrl})"; + + $requests = function($audience) use ($client, $activity, $profile, $payload, $userAgent) { foreach($audience as $url) { - $version = config('pixelfed.version'); - $appUrl = config('app.url'); $headers = HttpSignature::sign($profile, $url, $activity, [ 'Content-Type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', - 'User-Agent' => "(Pixelfed/{$version}; +{$appUrl})", + 'User-Agent' => $userAgent, ]); yield function() use ($client, $url, $headers, $payload) { return $client->postAsync($url, [ diff --git a/app/Jobs/StatusPipeline/StatusDelete.php b/app/Jobs/StatusPipeline/StatusDelete.php index 6a003bcce..d7f237e20 100644 --- a/app/Jobs/StatusPipeline/StatusDelete.php +++ b/app/Jobs/StatusPipeline/StatusDelete.php @@ -164,13 +164,15 @@ class StatusDelete implements ShouldQueue 'timeout' => config('federation.activitypub.delivery.timeout') ]); - $requests = function($audience) use ($client, $activity, $profile, $payload) { + $version = config('pixelfed.version'); + $appUrl = config('app.url'); + $userAgent = "(Pixelfed/{$version}; +{$appUrl})"; + + $requests = function($audience) use ($client, $activity, $profile, $payload, $userAgent) { foreach($audience as $url) { - $version = config('pixelfed.version'); - $appUrl = config('app.url'); $headers = HttpSignature::sign($profile, $url, $activity, [ 'Content-Type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', - 'User-Agent' => "(Pixelfed/{$version}; +{$appUrl})", + 'User-Agent' => $userAgent, ]); yield function() use ($client, $url, $headers, $payload) { return $client->postAsync($url, [