diff --git a/src/Module/Api/ApiResponse.php b/src/Module/Api/ApiResponse.php index c4b9b1e94..a6a94ad81 100644 --- a/src/Module/Api/ApiResponse.php +++ b/src/Module/Api/ApiResponse.php @@ -221,6 +221,16 @@ class ApiResponse extends Response $this->addContent($return); } + /** + * Wrapper around exit() for JSON only responses + * + * @param array $data + */ + public function exitWithJson(array $data) + { + $this->exit('content', ['content' => $data], static::TYPE_JSON); + } + /** * Quit execution with the message that the endpoint isn't implemented * diff --git a/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php b/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php index 4318fac7b..058a52f63 100644 --- a/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php +++ b/src/Module/Api/Mastodon/Accounts/VerifyCredentials.php @@ -52,6 +52,6 @@ class VerifyCredentials extends BaseApi // @todo Support the source property, $account = DI::mstdnAccount()->createFromContactId($cdata['user'], $uid); - $this->response->exit('account', ['account' => $account->toArray()]); + $this->response->exitWithJson($account->toArray()); } } diff --git a/tests/src/Module/Api/Mastodon/Accounts/StatusesTest.php b/tests/src/Module/Api/Mastodon/Accounts/StatusesTest.php index 0c6aab886..f2a709531 100644 --- a/tests/src/Module/Api/Mastodon/Accounts/StatusesTest.php +++ b/tests/src/Module/Api/Mastodon/Accounts/StatusesTest.php @@ -14,7 +14,7 @@ class StatusesTest extends ApiTest */ public function testApiStatusShowWithJson() { - self::markTestIncomplete('Needs Stastuses to not set header during call (like at BaseApi::setLinkHeader'); + self::markTestIncomplete('Needs Statuses to not set header during call (like at BaseApi::setLinkHeader'); // $result = api_status_show('json', 1); // self::assertStatus($result['status']); @@ -25,7 +25,7 @@ class StatusesTest extends ApiTest */ public function testApiStatusShowWithXml() { - self::markTestIncomplete('Needs Stastuses to not set header during call (like at BaseApi::setLinkHeader'); + self::markTestIncomplete('Needs Statuses to not set header during call (like at BaseApi::setLinkHeader'); // $result = api_status_show('xml', 1); // self::assertXml($result, 'statuses');