[ActivityPub] Fix Postgres incompatible query in Following and Followed collection

This commit is contained in:
susdiv 2020-06-05 17:48:21 +00:00
parent 9e7794cd66
commit b8c0fa9fa0

View File

@ -554,10 +554,11 @@ class Activitypub_profile extends Managed_DataObject
return $cnt; return $cnt;
} }
$user_table = common_database_tablename('user');
$sub = new Subscription(); $sub = new Subscription();
$sub->subscribed = $profile->id; $sub->subscribed = $profile->id;
$sub->whereAdd('subscriber != subscribed'); $sub->whereAdd('subscriber != subscribed');
$sub->whereAdd('subscriber IN (SELECT id FROM user UNION SELECT profile_id FROM activitypub_profile)'); $sub->whereAdd("subscriber IN (SELECT id FROM {$user_table} UNION SELECT profile_id AS 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);
@ -581,10 +582,11 @@ class Activitypub_profile extends Managed_DataObject
return $cnt; return $cnt;
} }
$user_table = common_database_tablename('user');
$sub = new Subscription(); $sub = new Subscription();
$sub->subscriber = $profile->id; $sub->subscriber = $profile->id;
$sub->whereAdd('subscriber != subscribed'); $sub->whereAdd('subscriber != subscribed');
$sub->whereAdd('subscribed IN (SELECT id FROM user UNION SELECT profile_id FROM activitypub_profile)'); $sub->whereAdd("subscribed IN (SELECT id FROM {$user_table} UNION SELECT profile_id AS 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);