[AP] Fix Follow collections
Activitypub_profile: - Fix subscription-counter getter functions, invalid profiles were being counted apActorFollowingAction: - Small rewrite of generate_following, didn't make sense to not use try-catch block apActorFollowersAction: - Small rewrite of generate_followers, didn't make sense to not use try-catch block
This commit is contained in:
parent
83f179989e
commit
3852ad175f
|
@ -116,19 +116,18 @@ class apActorFollowersAction extends ManagedAction
|
|||
*/
|
||||
public static function generate_followers($profile, $since, $limit)
|
||||
{
|
||||
/* Fetch Followers */
|
||||
$subs = [];
|
||||
try {
|
||||
$sub = Activitypub_profile::getSubscribers($profile, $since, $limit);
|
||||
|
||||
/* Get followers' URLs */
|
||||
foreach ($sub as $s) {
|
||||
$subs[] = ActivityPubPlugin::actor_uri($s);
|
||||
}
|
||||
} catch (NoResultException $e) {
|
||||
// Just let the exception go on its merry way
|
||||
}
|
||||
|
||||
/* Get followers' URLs */
|
||||
$subs = [];
|
||||
foreach ($sub as $s) {
|
||||
$subs[] = ActivityPubPlugin::actor_uri($s);
|
||||
}
|
||||
|
||||
return $subs;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,19 +116,18 @@ class apActorFollowingAction extends ManagedAction
|
|||
*/
|
||||
public function generate_following($profile, $since, $limit)
|
||||
{
|
||||
/* Fetch Following */
|
||||
$subs = [];
|
||||
try {
|
||||
$sub = Activitypub_profile::getSubscribed($profile, $since, $limit);
|
||||
|
||||
/* Get followed' URLs */
|
||||
foreach ($sub as $s) {
|
||||
$subs[] = ActivityPubPlugin::actor_uri($s);
|
||||
}
|
||||
} catch (NoResultException $e) {
|
||||
// Just let the exception go on its merry way
|
||||
}
|
||||
|
||||
/* Get followed' URLs */
|
||||
$subs = [];
|
||||
foreach ($sub as $s) {
|
||||
$subs[] = ActivityPubPlugin::actor_uri($s);
|
||||
}
|
||||
|
||||
return $subs;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -505,9 +505,8 @@ class Activitypub_profile extends Managed_DataObject
|
|||
|
||||
$sub = new Subscription();
|
||||
$sub->subscribed = $profile->id;
|
||||
$sub->joinAdd(['subscriber', 'user:id'], 'LEFT');
|
||||
$sub->joinAdd(['subscriber', 'activitypub_profile:profile_id'], 'LEFT');
|
||||
$sub->whereAdd('subscriber != subscribed');
|
||||
$sub->whereAdd('subscriber IN (SELECT id FROM user UNION SELECT profile_id FROM activitypub_profile)');
|
||||
$cnt = $sub->count('distinct subscriber');
|
||||
|
||||
self::cacheSet(sprintf('activitypub_profile:subscriberCount:%d', $profile->id), $cnt);
|
||||
|
@ -532,9 +531,8 @@ class Activitypub_profile extends Managed_DataObject
|
|||
|
||||
$sub = new Subscription();
|
||||
$sub->subscriber = $profile->id;
|
||||
$sub->joinAdd(['subscribed', 'user:id'], 'LEFT');
|
||||
$sub->joinAdd(['subscribed', 'activitypub_profile:profile_id'], 'LEFT');
|
||||
$sub->whereAdd('subscriber != subscribed');
|
||||
$sub->whereAdd('subscribed IN (SELECT id FROM user UNION SELECT profile_id FROM activitypub_profile)');
|
||||
$cnt = $sub->count('distinct subscribed');
|
||||
|
||||
self::cacheSet(sprintf('activitypub_profile:subscriptionCount:%d', $profile->id), $cnt);
|
||||
|
|
Loading…
Reference in New Issue
Block a user