]> git.mxchange.org Git - friendica.git/commitdiff
Deprecated upload function relocates to a replacement
authorMichael <heluecht@pirati.ca>
Sat, 27 Nov 2021 13:41:49 +0000 (13:41 +0000)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 28 Nov 2021 03:25:41 +0000 (22:25 -0500)
include/api.php
tests/legacy/ApiTest.php

index 3373ffe48ddc250fd9dcd2de6b4327e61cd8fe90..4f7040ab4bc5da4884901e921a03a616dd804ba8 100644 (file)
@@ -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.
index a80b587d1e5878b38d40ee52cc213604e00c9a1f..d78a61df9d6536a1a090579577b86e8ec4b58a0f 100644 (file)
@@ -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');
        }
 
        /**