Open AlternateRT opened 1 year ago
It's displaying the followers count from Vivaldi Social. I mean How many people are interacting with Pixelfed Account from that instance...
@neonota Ok, sure, but that doesn't explain why the post count is wrong (my instance is aware of the 10 posts the accopunt has made). And why not display the same followers count for the account like it is done in pixelfed.social, or how other Mastodon accounts do so when viewed in another different Mastodon instances?
Additionally, if I force fetch this account by searching for it with its URL, the three counts are all reset back to 0 :/
hm, the reason that pixelfed@pixelfed.social
is being set to 0 is because the collections seem to be advertising 0 totalItems
:
$ curl -H 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' https://pixelfed.social/users/pixelfed/followers
{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","id":"https:\/\/pixelfed.social\/users\/pixelfed\/followers","type":"OrderedCollectionPage","totalItems":0,"orderedItems":[]}
if i had to guess, something isn't wired up right -- this is expected behaviour for profiles that hide their followers, but not expected for profiles that don't hide their network. the outbox thing is just an oversight though
I looked into this problem today. The reason seems to be that it is hardcoded as 0.
I got it working by replacing the functions with this code:
public function userFollowing(Request $request, $username)
{
abort_if(!config_cache('federation.activitypub.enabled'), 404);
$profile = Profile::whereNull('domain')->whereUsername($username)->first();
if (!$profile) {
abort(404); // No profile found
}
$following = $profile->following;
$followingCount = $following->count();
$followingUsernames = $following->pluck('remote_url')->toArray();
$obj = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $request->getUri(),
'type' => 'OrderedCollectionPage',
'totalItems' => $followingCount,
'orderedItems' => $followingUsernames
];
return response()->json($obj);
}
public function userFollowers(Request $request, $username)
{
abort_if(!config_cache('federation.activitypub.enabled'), 404);
$profile = Profile::whereNull('domain')->whereUsername($username)->first();
if (!$profile) {
abort(404); // No profile found
}
$followers = $profile->followers;
$followersCount = $followers->count();
$followersUsernames = $followers->pluck('remote_url')->toArray();
$obj = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $request->getUri(),
'type' => 'OrderedCollectionPage',
'totalItems' => $followersCount,
'orderedItems' => $followersUsernames
];
return response()->json($obj);
}
This seems to work for Mastodon
I don't know anything about ActivityPub in general or the pixelfed codebase, so I don't feel comfortable opening a pull request for this. I don't know if I'm breaking anything or revealing information I shouldn't be revealing. But maybe this will help someone else to try and fix this problem.
Edit: Looks like this feature broke in this commit https://github.com/pixelfed/pixelfed/commit/7f4213924f9fdb14bb36043d17615e838b85b733#diff-b5309ee63eb1e5952f25c891ab227586940466a8b775b68e293f1b11ed865ed6R135-R180
I recently began following the official Pixelfed account from pixelfed.social in my Mastodon instance (social.vivaldi.net) when I realised that the posts, following, and followers counts were all weirdly wrong. This is what I see from my instance:
Instead, it should be displaying the same numbers that are displayed when viewing the profile from pixelfed.social: