Some fixes for the fetching of postings by using /p/

This commit is contained in:
Michael Vogel 2016-03-09 19:30:04 +01:00
parent 16eb8fd9bf
commit 32c66246c4
1 changed files with 15 additions and 10 deletions

View File

@ -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`