From a11206dbcd662a73d1c8200f2bef5287533cdbe6 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 21 Jul 2019 05:56:57 +0000 Subject: [PATCH] Issue 6675: Improved check for follower, removed global setting --- src/Module/Admin/Site.php | 3 --- src/Protocol/OStatus.php | 11 ++++++++--- view/templates/admin/site.tpl | 1 - view/theme/frio/templates/admin/site.tpl | 1 - 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Module/Admin/Site.php b/src/Module/Admin/Site.php index 8e36d86505..c899729f8e 100644 --- a/src/Module/Admin/Site.php +++ b/src/Module/Admin/Site.php @@ -166,7 +166,6 @@ class Site extends BaseAdminModule $nodeinfo = !empty($_POST['nodeinfo']); $dfrn_only = !empty($_POST['dfrn_only']); $ostatus_disabled = !empty($_POST['ostatus_disabled']); - $ostatus_full_threads = !empty($_POST['ostatus_full_threads']); $diaspora_enabled = !empty($_POST['diaspora_enabled']); $ssl_policy = (!empty($_POST['ssl_policy']) ? intval($_POST['ssl_policy']) : 0); $force_ssl = !empty($_POST['force_ssl']); @@ -361,7 +360,6 @@ class Site extends BaseAdminModule Config::set('system', 'curl_timeout' , $timeout); Config::set('system', 'dfrn_only' , $dfrn_only); Config::set('system', 'ostatus_disabled' , $ostatus_disabled); - Config::set('system', 'ostatus_full_threads' , $ostatus_full_threads); Config::set('system', 'diaspora_enabled' , $diaspora_enabled); Config::set('config', 'private_addons' , $private_addons); @@ -627,7 +625,6 @@ class Site extends BaseAdminModule '$community_page_style' => ['community_page_style', L10n::t('Community pages for visitors'), Config::get('system', 'community_page_style'), L10n::t('Which community pages should be available for visitors. Local users always see both pages.'), $community_page_style_choices], '$max_author_posts_community_page' => ['max_author_posts_community_page', L10n::t('Posts per user on community page'), Config::get('system', 'max_author_posts_community_page'), L10n::t('The maximum number of posts per user on the community page. (Not valid for "Global Community")')], '$ostatus_disabled' => ['ostatus_disabled', L10n::t('Disable OStatus support'), Config::get('system', 'ostatus_disabled'), L10n::t('Disable built-in OStatus (StatusNet, GNU Social etc.) compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.')], - '$ostatus_full_threads' => ['ostatus_full_threads', L10n::t('Only import OStatus threads from our contacts'), Config::get('system', 'ostatus_full_threads'), L10n::t('Normally we import every content from our OStatus contacts. With this option we only store threads that are started by a contact that is known on our system.')], '$ostatus_not_able' => L10n::t('OStatus support can only be enabled if threading is enabled.'), '$diaspora_able' => $diaspora_able, '$diaspora_not_able' => L10n::t('Diaspora support can\'t be enabled because Friendica was installed into a sub directory.'), diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 127773f3c6..b3685a1475 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -10,6 +10,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Cache; use Friendica\Core\Config; +use Friendica\Core\PConfig; use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Core\Lock; @@ -19,6 +20,7 @@ use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Model\Conversation; use Friendica\Model\GContact; +use Friendica\Model\APContact; use Friendica\Model\Item; use Friendica\Model\User; use Friendica\Network\Probe; @@ -113,6 +115,8 @@ class OStatus if (DBA::isResult($contact)) { if ($contact['blocked']) { $contact['id'] = -1; + } elseif (!empty(APContact::getByURL($contact['url'], false))) { + ActivityPub\Receiver::switchContact($contact['id'], $importer['uid'], $contact['url']); } $author["contact-id"] = $contact["id"]; } @@ -486,10 +490,11 @@ class OStatus if ($initialize && (count(self::$itemlist) > 0)) { if (self::$itemlist[0]['uri'] == self::$itemlist[0]['parent-uri']) { // We will import it everytime, when it is started by our contacts - $valid = !empty(self::$itemlist[0]['contact-id']); + $valid = Contact::isSharingByURL(self::$itemlist[0]['author-link'], self::$itemlist[0]['uid']); + if (!$valid) { // If not, then it depends on this setting - $valid = !Config::get('system', 'ostatus_full_threads'); + $valid = ((self::$itemlist[0]['uid'] == 0) || !PConfig::get(self::$itemlist[0]['uid'], 'system', 'accept_only_sharer', false)); if ($valid) { Logger::log("Item with uri ".self::$itemlist[0]['uri']." will be imported due to the system settings.", Logger::DEBUG); } @@ -501,7 +506,7 @@ class OStatus $valid = false; $verbs = [ACTIVITY_POST, ACTIVITY_SHARE]; foreach (self::$itemlist as $item) { - if (!empty($item['contact-id']) && in_array($item['verb'], $verbs)) { + if (in_array($item['verb'], $verbs) && Contact::isSharingByURL($item['author-link'], $item['uid'])) { $valid = true; } } diff --git a/view/templates/admin/site.tpl b/view/templates/admin/site.tpl index 823753768e..19774b4255 100644 --- a/view/templates/admin/site.tpl +++ b/view/templates/admin/site.tpl @@ -59,7 +59,6 @@ {{include file="field_input.tpl" field=$max_author_posts_community_page}} {{include file="field_checkbox.tpl" field=$ostatus_disabled}} - {{include file="field_checkbox.tpl" field=$ostatus_full_threads}} {{if $diaspora_able}} {{include file="field_checkbox.tpl" field=$diaspora_enabled}} diff --git a/view/theme/frio/templates/admin/site.tpl b/view/theme/frio/templates/admin/site.tpl index 4c0a6ce066..410f9443f7 100644 --- a/view/theme/frio/templates/admin/site.tpl +++ b/view/theme/frio/templates/admin/site.tpl @@ -138,7 +138,6 @@ {{include file="field_input.tpl" field=$max_author_posts_community_page}} {{include file="field_checkbox.tpl" field=$ostatus_disabled}} - {{include file="field_checkbox.tpl" field=$ostatus_full_threads}} {{if $diaspora_able}} {{include file="field_checkbox.tpl" field=$diaspora_enabled}}