]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
normalize accounts and check for return in HTTP for moving
authorEvan Prodromou <evan@status.net>
Mon, 10 Jan 2011 19:56:15 +0000 (14:56 -0500)
committerEvan Prodromou <evan@status.net>
Sun, 16 Jan 2011 22:17:55 +0000 (17:17 -0500)
lib/accountmover.php
lib/activitysink.php

index ba9da0f6fd27106ebb14a444c7690cdf18895cfe..eefd0487d8a9f38c05a175121f032a9c024ff31d 100644 (file)
@@ -57,6 +57,8 @@ class AccountMover
         $this->_user    = $user;
         $this->_profile = $user->getProfile();
 
+        $remote = Discovery::normalize($remote);
+
         $oprofile = Ostatus_profile::ensureProfileURI($remote);
 
         if (empty($oprofile)) {
index 287fd8f0ab396ad6425e40a28865e87ac903ff8d..fbe1f1e7ff9d5945c6660dd47981a719d728aa5f 100644 (file)
@@ -151,5 +151,19 @@ class ActivitySink
         $client->setBody($activity->asString(true, true, true));
 
         $response = $client->send();
+
+        $status = $response->getStatus();
+        $reason = $response->getReasonPhrase();
+
+        if ($status >= 200 && $status < 300) {
+            return true;
+        } else if ($status >= 400 && $status < 500) {
+            throw new ClientException("{$url} {$status} {$reason}");
+        } else if ($status >= 500 && $status < 600) {
+            throw new ServerException("{$url} {$status} {$reason}");
+        } else {
+            // That's unexpected.
+            throw new Exception("{$url} {$status} {$reason}");
+        }
     }
 }