X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FOStatus%2Fclasses%2FOstatus_profile.php;h=d36cbe21d66c902579e680224cfa2d0a967da3d5;hb=4e0ed61f7c542a1035dfecc395f4b799ab404805;hp=4d1c676844c51c5e9736dcc1b043a7525cbc2873;hpb=1644608376a583d4dcf5d5b64bf6fa3737734ca0;p=quix0rs-gnu-social.git diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 4d1c676844..d36cbe21d6 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -376,6 +376,7 @@ class Ostatus_profile extends Managed_DataObject public function notifyDeferred($entry, $actor) { if ($this->salmonuri) { + common_debug("OSTATUS: user {$actor->getNickname()} ({$actor->getID()}) wants to ping {$this->localProfile()->getNickname()} on {$this->salmonuri}"); $data = array('salmonuri' => $this->salmonuri, 'entry' => $this->notifyPrepXml($entry), 'actor' => $actor->getID(), @@ -444,10 +445,7 @@ class Ostatus_profile extends Managed_DataObject return; } - for ($i = 0; $i < $entries->length; $i++) { - $entry = $entries->item($i); - $this->processEntry($entry, $feed, $source); - } + $this->processEntries($entries, $feed, $source); } public function processRssFeed(DOMElement $rss, $source) @@ -465,9 +463,21 @@ class Ostatus_profile extends Managed_DataObject $items = $channel->getElementsByTagName('item'); - for ($i = 0; $i < $items->length; $i++) { - $item = $items->item($i); - $this->processEntry($item, $channel, $source); + $this->processEntries($items, $channel, $source); + } + + public function processEntries(DOMNodeList $entries, DOMElement $feed, $source) + { + for ($i = 0; $i < $entries->length; $i++) { + $entry = $entries->item($i); + try { + $this->processEntry($entry, $feed, $source); + } catch (AlreadyFulfilledException $e) { + common_debug('We already had this entry: '.$e->getMessage()); + } catch (ServerException $e) { + // FIXME: This should be UnknownUriException and the ActivityUtils:: findLocalObject should only test one URI + common_log(LOG_ERR, 'Entry threw exception while processing a feed from '.$source.': '.$e->getMessage()); + } } } @@ -480,14 +490,14 @@ class Ostatus_profile extends Managed_DataObject * * @return Notice Notice representing the new (or existing) activity */ - public function processEntry($entry, $feed, $source) + public function processEntry(DOMElement $entry, DOMElement $feed, $source) { $activity = new Activity($entry, $feed); return $this->processActivity($activity, $source); } // TODO: Make this throw an exception - public function processActivity($activity, $source) + public function processActivity(Activity $activity, $source) { $notice = null; @@ -635,14 +645,21 @@ class Ostatus_profile extends Managed_DataObject } } - // Try to get some hCard data + if (in_array( + preg_replace('/\s*;.*$/', '', $response->getHeader('Content-Type')), + array('application/rss+xml', 'application/atom+xml', 'application/xml', 'text/xml')) + ) { + $hints['feedurl'] = $response->getUrl(); + } else { + // Try to get some hCard data - $body = $response->getBody(); + $body = $response->getBody(); - $hcardHints = DiscoveryHints::hcardHints($body, $finalUrl); + $hcardHints = DiscoveryHints::hcardHints($body, $finalUrl); - if (!empty($hcardHints)) { - $hints = array_merge($hints, $hcardHints); + if (!empty($hcardHints)) { + $hints = array_merge($hints, $hcardHints); + } } // Check if they've got an LRDD header