]> git.mxchange.org Git - friendica.git/commitdiff
Unified request for uid
authorMichael <heluecht@pirati.ca>
Tue, 8 Jun 2021 08:28:14 +0000 (08:28 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 8 Jun 2021 08:28:14 +0000 (08:28 +0000)
src/Module/Api/Mastodon/Accounts.php
src/Module/Api/Mastodon/Accounts/Follow.php
src/Module/Api/Mastodon/Accounts/Statuses.php
src/Module/Api/Mastodon/Lists.php
src/Module/Api/Mastodon/Statuses.php
src/Module/BaseApi.php

index f650af0587ce9974e374b0a66731fc31047a0ad4..781547854aada3932d0e753ad33726b608ba2e94 100644 (file)
@@ -38,6 +38,8 @@ class Accounts extends BaseApi
         */
        public static function rawContent(array $parameters = [])
        {
+               $uid = self::getCurrentUserID();
+
                if (empty($parameters['id']) && empty($parameters['name'])) {
                        DI::mstdnError()->UnprocessableEntity();
                }
@@ -56,7 +58,7 @@ class Accounts extends BaseApi
                        }
                }
 
-               $account = DI::mstdnAccount()->createFromContactId($id, self::getCurrentUserID());
+               $account = DI::mstdnAccount()->createFromContactId($id, $uid);
                System::jsonExit($account);
        }
 }
index bdd21c73750357c05c7bfc52bcd78e1e5c241993..d877629fb5f6ae8f202cf068dacb1ed20d7c036b 100644 (file)
@@ -40,7 +40,7 @@ class Follow extends BaseApi
                        DI::mstdnError()->UnprocessableEntity();
                }
 
-               $cid = Contact::follow($parameters['id'], self::getCurrentUserID());
+               $cid = Contact::follow($parameters['id'], $uid);
 
                System::jsonExit(DI::mstdnRelationship()->createFromContactId($cid, $uid)->toArray());
        }
index 07a1e5adc267343452d8a1104ecdebcf74b48373..3b281392bf741673b18f0b10f4cc48a9c03384a6 100644 (file)
@@ -42,6 +42,8 @@ class Statuses extends BaseApi
         */
        public static function rawContent(array $parameters = [])
        {
+               $uid = self::getCurrentUserID();
+
                if (empty($parameters['id'])) {
                        DI::mstdnError()->UnprocessableEntity();
                }
@@ -66,8 +68,6 @@ class Statuses extends BaseApi
 
                $params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
 
-               $uid = self::getCurrentUserID();
-
                if (!$uid) {
                        $condition = ['author-id' => $id, 'private' => [Item::PUBLIC, Item::UNLISTED],
                                'uid' => 0, 'network' => Protocol::FEDERATED];
index 67db0b81f2e78e16229476f4c3a7293014c8b195..2d7fea3dd5ae02fbdc5037454080e28915a0194e 100644 (file)
@@ -34,7 +34,6 @@ class Lists extends BaseApi
        public static function delete(array $parameters = [])
        {
                self::login(self::SCOPE_WRITE);
-
                $uid = self::getCurrentUserID();
 
                if (empty($parameters['id'])) {
@@ -55,8 +54,7 @@ class Lists extends BaseApi
        public static function post(array $parameters = [])
        {
                self::login(self::SCOPE_WRITE);
-
-               $uid   = self::getCurrentUserID();
+               $uid = self::getCurrentUserID();
 
                $request = self::getRequest([
                        'title' => '',
index 8e13afb2fadc0450a412ec9747b56d24fc54d679..f2ff792dbc2e133d4e536a870b7ff7a4ea344e99 100644 (file)
@@ -219,10 +219,12 @@ class Statuses extends BaseApi
         */
        public static function rawContent(array $parameters = [])
        {
+               $uid = self::getCurrentUserID();
+
                if (empty($parameters['id'])) {
                        DI::mstdnError()->UnprocessableEntity();
                }
 
-               System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], self::getCurrentUserID()));
+               System::jsonExit(DI::mstdnStatus()->createFromUriId($parameters['id'], $uid));
        }
 }
index 5e5b3986b14ffe92b1fc8fd0e741b1e5ef722291..7c3e63ee84158d26620f6d5e849b41deb98e0be9 100644 (file)
@@ -173,21 +173,9 @@ class BaseApi extends BaseModule
        }
 
        /**
-        * Log in user via OAuth or Simple HTTP Auth.
-        *
-        * Simple Auth allow username in form of <pre>user@server</pre>, ignoring server part
+        * Log in user via OAuth or Basic HTTP Auth.
         *
         * @param string $scope the requested scope (read, write, follow)
-        *
-        * @throws HTTPException\ForbiddenException
-        * @throws HTTPException\UnauthorizedException
-        * @throws HTTPException\InternalServerErrorException
-        * @hook  'authenticate'
-        *               array $addon_auth
-        *               'username' => username from login form
-        *               'password' => password from login form
-        *               'authenticated' => return status,
-        *               'user_record' => return authenticated user record
         */
        protected static function login(string $scope)
        {