[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
217c8a3933
commit
9733f3c02c
|
@ -116,18 +116,17 @@ class apActorFollowersAction extends ManagedAction
|
||||||
*/
|
*/
|
||||||
public static function generate_followers($profile, $since, $limit)
|
public static function generate_followers($profile, $since, $limit)
|
||||||
{
|
{
|
||||||
/* Fetch Followers */
|
$subs = [];
|
||||||
try {
|
try {
|
||||||
$sub = Activitypub_profile::getSubscribers($profile, $since, $limit);
|
$sub = Activitypub_profile::getSubscribers($profile, $since, $limit);
|
||||||
} catch (NoResultException $e) {
|
|
||||||
// Just let the exception go on its merry way
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get followers' URLs */
|
/* Get followers' URLs */
|
||||||
$subs = [];
|
|
||||||
foreach ($sub as $s) {
|
foreach ($sub as $s) {
|
||||||
$subs[] = ActivityPubPlugin::actor_uri($s);
|
$subs[] = ActivityPubPlugin::actor_uri($s);
|
||||||
}
|
}
|
||||||
|
} catch (NoResultException $e) {
|
||||||
|
// Just let the exception go on its merry way
|
||||||
|
}
|
||||||
|
|
||||||
return $subs;
|
return $subs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,18 +116,17 @@ class apActorFollowingAction extends ManagedAction
|
||||||
*/
|
*/
|
||||||
public function generate_following($profile, $since, $limit)
|
public function generate_following($profile, $since, $limit)
|
||||||
{
|
{
|
||||||
/* Fetch Following */
|
$subs = [];
|
||||||
try {
|
try {
|
||||||
$sub = Activitypub_profile::getSubscribed($profile, $since, $limit);
|
$sub = Activitypub_profile::getSubscribed($profile, $since, $limit);
|
||||||
} catch (NoResultException $e) {
|
|
||||||
// Just let the exception go on its merry way
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get followed' URLs */
|
/* Get followed' URLs */
|
||||||
$subs = [];
|
|
||||||
foreach ($sub as $s) {
|
foreach ($sub as $s) {
|
||||||
$subs[] = ActivityPubPlugin::actor_uri($s);
|
$subs[] = ActivityPubPlugin::actor_uri($s);
|
||||||
}
|
}
|
||||||
|
} catch (NoResultException $e) {
|
||||||
|
// Just let the exception go on its merry way
|
||||||
|
}
|
||||||
|
|
||||||
return $subs;
|
return $subs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -505,9 +505,8 @@ class Activitypub_profile extends Managed_DataObject
|
||||||
|
|
||||||
$sub = new Subscription();
|
$sub = new Subscription();
|
||||||
$sub->subscribed = $profile->id;
|
$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 != subscribed');
|
||||||
|
$sub->whereAdd('subscriber IN (SELECT id FROM user UNION SELECT profile_id FROM activitypub_profile)');
|
||||||
$cnt = $sub->count('distinct subscriber');
|
$cnt = $sub->count('distinct subscriber');
|
||||||
|
|
||||||
self::cacheSet(sprintf('activitypub_profile:subscriberCount:%d', $profile->id), $cnt);
|
self::cacheSet(sprintf('activitypub_profile:subscriberCount:%d', $profile->id), $cnt);
|
||||||
|
@ -532,9 +531,8 @@ class Activitypub_profile extends Managed_DataObject
|
||||||
|
|
||||||
$sub = new Subscription();
|
$sub = new Subscription();
|
||||||
$sub->subscriber = $profile->id;
|
$sub->subscriber = $profile->id;
|
||||||
$sub->joinAdd(['subscribed', 'user:id'], 'LEFT');
|
|
||||||
$sub->joinAdd(['subscribed', 'activitypub_profile:profile_id'], 'LEFT');
|
|
||||||
$sub->whereAdd('subscriber != subscribed');
|
$sub->whereAdd('subscriber != subscribed');
|
||||||
|
$sub->whereAdd('subscribed IN (SELECT id FROM user UNION SELECT profile_id FROM activitypub_profile)');
|
||||||
$cnt = $sub->count('distinct subscribed');
|
$cnt = $sub->count('distinct subscribed');
|
||||||
|
|
||||||
self::cacheSet(sprintf('activitypub_profile:subscriptionCount:%d', $profile->id), $cnt);
|
self::cacheSet(sprintf('activitypub_profile:subscriptionCount:%d', $profile->id), $cnt);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user