]> git.mxchange.org Git - friendica.git/commitdiff
Don't count and fetch "follow" activities
authorMichael <heluecht@pirati.ca>
Thu, 7 May 2020 18:39:39 +0000 (18:39 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 7 May 2020 18:39:39 +0000 (18:39 +0000)
include/conversation.php
mod/ping.php
src/Model/Item.php

index a4fe9c00e397a7f6053990ed2997a589b5248330..5b7ccbd8a152615b5c3d8b22139ebf626b4eb8ad 100644 (file)
@@ -769,20 +769,12 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
 
        $items = [];
 
-       foreach ($parents AS $parent) {
-               $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) ",
-                       $parent['uri'], $uid];
-               if ($block_authors) {
-                       $condition[0] .= "AND NOT `author`.`hidden`";
-               }
-
-               $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params);
+       $follow = Item::activityToIndex(Activity::FOLLOW);
 
-               $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false);
-
-               if (count($comments) != 0) {
-                       $items = array_merge($items, $comments);
-               }
+       foreach ($parents AS $parent) {
+               $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) AND (`activity` != ? OR `activity` IS NULL)",
+                       $parent['uri'], $uid, $follow];
+               $items = conversation_fetch_items($parent, $items, $condition, $block_authors, $params);
        }
 
        foreach ($items as $index => $item) {
@@ -796,6 +788,31 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
        return $items;
 }
 
+/**
+ * Fetch conversation items
+ *
+ * @param array $parent
+ * @param array $items
+ * @param array $condition
+ * @param boolean $block_authors
+ * @param array $params
+ * @return array
+ */
+function conversation_fetch_items(array $parent, array $items, array $condition, bool $block_authors, array $params) {
+       if ($block_authors) {
+               $condition[0] .= "AND NOT `author`.`hidden`";
+       }
+
+       $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params);
+
+       $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false);
+
+       if (count($comments) != 0) {
+               $items = array_merge($items, $comments);
+       }
+       return $items;
+}
+
 function item_photo_menu($item) {
        $sub_link = '';
        $poke_link = '';
index 3057fb9e312fbf6219be9f397127896ce48fbc63..3dab119700dcfeb70b322526d9989a470e2154e0 100644 (file)
@@ -30,6 +30,7 @@ use Friendica\Model\Contact;
 use Friendica\Model\Group;
 use Friendica\Model\Item;
 use Friendica\Model\Notify\Type;
+use Friendica\Protocol\Activity;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Temporal;
 use Friendica\Util\Proxy as ProxyUtils;
@@ -134,9 +135,10 @@ function ping_init(App $a)
 
                $notifs = ping_get_notifications(local_user());
 
-               $condition = ["`unseen` AND `uid` = ? AND `contact-id` != ?", local_user(), local_user()];
+               $condition = ["`unseen` AND `uid` = ? AND `contact-id` != ? AND (`activity` != ? OR `activity` IS NULL)",
+                       local_user(), local_user(), Item::activityToIndex(Activity::FOLLOW)];
                $fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar',
-                       'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'wall'];
+                       'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'wall', 'activity'];
                $params = ['order' => ['received' => true]];
                $items = Item::selectForUser(local_user(), $fields, $condition, $params);
 
index 44e00b09b31fc4cdb4a9d82b43ce69be0bd759a8..38ea35c8f6bbc9de048cb58bb9f78990e7be9650 100644 (file)
@@ -74,7 +74,7 @@ class Item
                'event-id', 'event-created', 'event-edited', 'event-start', 'event-finish',
                'event-summary', 'event-desc', 'event-location', 'event-type',
                'event-nofinish', 'event-adjust', 'event-ignore', 'event-id',
-               'delivery_queue_count', 'delivery_queue_done', 'delivery_queue_failed'
+               'delivery_queue_count', 'delivery_queue_done', 'delivery_queue_failed', 'activity'
        ];
 
        // Field list that is used to deliver items via the protocols
@@ -1672,7 +1672,13 @@ class Item
                                $allow_gid      = $parent['allow_gid'];
                                $deny_cid       = $parent['deny_cid'];
                                $deny_gid       = $parent['deny_gid'];
-                               $item['wall']   = $parent['wall'];
+
+                               // Don't federate received participation messages
+                               if ($item['verb'] != Activity::FOLLOW) {
+                                       $item['wall'] = $parent['wall'];
+                               } else {
+                                       $item['wall'] = false;
+                               }
 
                                /*
                                 * If the parent is private, force privacy for the entire conversation