mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update FederationController, add proper following/follower counts
This commit is contained in:
parent
6ffc964371
commit
3204fb9669
1 changed files with 218 additions and 213 deletions
|
@ -30,6 +30,7 @@ use App\Util\ActivityPub\{
|
|||
};
|
||||
use Zttp\Zttp;
|
||||
use App\Services\InstanceService;
|
||||
use App\Services\AccountService;
|
||||
|
||||
class FederationController extends Controller
|
||||
{
|
||||
|
@ -239,12 +240,15 @@ class FederationController extends Controller
|
|||
{
|
||||
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 = [
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
'id' => $request->getUri(),
|
||||
'type' => 'OrderedCollectionPage',
|
||||
'totalItems' => 0,
|
||||
'orderedItems' => []
|
||||
'type' => 'OrderedCollection',
|
||||
'totalItems' => $account['following_count'] ?? 0,
|
||||
];
|
||||
return response()->json($obj);
|
||||
}
|
||||
|
@ -252,15 +256,16 @@ class FederationController extends Controller
|
|||
public function userFollowers(Request $request, $username)
|
||||
{
|
||||
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 = [
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
'id' => $request->getUri(),
|
||||
'type' => 'OrderedCollectionPage',
|
||||
'totalItems' => 0,
|
||||
'orderedItems' => []
|
||||
'type' => 'OrderedCollection',
|
||||
'totalItems' => $account['followers_count'] ?? 0,
|
||||
];
|
||||
|
||||
return response()->json($obj);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue