]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Let the WebFingerPlugin lookup profile resources with index.php/ too
authorMikael Nordfeldth <mmn@hethane.se>
Sun, 21 Feb 2016 17:48:48 +0000 (18:48 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Sun, 21 Feb 2016 17:48:48 +0000 (18:48 +0100)
plugins/WebFinger/WebFingerPlugin.php

index 1677501a2048539a9a906c04c20337fc23bf2f14..84d2f63b6c06a54fa702f47517aff3a955d78e34 100644 (file)
@@ -100,12 +100,21 @@ class WebFingerPlugin extends Plugin
                 }
             }
         } else {
-            $user = User::getKV('uri', $resource);
-            if ($user instanceof User) {
+            try {
+                $user = User::getByUri($resource);
                 $profile = $user->getProfile();
-            } else {
-                // try and get it by profile url
-                $profile = Profile::getKV('profileurl', $resource);
+            } catch (NoResultException $e) {
+                try {
+                    // common_fake_local_fancy_url can throw an exception
+                    $fancy_url = common_fake_local_fancy_url($resource);
+
+                    // and this will throw a NoResultException if not found
+                    $user = User::getByUri($fancy_url);
+                    $profile = $user->getProfile();
+                } catch (Exception $e) {
+                    // if our rewrite hack didn't work, try to get something by profile URL
+                    $profile = Profile::getKV('profileurl', $resource);
+                }
             }
         }