summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/OStatus/classes/Ostatus_profile.php2
-rw-r--r--plugins/OStatus/lib/webfinger.php14
2 files changed, 15 insertions, 1 deletions
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php
index ad9170f5b..26d776d52 100644
--- a/plugins/OStatus/classes/Ostatus_profile.php
+++ b/plugins/OStatus/classes/Ostatus_profile.php
@@ -1407,6 +1407,7 @@ class Ostatus_profile extends Memcached_DataObject
if (isset($feedUrl)) {
try {
+ common_log(LOG_INFO, "Discovery on acct:$addr with feed URL $feedUrl");
$oprofile = self::ensureProfile($feedUrl, $hints);
self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri);
return $oprofile;
@@ -1420,6 +1421,7 @@ class Ostatus_profile extends Memcached_DataObject
if (isset($profileUrl)) {
try {
+ common_log(LOG_INFO, "Discovery on acct:$addr with profile URL $profileUrl");
$oprofile = self::ensureProfile($profileUrl, $hints);
self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri);
return $oprofile;
diff --git a/plugins/OStatus/lib/webfinger.php b/plugins/OStatus/lib/webfinger.php
index 8d7040310..4b777c9a0 100644
--- a/plugins/OStatus/lib/webfinger.php
+++ b/plugins/OStatus/lib/webfinger.php
@@ -81,11 +81,14 @@ class Webfinger
function getServiceLinks($domain)
{
$url = 'http://'. $domain .'/.well-known/host-meta';
+
$content = $this->fetchURL($url);
+
if (empty($content)) {
common_log(LOG_DEBUG, 'Error fetching host-meta');
return false;
}
+
$result = XRD::parse($content);
// Ensure that the host == domain (spec may include signing later)
@@ -119,6 +122,11 @@ class Webfinger
function fetchURL($url)
{
try {
+ $c = Cache::instance();
+ $content = $c->get('webfinger:url:'.$url);
+ if ($content !== false) {
+ return $content;
+ }
$client = new HTTPClient();
$response = $client->get($url);
} catch (HTTP_Request2_Exception $e) {
@@ -129,7 +137,11 @@ class Webfinger
return false;
}
- return $response->getBody();
+ $body = $response->getBody();
+
+ $c->set('webfinger:url:'.$url, $body);
+
+ return $body;
}
function applyTemplate($template, $id)