]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Diaspora/Receive.php
Merge pull request #9783 from foss-/patch-1
[friendica.git] / src / Module / Diaspora / Receive.php
index 978bccd833027b15ffd0b9e5da35929e5e661082..372e7394638e67d94b0057b60fae3dd0b097e01e 100644 (file)
@@ -1,10 +1,28 @@
 <?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
 
 namespace Friendica\Module\Diaspora;
 
-use Friendica\App;
 use Friendica\BaseModule;
-use Friendica\Core\Config\Configuration;
+use Friendica\DI;
 use Friendica\Model\User;
 use Friendica\Network\HTTPException;
 use Friendica\Protocol\Diaspora;
@@ -20,25 +38,20 @@ class Receive extends BaseModule
        /** @var LoggerInterface */
        private static $logger;
 
-       public static function init()
+       public static function init(array $parameters = [])
        {
-               /** @var LoggerInterface $logger */
-               self::$logger = self::getClass(LoggerInterface::class);
+               self::$logger = DI::logger();
        }
 
-       public static function post()
+       public static function post(array $parameters = [])
        {
-               /** @var Configuration $config */
-               $config = self::getClass(Configuration::class);
-
-               $enabled = $config->get('system', 'diaspora_enabled', false);
+               $enabled = DI::config()->get('system', 'diaspora_enabled', false);
                if (!$enabled) {
                        self::$logger->info('Diaspora disabled.');
-                       throw new HTTPException\InternalServerErrorException('Diaspora disabled.');
+                       throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
                }
 
-               /** @var App\Arguments $args */
-               $args = self::getClass(App\Arguments::class);
+               $args = DI::args();
 
                $type = $args->get(1);
 
@@ -135,7 +148,7 @@ class Receive extends BaseModule
                }
 
                self::$logger->info('Diaspora: Post decoded.');
-               self::$logger->debug('Diaspora: Decoded message.', ['msg' => print_r($msg, true)]);
+               self::$logger->debug('Diaspora: Decoded message.', ['msg' => $msg]);
 
                if (!is_array($msg)) {
                        throw new HTTPException\InternalServerErrorException('Message is not an array.');