diff options
author | Evan Prodromou <evan@status.net> | 2010-09-02 16:58:55 -0400 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-09-02 16:58:55 -0400 |
commit | 82b1d6daefc29c870ea71b29ab851153642f270b (patch) | |
tree | 61db5e4fcee85ae0b2e94563e50c78ca794bcf4f /plugins/OStatus/classes | |
parent | 7517409bf16137a9d8a420b7358f30fa55945ba0 (diff) | |
parent | ebcd8644a51b66d73971d581789e7c70b82007b2 (diff) |
Merge branch 'swat0' into 0.9.x
Diffstat (limited to 'plugins/OStatus/classes')
-rw-r--r-- | plugins/OStatus/classes/Ostatus_profile.php | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index cc4307b14..898c63e83 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -700,14 +700,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; } @@ -1764,6 +1766,37 @@ class Ostatus_profile extends Memcached_DataObject return $file; } + + static function ensureProfileURI($uri) + { + $oprofile = null; + + // 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; + } } /** |