Update HttpSignature

This commit is contained in:
Daniel Supernault 2023-04-19 18:57:40 -06:00
parent b43f06abaf
commit f17ca9d904
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
3 changed files with 18 additions and 6 deletions

View file

@ -282,14 +282,22 @@ class AccountController extends Controller
$filterable['id'] = $profile->id; $filterable['id'] = $profile->id;
$filterable['type'] = $class; $filterable['type'] = $class;
Follower::whereProfileId($profile->id)->whereFollowingId($pid)->delete(); $followed = Follower::whereProfileId($profile->id)->whereFollowingId($pid)->first();
if($followed) {
$followed->delete();
$selfProfile = $request->user()->profile;
$selfProfile->followers_count = Follower::whereFollowingId($pid)->count();
$selfProfile->save();
AccountService::del($selfProfile->id);
}
Notification::whereProfileId($pid) Notification::whereProfileId($pid)
->whereActorId($profile->id) ->whereActorId($profile->id)
->get() ->get()
->map(function($n) use($pid) { ->map(function($n) use($pid) {
NotificationService::del($pid, $n['id']); NotificationService::del($pid, $n['id']);
$n->forceDelete(); $n->forceDelete();
}); });
break; break;
} }

View file

@ -7,6 +7,7 @@ use App\Profile;
use App\Util\ActivityPub\Helpers; use App\Util\ActivityPub\Helpers;
use App\Util\ActivityPub\HttpSignature; use App\Util\ActivityPub\HttpSignature;
use Illuminate\Http\Client\ConnectionException; use Illuminate\Http\Client\ConnectionException;
use Illuminate\Http\Client\RequestException;
class ActivityPubFetchService class ActivityPubFetchService
{ {
@ -17,13 +18,16 @@ class ActivityPubFetchService
} }
$headers = HttpSignature::instanceActorSign($url, false); $headers = HttpSignature::instanceActorSign($url, false);
$headers['Accept'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'; $headers['Accept'] = 'application/activity+json';
$headers['User-Agent'] = '(Pixelfed/'.config('pixelfed.version').'; +'.config('app.url').')';
try { try {
$res = Http::withHeaders($headers) $res = Http::withHeaders($headers)
->timeout(10) ->timeout(30)
->connectTimeout(5)
->retry(3, 500)
->get($url); ->get($url);
} catch (RequestException $e) {
return;
} catch (ConnectionException $e) { } catch (ConnectionException $e) {
return; return;
} catch (Exception $e) { } catch (Exception $e) {

View file

@ -130,8 +130,8 @@ class HttpSignature {
$headers = [ $headers = [
'(request-target)' => 'post '.parse_url($url, PHP_URL_PATH), '(request-target)' => 'post '.parse_url($url, PHP_URL_PATH),
'Date' => $date->format('D, d M Y H:i:s \G\M\T'),
'Host' => parse_url($url, PHP_URL_HOST), 'Host' => parse_url($url, PHP_URL_HOST),
'Date' => $date->format('D, d M Y H:i:s \G\M\T'),
]; ];
if($digest) { if($digest) {