]> git.mxchange.org Git - friendica.git/commitdiff
Expand system.accept_only_sharer pconfig value to include previous behavior with...
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 15 Feb 2022 20:40:18 +0000 (15:40 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 15 Feb 2022 20:54:36 +0000 (15:54 -0500)
mod/settings.php
src/Model/Item.php
src/Protocol/ActivityPub/Processor.php
src/Protocol/OStatus.php
view/templates/settings/connectors.tpl
view/theme/frio/templates/settings/connectors.tpl

index 111e52330261d9c82084588f00b71e1d19a25d84..6668951e8fdd87df6a54c6bb32c0d295dcb96488 100644 (file)
@@ -31,6 +31,7 @@ use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Group;
+use Friendica\Model\Item;
 use Friendica\Model\Notification;
 use Friendica\Model\Profile;
 use Friendica\Model\User;
@@ -570,7 +571,17 @@ function settings_content(App $a)
                        '$ostat_enabled' => $ostat_enabled,
 
                        '$general_settings' => DI::l10n()->t('General Social Media Settings'),
-                       '$accept_only_sharer' => ['accept_only_sharer', DI::l10n()->t('Accept only top level posts by contacts you follow'), $accept_only_sharer, DI::l10n()->t('The system does an auto completion of threads when a comment arrives. This has got the side effect that you can receive posts that had been started by a non-follower but had been commented by someone you follow. This setting deactivates this behaviour. When activated, you strictly only will receive posts from people you really do follow.')],
+                       '$accept_only_sharer' => [
+                               'accept_only_sharer',
+                               DI::l10n()->t('Followed content scope'),
+                               $accept_only_sharer,
+                               DI::l10n()->t('By default, conversations in which your follows participated but didn\'t start will be shown in your timeline. You can turn this behavior off, or expand it to the conversations in which your follows liked a post.'),
+                               [
+                                       Item::COMPLETION_NONE    => DI::l10n()->t('Only conversations my follows started'),
+                                       Item::COMPLETION_COMMENT => DI::l10n()->t('Conversations my follows started or commented on (default)'),
+                                       Item::COMPLETION_LIKE    => DI::l10n()->t('Any conversation my follows interacted with, including likes'),
+                               ]
+                       ],
                        '$enable_cw' => ['enable_cw', DI::l10n()->t('Enable Content Warning'), $enable_cw, DI::l10n()->t('Users on networks like Mastodon or Pleroma are able to set a content warning field which collapse their post by default. This enables the automatic collapsing instead of setting the content warning as the post title. Doesn\'t affect any other content filtering you eventually set up.')],
                        '$enable_smart_shortening' => ['enable_smart_shortening', DI::l10n()->t('Enable intelligent shortening'), $enable_smart_shortening, DI::l10n()->t('Normally the system tries to find the best link to add to shortened posts. If disabled, every shortened post will always point to the original friendica post.')],
                        '$simple_shortening' => ['simple_shortening', DI::l10n()->t('Enable simple text shortening'), $simple_shortening, DI::l10n()->t('Normally the system shortens posts at the next line feed. If this option is enabled then the system will shorten the text at the maximum character limit.')],
index 96cf5c488c35b1f9b599958bdd399876d0a20fd7..ef3ba01f4312816a8929d1c4f52101fa3ebad8f4 100644 (file)
@@ -74,6 +74,11 @@ class Item
        const PR_RELAY = 74;
        const PR_FETCHED = 75;
 
+       // system.accept_only_sharer setting values
+       const COMPLETION_NONE    = 1;
+       const COMPLETION_COMMENT = 0;
+       const COMPLETION_LIKE    = 2;
+
        // Field list that is used to display the items
        const DISPLAY_FIELDLIST = [
                'uid', 'id', 'parent', 'guid', 'network', 'gravity',
@@ -1403,7 +1408,7 @@ class Item
                $is_reshare = ($item['gravity'] == GRAVITY_ACTIVITY) && ($item['verb'] == Activity::ANNOUNCE);
 
                if ((($item['gravity'] == GRAVITY_PARENT) || $is_reshare) &&
-                       DI::pConfig()->get($uid, 'system', 'accept_only_sharer') &&
+                       DI::pConfig()->get($uid, 'system', 'accept_only_sharer') === self::COMPLETION_NONE &&
                        !Contact::isSharingByURL($item['author-link'], $uid) &&
                        !Contact::isSharingByURL($item['owner-link'], $uid)) {
                        Logger::info('Contact is not a follower, thread will not be stored', ['author' => $item['author-link'], 'uid' => $uid]);
index b7ddc09f61b0856e5e5b760c39a81ff715a790d5..f0d7251a9073d8e89f97845daa89bfcd895bb643 100644 (file)
@@ -647,7 +647,12 @@ class Processor
                                        Logger::info('Top level post via BCC from a non sharer, ignoring', ['uid' => $receiver, 'contact' => $item['contact-id']]);
                                        continue;
                                }
-                               if (!empty($activity['thread-children-type']) && in_array($activity['thread-children-type'], Receiver::ACTIVITY_TYPES)) {
+
+                               if (
+                                       !empty($activity['thread-children-type'])
+                                       && in_array($activity['thread-children-type'], Receiver::ACTIVITY_TYPES)
+                                       && DI::pConfig()->get($receiver, 'system', 'accept_only_sharer', Item::COMPLETION_COMMENT) !== Item::COMPLETION_LIKE
+                               ) {
                                        Logger::info('Top level post from thread completion from a non sharer had been initiated via an activity, ignoring',
                                                ['type' => $activity['thread-children-type'], 'user' => $item['uid'], 'causer' => $item['causer-link'], 'author' => $activity['author'], 'url' => $item['uri']]);
                                        continue;
@@ -663,7 +668,7 @@ class Processor
                                }
                        }
 
-                       if (!$is_forum && DI::pConfig()->get($receiver, 'system', 'accept_only_sharer', false) && ($receiver != 0) && ($item['gravity'] == GRAVITY_PARENT)) {
+                       if (!$is_forum && DI::pConfig()->get($receiver, 'system', 'accept_only_sharer', Item::COMPLETION_COMMENT) === Item::COMPLETION_NONE && ($receiver != 0) && ($item['gravity'] == GRAVITY_PARENT)) {
                                $skip = !Contact::isSharingByURL($activity['author'], $receiver);
 
                                if ($skip && (($activity['type'] == 'as:Announce') || ($item['isForum'] ?? false))) {
index 86716e99379d4032ad82843864624c0e4999aad6..2b3d7cb1214d1a7071f7e43802cf0d2eb74f062b 100644 (file)
@@ -494,19 +494,22 @@ class OStatus
 
                        if ($initialize && (count(self::$itemlist) > 0)) {
                                if (self::$itemlist[0]['uri'] == self::$itemlist[0]['thr-parent']) {
+                                       $uid = self::$itemlist[0]['uid'];
                                        // We will import it everytime, when it is started by our contacts
-                                       $valid = Contact::isSharingByURL(self::$itemlist[0]['author-link'], self::$itemlist[0]['uid']);
+                                       $valid = Contact::isSharingByURL(self::$itemlist[0]['author-link'], $uid);
 
                                        if (!$valid) {
                                                // If not, then it depends on this setting
-                                               $valid = ((self::$itemlist[0]['uid'] == 0) || !DI::pConfig()->get(self::$itemlist[0]['uid'], 'system', 'accept_only_sharer', false));
+                                               $valid = !$uid || DI::pConfig()->get($uid, 'system', 'accept_only_sharer', Item::COMPLETION_COMMENT) !== Item::COMPLETION_NONE;
+
                                                if ($valid) {
                                                        Logger::info("Item with uri ".self::$itemlist[0]['uri']." will be imported due to the system settings.");
                                                }
                                        } else {
                                                Logger::info("Item with uri ".self::$itemlist[0]['uri']." belongs to a contact (".self::$itemlist[0]['contact-id']."). It will be imported.");
                                        }
-                                       if ($valid) {
+
+                                       if ($valid && DI::pConfig()->get($uid, 'system', 'accept_only_sharer', Item::COMPLETION_COMMENT) !== Item::COMPLETION_LIKE) {
                                                // Never post a thread when the only interaction by our contact was a like
                                                $valid = false;
                                                $verbs = [Activity::POST, Activity::SHARE];
index 0479e99d90a77c62ca731f231273e0e25abb6612..8010cc982d137e17757e6f06c8fe71dd38d46b33 100644 (file)
@@ -11,7 +11,7 @@
 
        <div id="settings_general_expanded" class="settings-block" style="display: none;">
 
-               {{include file="field_checkbox.tpl" field=$accept_only_sharer}}
+               {{include file="field_select.tpl" field=$accept_only_sharer}}
                {{include file="field_checkbox.tpl" field=$enable_cw}}
                {{include file="field_checkbox.tpl" field=$enable_smart_shortening}}
                {{include file="field_checkbox.tpl" field=$simple_shortening}}
index 069b9d3d1c7a8e58a02c2b248a8986b9b88cd2b6..dc32c174f3b0c9714136d72b0c3cf956187c87b3 100644 (file)
@@ -18,7 +18,7 @@
                        </div>
                        <div id="content-settings-content" class="panel-collapse collapse" role="tabpanel" aria-labelledby="content-settings-title">
                                <div class="panel-body">
-                                       {{include file="field_checkbox.tpl" field=$accept_only_sharer}}
+                                       {{include file="field_select.tpl" field=$accept_only_sharer}}
 
                                        {{include file="field_checkbox.tpl" field=$enable_cw}}