From b11426dbf4d5175da091b63af6cfbad6e1c4bedb Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 10 Jan 2011 14:56:15 -0500 Subject: [PATCH] normalize accounts and check for return in HTTP for moving --- lib/accountmover.php | 2 ++ lib/activitysink.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/accountmover.php b/lib/accountmover.php index ba9da0f6fd..eefd0487d8 100644 --- a/lib/accountmover.php +++ b/lib/accountmover.php @@ -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)) { diff --git a/lib/activitysink.php b/lib/activitysink.php index 287fd8f0ab..fbe1f1e7ff 100644 --- a/lib/activitysink.php +++ b/lib/activitysink.php @@ -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}"); + } } } -- 2.39.5