]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
correctly return oprofile from Ostatus_profile::ensureProfileURI()
authorEvan Prodromou <evan@status.net>
Wed, 1 Sep 2010 21:05:11 +0000 (17:05 -0400)
committerEvan Prodromou <evan@status.net>
Wed, 1 Sep 2010 21:05:11 +0000 (17:05 -0400)
plugins/OStatus/classes/Ostatus_profile.php

index fe3946d249a0e83ecff46f781d9a61f7c188ea67..78771287458624cdb203dad591a3ea77f5095a23 100644 (file)
@@ -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;
     }
 }