If it doesn't work with the new method, try the old one

This commit is contained in:
Michael Vogel 2016-06-30 22:58:56 +02:00
parent e5dd67121f
commit c1ce7059b6

View file

@ -876,13 +876,15 @@ class diaspora {
if($envelope) { if($envelope) {
logger("Envelope was fetched.", LOGGER_DEBUG); logger("Envelope was fetched.", LOGGER_DEBUG);
$x = self::verify_magic_envelope($envelope); $x = self::verify_magic_envelope($envelope);
if (!$x) { if (!$x)
logger("Envelope could not be verified.", LOGGER_DEBUG); logger("Envelope could not be verified.", LOGGER_DEBUG);
return false; else
}
logger("Envelope was verified.", LOGGER_DEBUG); logger("Envelope was verified.", LOGGER_DEBUG);
} else { } else
$x = false;
// This will work for older Diaspora and Friendica servers // This will work for older Diaspora and Friendica servers
if (!$x) {
$source_url = $server."/p/".$guid.".xml"; $source_url = $server."/p/".$guid.".xml";
logger("Fetch post from ".$source_url, LOGGER_DEBUG); logger("Fetch post from ".$source_url, LOGGER_DEBUG);
@ -1985,27 +1987,15 @@ class diaspora {
if (!$r) { if (!$r) {
$server = "https://".substr($orig_author, strpos($orig_author, "@") + 1); $server = "https://".substr($orig_author, strpos($orig_author, "@") + 1);
logger("1st try: reshared message ".$guid." will be fetched from original server: ".$server); logger("1st try: reshared message ".$guid." will be fetched via SSL from the server ".$server);
$item_id = self::store_by_guid($guid, $server); $item_id = self::store_by_guid($guid, $server);
if (!$item_id) { if (!$item_id) {
$server = "http://".substr($orig_author, strpos($orig_author, "@") + 1); $server = "http://".substr($orig_author, strpos($orig_author, "@") + 1);
logger("2nd try: reshared message ".$guid." will be fetched from original server: ".$server); logger("2nd try: reshared message ".$guid." will be fetched without SLL from the server ".$server);
$item_id = self::store_by_guid($guid, $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_id = self::store_by_guid($guid, $server);
}
*/
if ($item_id) { if ($item_id) {
$r = q("SELECT `body`, `tag`, `app`, `created`, `object-type`, `uri`, `guid`, $r = q("SELECT `body`, `tag`, `app`, `created`, `object-type`, `uri`, `guid`,
`author-name`, `author-link`, `author-avatar` `author-name`, `author-link`, `author-avatar`