]> git.mxchange.org Git - friendica.git/commitdiff
Diaspora will introduce "like on comment" so we doing it as well
authorMichael <heluecht@pirati.ca>
Fri, 8 Sep 2017 05:36:00 +0000 (05:36 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 8 Sep 2017 05:36:00 +0000 (05:36 +0000)
include/diaspora.php
object/Item.php

index 1907c0d5ad74366101a5640dbef1fbcfcc54a098..8bfba6eff41d68c96cc0afccd3abc63b0a76172e 100644 (file)
@@ -1182,7 +1182,7 @@ class Diaspora {
         * @return array the item record
         */
        private static function parent_item($uid, $guid, $author, $contact) {
-               $r = q("SELECT `id`, `body`, `wall`, `uri`, `private`, `origin`,
+               $r = q("SELECT `id`, `parent`, `body`, `wall`, `uri`, `private`, `origin`,
                                `author-name`, `author-link`, `author-avatar`,
                                `owner-name`, `owner-link`, `owner-avatar`
                        FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
@@ -1776,8 +1776,16 @@ class Diaspora {
                        logger("Stored like ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
                }
 
+               // like on comments have the comment as parent. So we need to fetch the toplevel parent
+               if ($parent_item["id"] != $parent_item["parent"]) {
+                       $toplevel = dba::select('item', array('origin'), array('id' => $parent_item["parent"]), array('limit' => 1));
+                       $origin = $toplevel["origin"];
+               } else {
+                       $origin = $parent_item["origin"];
+               }
+
                // If we are the origin of the parent we store the original data and notify our followers
-               if ($message_id && $parent_item["origin"]) {
+               if ($message_id && $origin) {
 
                        // Formerly we stored the signed text, the signature and the author in different fields.
                        // We now store the raw data so that we are more flexible.
index f81b8ea4e8a13be43206444663bc8bb92685e6d9..816406e4eb866dfe1ae644cc5cdc64a0e8321de7 100644 (file)
@@ -68,6 +68,11 @@ class Item extends BaseObject {
                                        continue;
                                }
 
+                               // You can always comment on Diaspora items
+                               if (($item['network'] == NETWORK_DIASPORA) && (local_user() == $item['uid'])) {
+                                       $item['writable'] = true;
+                               }
+
                                $item['pagedrop'] = $data['pagedrop'];
                                $child = new Item($item);
                                $this->add_child($child);
@@ -319,18 +324,6 @@ class Item extends BaseObject {
                        unset($buttons["like"]);
                }
 
-               // Diaspora isn't able to do likes on comments - but Hubzilla does
-               /// @todo When Diaspora will pass this information we will remove these lines
-               if (($item["item_network"] == NETWORK_DIASPORA) && ($indent == 'comment') &&
-                       !Diaspora::is_redmatrix($item["owner-link"]) && isset($buttons["like"])) {
-                       unset($buttons["like"]);
-               }
-
-               // Facebook can like comments - but it isn't programmed in the connector yet.
-               if (($item["item_network"] == NETWORK_FACEBOOK) && ($indent == 'comment') && isset($buttons["like"])) {
-                       unset($buttons["like"]);
-               }
-
                $tmp_item = array(
                        'template'        => $this->get_template(),
                        'type'            => implode("",array_slice(explode("/",$item['verb']),-1)),