From 2d4e0693c88bb8cad47f917db3ac5ecfacf28619 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 1 Sep 2010 16:17:18 -0400 Subject: save URIs of remote profiles marked for attention --- plugins/OStatus/classes/Ostatus_profile.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'plugins/OStatus/classes/Ostatus_profile.php') diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index a95612a7f..fe3946d24 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -699,14 +699,16 @@ class Ostatus_profile extends Memcached_DataObject } // Is the recipient a remote group? - $oprofile = Ostatus_profile::staticGet('uri', $recipient); + $oprofile = Ostatus_profile::ensureProfileURI($recipient); + if ($oprofile) { if ($oprofile->isGroup()) { // Deliver to local members of this remote group. // @fixme sender verification? $groups[] = $oprofile->group_id; } else { - common_log(LOG_DEBUG, "Skipping reply to remote profile $recipient"); + // may be canonicalized or something + $replies[] = $oprofile->uri; } continue; } @@ -1763,6 +1765,28 @@ class Ostatus_profile extends Memcached_DataObject return $file; } + + static function ensureProfileURI($uri) + { + $oprofile = null; + + if (preg_match("/^(\w+)\:(.*)/", $uri, $match)) { + $protocol = $match[1]; + switch ($protocol) { + case 'http': + case 'https': + $oprofile = Ostatus_profile::ensureProfileURL($uri); + break; + case 'acct': + case 'mailto': + $rest = $match[2]; + $oprofile = Ostatus_profile::ensureWebfinger($rest); + default: + common_log("Unrecognized URI protocol for profile: $protocol ($uri)"); + break; + } + } + } } /** -- cgit v1.2.3-54-g00ecf From ab88123373ce5f17b9e09ed2372f587e607cba20 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 1 Sep 2010 17:05:11 -0400 Subject: correctly return oprofile from Ostatus_profile::ensureProfileURI() --- plugins/OStatus/classes/Ostatus_profile.php | 37 ++++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'plugins/OStatus/classes/Ostatus_profile.php') diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index fe3946d24..787712874 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -1770,22 +1770,31 @@ class Ostatus_profile extends Memcached_DataObject { $oprofile = null; - if (preg_match("/^(\w+)\:(.*)/", $uri, $match)) { - $protocol = $match[1]; - switch ($protocol) { - case 'http': - case 'https': - $oprofile = Ostatus_profile::ensureProfileURL($uri); - break; - case 'acct': - case 'mailto': - $rest = $match[2]; - $oprofile = Ostatus_profile::ensureWebfinger($rest); - default: - common_log("Unrecognized URI protocol for profile: $protocol ($uri)"); - break; + // First, try to query it + + $oprofile = Ostatus_profile::staticGet('uri', $uri); + + // If unfound, do discovery stuff + + if (empty($oprofile)) { + if (preg_match("/^(\w+)\:(.*)/", $uri, $match)) { + $protocol = $match[1]; + switch ($protocol) { + case 'http': + case 'https': + $oprofile = Ostatus_profile::ensureProfileURL($uri); + break; + case 'acct': + case 'mailto': + $rest = $match[2]; + $oprofile = Ostatus_profile::ensureWebfinger($rest); + default: + common_log("Unrecognized URI protocol for profile: $protocol ($uri)"); + break; + } } } + return $oprofile; } } -- cgit v1.2.3-54-g00ecf