]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x
authorSarven Capadisli <csarven@status.net>
Thu, 11 Mar 2010 21:39:07 +0000 (16:39 -0500)
committerSarven Capadisli <csarven@status.net>
Thu, 11 Mar 2010 21:39:07 +0000 (16:39 -0500)
classes/Profile.php
classes/User.php
plugins/OStatus/lib/magicenvelope.php
plugins/OStatus/lib/xrdaction.php

index 0322c935886028a09858653be49bd528fef71f8d..91f6e4692216b52bafec13eb5e6ce34055be1960 100644 (file)
@@ -147,14 +147,16 @@ class Profile extends Memcached_DataObject
         return ($this->fullname) ? $this->fullname : $this->nickname;
     }
 
-    # Get latest notice on or before date; default now
-    function getCurrentNotice($dt=null)
+    /**
+     * Get the most recent notice posted by this user, if any.
+     *
+     * @return mixed Notice or null
+     */
+    function getCurrentNotice()
     {
         $notice = new Notice();
         $notice->profile_id = $this->id;
-        if ($dt) {
-            $notice->whereAdd('created < "' . $dt . '"');
-        }
+        // @fixme change this to sort on notice.id only when indexes are updated
         $notice->orderBy('created DESC, notice.id DESC');
         $notice->limit(1);
         if ($notice->find(true)) {
index fade0f35deaa28f930c346fa4c80a21d3e0d4d4f..77091fad5d72e65513b82a75155e3bbcae5903db 100644 (file)
@@ -132,13 +132,18 @@ class User extends Memcached_DataObject
         return !in_array($nickname, $blacklist);
     }
 
-    function getCurrentNotice($dt=null)
+    /**
+     * Get the most recent notice posted by this user, if any.
+     *
+     * @return mixed Notice or null
+     */
+    function getCurrentNotice()
     {
         $profile = $this->getProfile();
         if (!$profile) {
             return null;
         }
-        return $profile->getCurrentNotice($dt);
+        return $profile->getCurrentNotice();
     }
 
     function getCarrier()
index fb8c57c7183e6340c0ad7c404f5484e91c1e37b7..9266cab5cf40351de6f7949212fc10ec061a9645 100644 (file)
@@ -59,7 +59,11 @@ class MagicEnvelope
         }
         if ($xrd->links) {
             if ($link = Discovery::getService($xrd->links, Magicsig::PUBLICKEYREL)) {
-                list($type, $keypair) = explode(';', $link['href']);
+                list($type, $keypair) = explode(',', $link['href']);
+                if (empty($keypair)) {
+                    // Backwards compatibility check for separator bug in 0.9.0
+                    list($type, $keypair) = explode(';', $link['href']);
+                }
                 return $keypair;
             }
         }
@@ -70,7 +74,7 @@ class MagicEnvelope
     public function signMessage($text, $mimetype, $keypair)
     {
         $signature_alg = Magicsig::fromString($keypair);
-        $armored_text = base64_encode($text);
+        $armored_text = base64_url_encode($text);
 
         return array(
             'data' => $armored_text,
@@ -108,7 +112,7 @@ class MagicEnvelope
     public function unfold($env)
     {
         $dom = new DOMDocument();
-        $dom->loadXML(base64_decode($env['data']));
+        $dom->loadXML(base64_url_decode($env['data']));
 
         if ($dom->documentElement->tagName != 'entry') {
             return false;
@@ -165,7 +169,7 @@ class MagicEnvelope
             return false;
         }
 
-        $text = base64_decode($env['data']);
+        $text = base64_url_decode($env['data']);
         $signer_uri = $this->getAuthor($text);
 
         try {
@@ -193,11 +197,12 @@ class MagicEnvelope
 
     public function fromDom($dom)
     {
-        if ($dom->documentElement->tagName == 'entry') {
+        $env_element = $dom->getElementsByTagNameNS(MagicEnvelope::NS, 'env')->item(0);
+        if (!$env_element) {
             $env_element = $dom->getElementsByTagNameNS(MagicEnvelope::NS, 'provenance')->item(0);
-        } else if ($dom->documentElement->tagName == 'me:env') {
-            $env_element = $dom->documentElement;
-        } else {
+        }
+
+        if (!$env_element) {
             return false;
         }
 
index 6881292add2a3c58afaf0fed1487aa5252eaddf0..b3c1d84530e2ce100cc92b38b3a82a25b4cfca7b 100644 (file)
@@ -91,7 +91,7 @@ class XrdAction extends Action
         }
 
         $xrd->links[] = array('rel' => Magicsig::PUBLICKEYREL,
-                              'href' => 'data:application/magic-public-key;'. $magickey->toString(false));
+                              'href' => 'data:application/magic-public-key,'. $magickey->toString(false));
 
         // TODO - finalize where the redirect should go on the publisher
         $url = common_local_url('ostatussub') . '?profile={uri}';