]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/OStatus/Salmon.php
Merge pull request #13724 from Raroun/Fix-for-Issue-#13637---Photo-caption-prevents...
[friendica.git] / src / Module / OStatus / Salmon.php
index f674f9300b8ebe3dddb0795756bfbc1ba4544049..9f064869287aa7e08b4f23792ad21a3f8e92902c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -62,17 +62,19 @@ class Salmon extends \Friendica\BaseModule
         * @throws HTTPException\OKException
         * @throws \ImagickException
         */
-       protected function rawContent(array $request = [])
+       protected function post(array $request = [])
        {
                $xml = Network::postdata();
+               $this->logger->debug('Got request data.', ['request' => $request]);
 
-               $this->logger->debug('New Salmon', ['nickname' => $this->parameters['nickname'], 'xml' => $xml]);
-
-               // Despite having a route with a mandatory nickname parameter, this method can also be called from
-               // \Friendica\Module\DFRN\Notify->post where the same parameter is optional 🤷‍
                $nickname = $this->parameters['nickname'] ?? '';
+               if (empty($nickname)) {
+                       throw new HTTPException\BadRequestException('nickname parameter is mandatory');
+               }
+
+               $this->logger->debug('New Salmon', ['nickname' => $nickname, 'xml' => $xml]);
 
-               $importer = $this->database->selectFirst('user', [], ['nickname' => $nickname, 'account_expired' => false, 'account_removed' => false]);
+               $importer = $this->database->selectFirst('user', [], ['nickname' => $nickname, 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false]);
                if (!$this->database->isResult($importer)) {
                        throw new HTTPException\InternalServerErrorException();
                }
@@ -142,14 +144,9 @@ class Salmon extends \Friendica\BaseModule
                        throw new HTTPException\BadRequestException();
                }
 
-               $key_info = explode('.', $key);
-
-               $m = Strings::base64UrlDecode($key_info[1]);
-               $e = Strings::base64UrlDecode($key_info[2]);
-
-               $this->logger->info('Key details', ['info' => $key_info]);
+               $this->logger->info('Key details', ['info' => $key]);
 
-               $pubkey = Crypto::meToPem($m, $e);
+               $pubkey = SalmonProtocol::magicKeyToPem($key);
 
                // We should have everything we need now. Let's see if it verifies.