]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
more cleanup
authorJames Walker <walkah@walkah.net>
Fri, 26 Feb 2010 09:07:58 +0000 (04:07 -0500)
committerJames Walker <walkah@walkah.net>
Fri, 26 Feb 2010 09:07:58 +0000 (04:07 -0500)
plugins/OStatus/classes/Ostatus_profile.php
plugins/OStatus/lib/discovery.php
plugins/OStatus/lib/magicenvelope.php

index 4a9aafce1e31d55c93d444b33b5d0d528905c407..091056c54180a4c6624a256a0de6cc8c535571ac 100644 (file)
@@ -1305,7 +1305,7 @@ class Ostatus_profile extends Memcached_DataObject
             case Discovery::UPDATESFROM:
                 $feedUrl = $link['href'];
                 break;
-            case Webfinger::HCARD:
+            case Discovery::HCARD:
                 $hcardUrl = $link['href'];
                 break;
             default:
index 1ab6e51bda499b87e06095a6d0eebc66da5a6884..388df0a28feed184d48df8a1887fb7bc0c5a3044 100644 (file)
@@ -111,6 +111,10 @@ class Discovery
     }
 
     public static function getService($links, $service) {
+        if (!is_array($links)) {
+            return false;
+        }
+        
         foreach ($links as $link) {
             if ($link['rel'] == $service) {
                 return $link;
index c642af5488f51d2f8b1482c4bfe662d544892ed0..457c0fba221a269695c3b97f81ad7c3159e28182 100644 (file)
@@ -52,12 +52,17 @@ class MagicEnvelope
     {
         $disco = new Discovery();
 
-        $xrd = $disco->lookup($signer_uri);
-        if ($link = Discovery::getService($xrd->links, Magicsig::PUBLICKEYREL)) {
-            list($type, $keypair) = explode(';', $link['href']);
-            return $keypair;
+        try {
+            $xrd = $disco->lookup($signer_uri);
+        } catch (Exception $e) {
+            return false;
+        }
+        if ($xrd->links) {
+            if ($link = Discovery::getService($xrd->links, Magicsig::PUBLICKEYREL)) {
+                list($type, $keypair) = explode(';', $link['href']);
+                return $keypair;
+            }
         }
-
         throw new Exception('Unable to locate signer public key');
     }
 
@@ -70,7 +75,11 @@ class MagicEnvelope
             throw new Exception("Unable to determine entry author.");
         }
 
-        $signature_alg = Magicsig::fromString($this->getKeyPair($signer_uri));
+        $keypair = $this->getKeyPair($signer_uri);
+        if (!$keypair) {
+            throw new Exception("Unable to retrive keypair for ". $signer_uri);
+        }
+        $signature_alg = Magicsig::fromString($keypair);
         $armored_text = base64_encode($text);
 
         return array(