]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/DFRN/Notify.php
Merge remote-tracking branch 'upstream/develop' into json-ld
[friendica.git] / src / Module / DFRN / Notify.php
index eb0434897083b9bb804f00f2f89dd3f558df63e1..2dae0da0ad8a11816dfe1ef922cbfa95631c9cc7 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
  *
@@ -24,6 +24,7 @@ namespace Friendica\Module\DFRN;
 use Friendica\BaseModule;
 use Friendica\Core\Logger;
 use Friendica\Core\System;
+use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Conversation;
 use Friendica\Model\User;
@@ -37,7 +38,7 @@ use Friendica\Network\HTTPException;
  */
 class Notify extends BaseModule
 {
-       public static function post(array $parameters = [])
+       protected function post(array $request = [])
        {
                $postdata = Network::postdata();
 
@@ -46,24 +47,25 @@ class Notify extends BaseModule
                }
 
                $data = json_decode($postdata);
-               if (is_object($data) && !empty($parameters['nickname'])) {
-                       $user = User::getByNickname($parameters['nickname']);
+               if (is_object($data) && !empty($this->parameters['nickname'])) {
+                       $user = User::getByNickname($this->parameters['nickname']);
                        if (empty($user)) {
                                throw new \Friendica\Network\HTTPException\InternalServerErrorException();
                        }
                        self::dispatchPrivate($user, $postdata);
                } elseif (!self::dispatchPublic($postdata)) {
                        require_once 'mod/salmon.php';
-                       salmon_post($a, $postdata);
+                       salmon_post(DI::app(), $postdata);
                }
        }
 
-       private static function dispatchPublic($postdata)
+       private static function dispatchPublic(array $postdata)
        {
                $msg = Diaspora::decodeRaw($postdata, '', true);
-               if (!$msg) {
+               if (!is_array($msg)) {
                        // We have to fail silently to be able to hand it over to the salmon parser
-                       return false;
+                       Logger::warning('Diaspora::decodeRaw() has failed for some reason.');
+                       return;
                }
 
                // Fetch the corresponding public contact
@@ -87,10 +89,10 @@ class Notify extends BaseModule
                System::xmlExit($ret, 'Done');
        }
 
-       private static function dispatchPrivate($user, $postdata)
+       private static function dispatchPrivate(array $user, string $postdata)
        {
                $msg = Diaspora::decodeRaw($postdata, $user['prvkey'] ?? '');
-               if (!$msg) {
+               if (!is_array($msg)) {
                        System::xmlExit(4, 'Unable to parse message');
                }