Added logging

This commit is contained in:
Michael 2017-09-10 08:27:24 +00:00
parent bdf490e2fa
commit b847f63e2a

View File

@ -614,9 +614,11 @@ class ostatus {
$stored = true; $stored = true;
$xml = $conversation['source']; $xml = $conversation['source'];
if (self::process($xml, $importer, $contact, $hub, $stored, false)) { if (self::process($xml, $importer, $contact, $hub, $stored, false)) {
logger('Got valid cached XML for URI '.$related_uri, LOGGER_DEBUG);
return; return;
} }
if ($conversation['protocol'] == PROTOCOL_OSTATUS_SALMON) { if ($conversation['protocol'] == PROTOCOL_OSTATUS_SALMON) {
logger('Delete invalid cached XML for URI '.$related_uri, LOGGER_DEBUG);
dba::delete('conversation', array('item-uri' => $related_uri)); dba::delete('conversation', array('item-uri' => $related_uri));
} }
} }
@ -631,6 +633,7 @@ class ostatus {
$xml = ''; $xml = '';
if (stristr($related_data['header'], 'Content-Type: application/atom+xml')) { if (stristr($related_data['header'], 'Content-Type: application/atom+xml')) {
logger('Directly fetched XML for URI '.$related_uri, LOGGER_DEBUG);
$xml = $related_data['body']; $xml = $related_data['body'];
} }
@ -641,16 +644,22 @@ class ostatus {
} }
$xpath = new DomXPath($doc); $xpath = new DomXPath($doc);
$atom_file = '';
$links = $xpath->query('//link'); $links = $xpath->query('//link');
if ($links) { if ($links) {
foreach ($links AS $link) { foreach ($links AS $link) {
$attribute = self::read_attributes($link); $attribute = self::read_attributes($link);
if (($attribute['rel'] == 'alternate') && ($attribute['type'] == 'application/atom+xml')) { if (($attribute['rel'] == 'alternate') && ($attribute['type'] == 'application/atom+xml')) {
$related_atom = z_fetch_url($attribute['href']); $atom_file = $attribute['href'];
}
}
if ($atom_file != '') {
$related_atom = z_fetch_url($atom_file);
if ($related_atom['success']) { if ($related_atom['success']) {
$xml = $related_atom['body']; logger('Fetched XML for URI '.$related_uri, LOGGER_DEBUG);
} $xml = $related_atom['body'];
} }
} }
} }
@ -658,15 +667,29 @@ class ostatus {
// Workaround for older GNU Social servers // Workaround for older GNU Social servers
if (($xml == '') && strstr($related, '/notice/')) { if (($xml == '') && strstr($related, '/notice/')) {
$related_atom = z_fetch_url(str_replace('/notice/', '/api/statuses/show/', $related).',atom'); $related_atom = z_fetch_url(str_replace('/notice/', '/api/statuses/show/', $related).'.atom');
if ($related_atom['success']) { if ($related_atom['success']) {
logger('GNU Social workaround to fetch XML for URI '.$related_uri, LOGGER_DEBUG);
$xml = $related_atom['body'];
}
}
// Even more worse workaround for GNU Social ;-)
if ($xml == '') {
$related_guess = ostatus::convert_href($related_uri);
$related_atom = z_fetch_url(str_replace('/notice/', '/api/statuses/show/', $related_guess).'.atom');
if ($related_atom['success']) {
logger('GNU Social workaround 2 to fetch XML for URI '.$related_uri, LOGGER_DEBUG);
$xml = $related_atom['body']; $xml = $related_atom['body'];
} }
} }
if ($xml != '') { if ($xml != '') {
self::process($xml, $importer, $contact, $hub, $stored, false); self::process($xml, $importer, $contact, $hub, $stored, false);
} else {
logger("XML couldn't be fetched for URI: ".$related_uri." - href: ".$related, LOGGER_DEBUG);
} }
return; return;
} }