From e38a699324c36e1a5cc3d6746a419df40f6b0bf3 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Dec 2023 17:16:10 +0000 Subject: [PATCH] Fix for profile limitation / configurable list of limited servers --- src/Protocol/ActivityPub.php | 10 ++++++++++ src/Protocol/ActivityPub/Transmitter.php | 4 ++-- static/defaults.config.php | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Protocol/ActivityPub.php b/src/Protocol/ActivityPub.php index c27506ec1e..a9ede518ed 100644 --- a/src/Protocol/ActivityPub.php +++ b/src/Protocol/ActivityPub.php @@ -24,6 +24,7 @@ namespace Friendica\Protocol; use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; +use Friendica\DI; use Friendica\Model\APContact; use Friendica\Model\Contact; use Friendica\Model\User; @@ -305,6 +306,15 @@ class ActivityPub return false; } + $limited = DI::config()->get('system', 'limited_servers'); + if (!empty($limited)) { + $servers = explode(',', str_replace(' ', '', $limited)); + $host = parse_url($contact['baseurl'], PHP_URL_HOST); + if (!empty($host) && in_array($host, $servers)) { + return false; + } + } + // @todo Look for user blocked domains Logger::debug('Server is an accepted requester', ['uid' => $uid, 'id' => $apcontact['gsid'], 'url' => $apcontact['baseurl'], 'signer' => $signer, 'called_by' => $called_by]); diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index c15ee42dfe..94655eead1 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -373,9 +373,9 @@ class Transmitter } $data['preferredUsername'] = $owner['nick']; - $data['name'] = $owner['name']; + $data['name'] = $full ? $owner['name'] : $owner['nick']; - if (!$full && !empty($owner['country-name'] . $owner['region'] . $owner['locality'])) { + if ($full && !empty($owner['country-name'] . $owner['region'] . $owner['locality'])) { $data['vcard:hasAddress'] = ['@type' => 'vcard:Home', 'vcard:country-name' => $owner['country-name'], 'vcard:region' => $owner['region'], 'vcard:locality' => $owner['locality']]; } diff --git a/static/defaults.config.php b/static/defaults.config.php index 3eedd8a901..b33b30b562 100644 --- a/static/defaults.config.php +++ b/static/defaults.config.php @@ -325,6 +325,10 @@ return [ // Don't update the "commented" value of an item when it is liked. 'like_no_comment' => false, + // limited_servers (String) + // A comma separated list of server hostnames that should get limited profile data + 'limited_servers' => '', + // local_tags (Boolean) // If activated, all hashtags will point to the local server. 'local_tags' => true, -- 2.39.5