]> git.mxchange.org Git - friendica.git/commitdiff
Conversation and Item now handles (dis)like as they should
authorDomovoy <domovoy@errlock.org>
Sun, 12 Aug 2012 15:46:02 +0000 (17:46 +0200)
committerDomovoy <domovoy@errlock.org>
Sun, 12 Aug 2012 15:46:02 +0000 (17:46 +0200)
include/conversation.php
object/Conversation.php
object/Item.php

index 19ca0dc4cf1f6e973d693f045df7abe9c33d7c69..2c1c2746959df6fcd176f864949795f02650e38e 100644 (file)
@@ -862,9 +862,18 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                        $threads = array();
                        foreach($items as $item) {
 
+                               // Can we put this after the visibility check?
                                like_puller($a,$item,$alike,'like');
                                like_puller($a,$item,$dlike,'dislike');
 
+                               // Only add what is visible
+                               if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
+                                       continue;
+                               }
+                               if($item['verb'] === ACTIVITY_LIKE || $item['verb'] === ACTIVITY_DISLIKE) {
+                                       continue;
+                               }
+
                                if($item['id'] == $item['parent']) {
                                        $item_object = new Item($item);
                                        $conv->add_thread($item_object);
index d8d14589d2d2f7256399daeeaf7e3136242b46a7..b9b0cb74c200af24d35ec01c95252183dcd7542d 100644 (file)
@@ -91,6 +91,18 @@ class Conversation extends BaseObject {
                        logger('[WARN] Conversation::add_thread : Thread already exists ('. $item->get_id() .').', LOGGER_DEBUG);
                        return false;
                }
+
+               /*
+                * Only add will be displayed
+                */
+               if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
+                       logger('[WARN] Conversation::add_thread : Thread is a mail ('. $item->get_id() .').', LOGGER_DEBUG);
+                       return false;
+               }
+               if($item->get_data_value('verb') === ACTIVITY_LIKE || $item->get_data_value('verb') === ACTIVITY_DISLIKE) {
+                       logger('[WARN] Conversation::add_thread : Thread is a (dis)like ('. $item->get_id() .').', LOGGER_DEBUG);
+                       return false;
+               }
                $item->set_conversation($this);
                $this->threads[] = $item;
                return end($this->threads);
index 0639e4db71302bd271d11348498b85e0eb9aca6b..7f883b41d522b3c1d6179219025a23a635c36a04 100644 (file)
@@ -42,6 +42,15 @@ class Item extends BaseObject {
                // Prepare the children
                if(count($data['children'])) {
                        foreach($data['children'] as $item) {
+                               /*
+                                * Only add will be displayed
+                                */
+                               if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
+                                       continue;
+                               }
+                               if($item['verb'] === ACTIVITY_LIKE || $item['verb'] === ACTIVITY_DISLIKE) {
+                                       continue;
+                               }
                                $child = new Item($item);
                                $this->add_child($child);
                        }
@@ -270,6 +279,18 @@ class Item extends BaseObject {
                        logger('[WARN] Item::add_child : Item already exists ('. $item->get_id() .').', LOGGER_DEBUG);
                        return false;
                }
+               /*
+                * Only add will be displayed
+                */
+               if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
+                       logger('[WARN] Item::add_child : Item is a mail ('. $item->get_id() .').', LOGGER_DEBUG);
+                       return false;
+               }
+               if($item->get_data_value('verb') === ACTIVITY_LIKE || $item->get_data_value('verb') === ACTIVITY_DISLIKE) {
+                       logger('[WARN] Item::add_child : Item is a (dis)like ('. $item->get_id() .').', LOGGER_DEBUG);
+                       return false;
+               }
+               
                $item->set_parent($this);
                $this->children[] = $item;
                return end($this->children);