]> git.mxchange.org Git - friendica.git/commitdiff
"remote-self" is now working for Diaspora and Twitter as well
authorMichael <heluecht@pirati.ca>
Fri, 4 May 2018 21:12:13 +0000 (21:12 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 4 May 2018 21:12:13 +0000 (21:12 +0000)
mod/crepair.php
src/Model/Item.php
src/Protocol/DFRN.php

index 29aa01572657ec7622d8a5fb441e0f58f12f3035..29b00b4e3aab3a6848837636e5c45406a5edbb34 100644 (file)
@@ -121,7 +121,7 @@ function crepair_content(App $a)
        // Disable remote self for everything except feeds.
        // There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter
        // Problem is, you couldn't reply to both networks.
-       if (!in_array($contact['network'], [NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA])) {
+       if (!in_array($contact['network'], [NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_TWITTER])) {
                $allow_remote_self = false;
        }
 
index 54abc49d602b851c0e4b43d6c0d93edde6e231a8..425f71822ae1ab6b717777a1568c03f02db1c35c 100644 (file)
@@ -925,7 +925,15 @@ class Item extends BaseObject
 
                /// @todo Handling of "event-id"
 
-               $distributed = self::insert($item, false, false, true);
+               $notify = false;
+               if ($item['uri'] == $item['parent-uri']) {
+                       $contact = dba::selectFirst('contact', [], ['id' => $item['contact-id'], 'self' => false]);
+                       if (DBM::is_result($contact)) {
+                               $notify = self::isRemoteSelf($contact, $item);
+                       }
+               }
+
+               $distributed = self::insert($item, false, $notify, true);
 
                if (!$distributed) {
                        logger("Distributed public item " . $itemid . " for user " . $uid . " wasn't stored", LOGGER_DEBUG);
@@ -1406,20 +1414,24 @@ class Item extends BaseObject
 
                // Prevent the forwarding of posts that are forwarded
                if ($datarray["extid"] == NETWORK_DFRN) {
+                       logger('Already forwarded', LOGGER_DEBUG);
                        return false;
                }
 
                // Prevent to forward already forwarded posts
                if ($datarray["app"] == $a->get_hostname()) {
+                       logger('Already forwarded (second test)', LOGGER_DEBUG);
                        return false;
                }
 
                // Only forward posts
                if ($datarray["verb"] != ACTIVITY_POST) {
+                       logger('No post', LOGGER_DEBUG);
                        return false;
                }
 
                if (($contact['network'] != NETWORK_FEED) && $datarray['private']) {
+                       logger('Not public', LOGGER_DEBUG);
                        return false;
                }
 
@@ -1441,6 +1453,10 @@ class Item extends BaseObject
 
                                unset($datarray['created']);
                                unset($datarray['edited']);
+
+                               unset($datarray['network']);
+                               unset($datarray['owner-id']);
+                               unset($datarray['author-id']);
                        }
 
                        if ($contact['network'] != NETWORK_FEED) {
@@ -1448,7 +1464,8 @@ class Item extends BaseObject
                                unset($datarray["plink"]);
                                $datarray["uri"] = item_new_uri($a->get_hostname(), $contact['uid'], $datarray["guid"]);
                                $datarray["parent-uri"] = $datarray["uri"];
-                               $datarray["extid"] = $contact['network'];
+                               $datarray["thr-parent"] = $datarray["uri"];
+                               $datarray["extid"] = NETWORK_DFRN;
                                $urlpart = parse_url($datarray2['author-link']);
                                $datarray["app"] = $urlpart["host"];
                        } else {
@@ -1458,10 +1475,11 @@ class Item extends BaseObject
 
                if ($contact['network'] != NETWORK_FEED) {
                        // Store the original post
-                       $r = self::insert($datarray2, false, false);
-                       logger('remote-self post original item - Contact '.$contact['url'].' return '.$r.' Item '.print_r($datarray2, true), LOGGER_DEBUG);
+                       $result = self::insert($datarray2, false, false);
+                       logger('remote-self post original item - Contact '.$contact['url'].' return '.$result.' Item '.print_r($datarray2, true), LOGGER_DEBUG);
                } else {
                        $datarray["app"] = "Feed";
+                       $result = true;
                }
 
                // Trigger automatic reactions for addons
@@ -1471,7 +1489,7 @@ class Item extends BaseObject
                $_SESSION["authenticated"] = true;
                $_SESSION["uid"] = $contact['uid'];
 
-               return true;
+               return $result;
        }
 
        /**
index 5af1ddc5d8baf0fbff8c6ce04097def53f5521d4..92a01d2537fb395033874e7587fac4e281999a2f 100644 (file)
@@ -2767,6 +2767,10 @@ class DFRN
 
                        $posted_id = Item::insert($item, false, $notify);
 
+                       if ($notify) {
+                               $notify = $notify;
+                       }
+
                        logger("Item was stored with id ".$posted_id, LOGGER_DEBUG);
 
                        if ($item['uid'] == 0) {