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['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)
->whereActorId($profile->id)
->get()
->map(function($n) use($pid) {
NotificationService::del($pid, $n['id']);
$n->forceDelete();
});
});
break;
}

View file

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

View file

@ -130,8 +130,8 @@ class HttpSignature {
$headers = [
'(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),
'Date' => $date->format('D, d M Y H:i:s \G\M\T'),
];
if($digest) {