forked from mirror/pixelfed
Update FederationController, add proper following/follower counts
This commit is contained in:
parent
6ffc964371
commit
3204fb9669
|
@ -30,6 +30,7 @@ use App\Util\ActivityPub\{
|
||||||
};
|
};
|
||||||
use Zttp\Zttp;
|
use Zttp\Zttp;
|
||||||
use App\Services\InstanceService;
|
use App\Services\InstanceService;
|
||||||
|
use App\Services\AccountService;
|
||||||
|
|
||||||
class FederationController extends Controller
|
class FederationController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -239,12 +240,15 @@ class FederationController extends Controller
|
||||||
{
|
{
|
||||||
abort_if(!config_cache('federation.activitypub.enabled'), 404);
|
abort_if(!config_cache('federation.activitypub.enabled'), 404);
|
||||||
|
|
||||||
|
$id = AccountService::usernameToId($username);
|
||||||
|
abort_if(!$id, 404);
|
||||||
|
$account = AccountService::get($id);
|
||||||
|
abort_if(!$account || !isset($account['following_count']), 404);
|
||||||
$obj = [
|
$obj = [
|
||||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||||
'id' => $request->getUri(),
|
'id' => $request->getUri(),
|
||||||
'type' => 'OrderedCollectionPage',
|
'type' => 'OrderedCollection',
|
||||||
'totalItems' => 0,
|
'totalItems' => $account['following_count'] ?? 0,
|
||||||
'orderedItems' => []
|
|
||||||
];
|
];
|
||||||
return response()->json($obj);
|
return response()->json($obj);
|
||||||
}
|
}
|
||||||
|
@ -252,15 +256,16 @@ class FederationController extends Controller
|
||||||
public function userFollowers(Request $request, $username)
|
public function userFollowers(Request $request, $username)
|
||||||
{
|
{
|
||||||
abort_if(!config_cache('federation.activitypub.enabled'), 404);
|
abort_if(!config_cache('federation.activitypub.enabled'), 404);
|
||||||
|
$id = AccountService::usernameToId($username);
|
||||||
|
abort_if(!$id, 404);
|
||||||
|
$account = AccountService::get($id);
|
||||||
|
abort_if(!$account || !isset($account['followers_count']), 404);
|
||||||
$obj = [
|
$obj = [
|
||||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||||
'id' => $request->getUri(),
|
'id' => $request->getUri(),
|
||||||
'type' => 'OrderedCollectionPage',
|
'type' => 'OrderedCollection',
|
||||||
'totalItems' => 0,
|
'totalItems' => $account['followers_count'] ?? 0,
|
||||||
'orderedItems' => []
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return response()->json($obj);
|
return response()->json($obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue