mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update Federation, use proper Content-Type headers for following/follower collections
This commit is contained in:
parent
221fe43638
commit
fb0bb9a34f
2 changed files with 20 additions and 2 deletions
|
@ -253,7 +253,7 @@ class FederationController extends Controller
|
||||||
'type' => 'OrderedCollection',
|
'type' => 'OrderedCollection',
|
||||||
'totalItems' => $account['following_count'] ?? 0,
|
'totalItems' => $account['following_count'] ?? 0,
|
||||||
];
|
];
|
||||||
return response()->json($obj);
|
return response()->json($obj)->header('Content-Type', 'application/activity+json');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function userFollowers(Request $request, $username)
|
public function userFollowers(Request $request, $username)
|
||||||
|
@ -269,6 +269,6 @@ class FederationController extends Controller
|
||||||
'type' => 'OrderedCollection',
|
'type' => 'OrderedCollection',
|
||||||
'totalItems' => $account['followers_count'] ?? 0,
|
'totalItems' => $account['followers_count'] ?? 0,
|
||||||
];
|
];
|
||||||
return response()->json($obj);
|
return response()->json($obj)->header('Content-Type', 'application/activity+json');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -372,6 +372,10 @@ class Helpers {
|
||||||
$idDomain = parse_url($id, PHP_URL_HOST);
|
$idDomain = parse_url($id, PHP_URL_HOST);
|
||||||
$urlDomain = parse_url($url, PHP_URL_HOST);
|
$urlDomain = parse_url($url, PHP_URL_HOST);
|
||||||
|
|
||||||
|
if($idDomain && $urlDomain && strtolower($idDomain) !== strtolower($urlDomain)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(!self::validateUrl($id)) {
|
if(!self::validateUrl($id)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -455,14 +459,21 @@ class Helpers {
|
||||||
|
|
||||||
public static function storeStatus($url, $profile, $activity)
|
public static function storeStatus($url, $profile, $activity)
|
||||||
{
|
{
|
||||||
|
$originalUrl = $url;
|
||||||
$id = isset($activity['id']) ? self::pluckval($activity['id']) : self::pluckval($activity['url']);
|
$id = isset($activity['id']) ? self::pluckval($activity['id']) : self::pluckval($activity['url']);
|
||||||
$url = isset($activity['url']) && is_string($activity['url']) ? self::pluckval($activity['url']) : self::pluckval($id);
|
$url = isset($activity['url']) && is_string($activity['url']) ? self::pluckval($activity['url']) : self::pluckval($id);
|
||||||
$idDomain = parse_url($id, PHP_URL_HOST);
|
$idDomain = parse_url($id, PHP_URL_HOST);
|
||||||
$urlDomain = parse_url($url, PHP_URL_HOST);
|
$urlDomain = parse_url($url, PHP_URL_HOST);
|
||||||
|
$originalUrlDomain = parse_url($originalUrl, PHP_URL_HOST);
|
||||||
if(!self::validateUrl($id) || !self::validateUrl($url)) {
|
if(!self::validateUrl($id) || !self::validateUrl($url)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( strtolower($originalUrlDomain) !== strtolower($idDomain) ||
|
||||||
|
strtolower($originalUrlDomain) !== strtolower($urlDomain) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$reply_to = self::getReplyTo($activity);
|
$reply_to = self::getReplyTo($activity);
|
||||||
|
|
||||||
$ts = self::pluckval($activity['published']);
|
$ts = self::pluckval($activity['published']);
|
||||||
|
@ -763,7 +774,11 @@ class Helpers {
|
||||||
if(!$res || isset($res['id']) == false) {
|
if(!$res || isset($res['id']) == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$urlDomain = parse_url($url, PHP_URL_HOST);
|
||||||
$domain = parse_url($res['id'], PHP_URL_HOST);
|
$domain = parse_url($res['id'], PHP_URL_HOST);
|
||||||
|
if(strtolower($urlDomain) !== strtolower($domain)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(!isset($res['preferredUsername']) && !isset($res['nickname'])) {
|
if(!isset($res['preferredUsername']) && !isset($res['nickname'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -831,6 +846,9 @@ class Helpers {
|
||||||
|
|
||||||
public static function sendSignedObject($profile, $url, $body)
|
public static function sendSignedObject($profile, $url, $body)
|
||||||
{
|
{
|
||||||
|
if(app()->environment() !== 'production') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ActivityPubDeliveryService::queue()
|
ActivityPubDeliveryService::queue()
|
||||||
->from($profile)
|
->from($profile)
|
||||||
->to($url)
|
->to($url)
|
||||||
|
|
Loading…
Reference in a new issue