]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/BaseApi.php
Issue 11566: More detailled notification configuration
[friendica.git] / src / Module / BaseApi.php
index 233edeec8a4b6fd2eb521a3cf8324d4f2eec88a7..b6824140db632ab8b73afbff30f0042baf6af2ea 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -79,19 +79,21 @@ class BaseApi extends BaseModule
         *
         * @throws HTTPException\ForbiddenException
         */
-       public function run(array $request = []): ResponseInterface
+       public function run(array $request = [], bool $scopecheck = true): ResponseInterface
        {
-               switch ($this->server['REQUEST_METHOD'] ?? Router::GET) {
-                       case Router::DELETE:
-                       case Router::PATCH:
-                       case Router::POST:
-                       case Router::PUT:
-                               self::checkAllowedScope(self::SCOPE_WRITE);
-
-                               if (!self::getCurrentUserID()) {
-                                       throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
-                               }
-                               break;
+               if ($scopecheck) {
+                       switch ($this->args->getMethod()) {
+                               case Router::DELETE:
+                               case Router::PATCH:
+                               case Router::POST:
+                               case Router::PUT:
+                                       self::checkAllowedScope(self::SCOPE_WRITE);
+       
+                                       if (!self::getCurrentUserID()) {
+                                               throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
+                                       }
+                                       break;
+                       }       
                }
 
                return parent::run($request);