store follow counts

This commit is contained in:
Mike Macgirvin 2024-06-28 21:58:16 +10:00
parent 4b1fd36e86
commit 31fa60f6eb
2 changed files with 28 additions and 12 deletions

View file

@ -2573,9 +2573,9 @@ class Activity
}
$m = parse_url($url);
if ($m['scheme'] && $m['host']) {
$site_url = $m['scheme'] . '://' . $m['host'] . (($m['port']) ? ':' . $m['port'] : '');
$collection = parse_url($url);
if ($collection['scheme'] && $collection['host']) {
$site_url = $collection['scheme'] . '://' . $collection['host'] . (($collection['port']) ? ':' . $collection['port'] : '');
if (!SConfig::Get($site_url,'system','owa')) {
if ($webfinger === null) {
$webfinger = Webfinger::exec($webfingerAddress);
@ -2638,6 +2638,20 @@ class Activity
if ($collections) {
set_xconfig($url, 'activitypub', 'collections', $collections);
$followers = $following = 'unset';
if (isset($collections['followers'])) {
$collection = Activity::fetch($collections['followers']);
if (is_array($collection) && isset($collection['totalItems'])) {
$followers = intval($collection['totalItems']);
}
}
if (isset($collections['following'])) {
$collection = Activity::fetch($collections['following']);
if (is_array($collection) && isset($collection['totalItems'])) {
$following = intval($collection['totalItems']);
}
}
set_xconfig($url, 'activitypub', 'follows', $followers . '/' . $following);
}
$h = q(
@ -2646,10 +2660,10 @@ class Activity
);
$m = parse_url($url);
if ($m) {
$hostname = $m['host'];
$baseurl = $m['scheme'] . '://' . $m['host'] . ((isset($m['port']) && intval($m['port'])) ? ':' . $m['port'] : '');
$collection = parse_url($url);
if ($collection) {
$hostname = $collection['host'];
$baseurl = $collection['scheme'] . '://' . $collection['host'] . ((isset($collection['port']) && intval($collection['port'])) ? ':' . $collection['port'] : '');
}
if (!$h) {

View file

@ -3,6 +3,7 @@
namespace Code\Module;
use App;
use Code\Lib\XConfig;
use Code\Web\Controller;
use Code\Lib\Libzot;
use Code\Lib\Zotfinger;
@ -115,10 +116,9 @@ class Chanview extends Controller
$about = zidify_links(bbcode($xprof[0]['xprof_about']));
}
$followers = t('Not available');
$following = t('Not available');
$followers = $following = 'unset';
$f = get_xconfig(App::$poi['xchan_hash'], 'activitypub', 'collections');
$f = XConfig::Get(App::$poi['xchan_hash'], 'activitypub', 'collections');
if ($f && isset($f['followers'])) {
$m = Activity::fetch($f['followers']);
if (is_array($m) && isset($m['totalItems'])) {
@ -131,6 +131,8 @@ class Chanview extends Controller
$following = intval($m['totalItems']);
}
}
XConfig::Set(App::$poi['xchan_hash'], 'activitypub', 'follows', $followers . '/' . $following);
$o = replace_macros(Theme::get_template('chanview.tpl'), [
'$url' => $url,
@ -139,8 +141,8 @@ class Chanview extends Controller
'$about' => $about,
'$followers_txt' => t('Followers'),
'$following_txt' => t('Following'),
'$followers' => $followers,
'$following' => $following,
'$followers' => (($followers === 'unset') ? t('Not available') : $followers),
'$following' => (($following === 'unset') ? t('Not available') : $following),
'$visit' => t('Visit'),
'$outbox' => $load_outbox,
'$view' => t('View Recent'),