From 32c66246c4fcddcab30e4850d5c6b62bdfac225a Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 9 Mar 2016 19:30:04 +0100 Subject: [PATCH] Some fixes for the fetching of postings by using /p/ --- include/diaspora2.php | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/include/diaspora2.php b/include/diaspora2.php index 4c9d79912e..7aa0fc6989 100644 --- a/include/diaspora2.php +++ b/include/diaspora2.php @@ -550,12 +550,15 @@ class diaspora { return self::fetch_message($source_xml->root_guid, $server, ++$level); } + $author = ""; + // Fetch the author - for the old and the new Diaspora version if ($source_xml->post->status_message->diaspora_handle) $author = (string)$source_xml->post->status_message->diaspora_handle; - elseif ($source_xml->author) + elseif ($source_xml->author AND ($source_xml->getName() == "status_message")) $author = (string)$source_xml->author; + // If this isn't a "status_message" then quit if (!$author) return false; @@ -1391,22 +1394,24 @@ EOT; logger("1st try: reshared message ".$guid." will be fetched from original server: ".$server); $item_id = self::store_by_guid($guid, $server); - if (!$item_id) { - $server = "https://".substr($author, strpos($author, "@") + 1); - logger("2nd try: reshared message ".$guid." will be fetched from sharer's server: ".$server); - $item = self::store_by_guid($guid, $server); - } if (!$item_id) { $server = "http://".substr($orig_author, strpos($orig_author, "@") + 1); - logger("3rd try: reshared message ".$guid." will be fetched from original server: ".$server); - $item = self::store_by_guid($guid, $server); + logger("2nd try: reshared message ".$guid." will be fetched from original server: ".$server); + $item_id = self::store_by_guid($guid, $server); + } + + // Deactivated by now since there is a risk that someone could manipulate postings through this method +/* if (!$item_id) { + $server = "https://".substr($author, strpos($author, "@") + 1); + logger("3rd try: reshared message ".$guid." will be fetched from sharer's server: ".$server); + $item_id = self::store_by_guid($guid, $server); } if (!$item_id) { $server = "http://".substr($author, strpos($author, "@") + 1); logger("4th try: reshared message ".$guid." will be fetched from sharer's server: ".$server); - $item = self::store_by_guid($guid, $server); + $item_id = self::store_by_guid($guid, $server); } - +*/ if ($item_id) { $r = q("SELECT `body`, `tag`, `app`, `created`, `object-type`, `uri`, `guid`, `author-name`, `author-link`, `author-avatar`