diff --git a/include/api.php b/include/api.php index 3373ffe48d..4f7040ab4b 100644 --- a/include/api.php +++ b/include/api.php @@ -646,53 +646,6 @@ function group_create($name, $uid, $users = []) * TWITTER API */ -/** - * Deprecated function to upload media. - * - * @param string $type Return type (atom, rss, xml, json) - * - * @return array|string - * @throws BadRequestException - * @throws ForbiddenException - * @throws ImagickException - * @throws InternalServerErrorException - * @throws UnauthorizedException - */ -function api_statuses_mediap($type) -{ - BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); - $uid = BaseApi::getCurrentUserID(); - - $a = DI::app(); - - $_REQUEST['profile_uid'] = $uid; - $_REQUEST['api_source'] = true; - $txt = $_REQUEST['status'] ?? ''; - - if ((strpos($txt, '<') !== false) || (strpos($txt, '>') !== false)) { - $txt = HTML::toBBCodeVideo($txt); - $config = HTMLPurifier_Config::createDefault(); - $config->set('Cache.DefinitionImpl', null); - $purifier = new HTMLPurifier($config); - $txt = $purifier->purify($txt); - } - $txt = HTML::toBBCode($txt); - - $picture = Photo::upload($uid, $_FILES['media']); - - // now that we have the img url in bbcode we can add it to the status and insert the wall item. - $_REQUEST['body'] = $txt . "\n\n" . '[url=' . $picture["albumpage"] . '][img]' . $picture["preview"] . "[/img][/url]"; - $item_id = item_post($a); - - $include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true'); - - // output the post that we just posted. - $status_info = DI::twitterStatus()->createFromItemId($item_id, $uid, $include_entities)->toArray(); - return DI::apiResponse()->formatData('statuses', $type, ['status' => $status_info]); -} - -api_register_func('api/statuses/mediap', 'api_statuses_mediap', true); - /** * Updates the user’s current status. * @@ -876,6 +829,7 @@ function api_statuses_update($type) api_register_func('api/statuses/update', 'api_statuses_update', true); api_register_func('api/statuses/update_with_media', 'api_statuses_update', true); +api_register_func('api/statuses/mediap', 'api_statuses_update', true); /** * Repeats a status. diff --git a/tests/legacy/ApiTest.php b/tests/legacy/ApiTest.php index a80b587d1e..d78a61df9d 100644 --- a/tests/legacy/ApiTest.php +++ b/tests/legacy/ApiTest.php @@ -875,6 +875,7 @@ class ApiTest extends FixtureTest */ public function testApiStatusesMediap() { + /* DI::args()->setArgc(2); $_FILES = [ @@ -892,6 +893,7 @@ class ApiTest extends FixtureTest $result = api_statuses_mediap('json'); self::assertStatus($result['status']); + */ } /** @@ -901,10 +903,10 @@ class ApiTest extends FixtureTest */ public function testApiStatusesMediapWithoutAuthenticatedUser() { - $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class); - BasicAuth::setCurrentUserID(); - $_SESSION['authenticated'] = false; - api_statuses_mediap('json'); + // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class); + // BasicAuth::setCurrentUserID(); + // $_SESSION['authenticated'] = false; + // api_statuses_mediap('json'); } /**