]> git.mxchange.org Git - friendica.git/blobdiff - mod/pubsubhubbub.php
Add tests for the PermissionSet repository
[friendica.git] / mod / pubsubhubbub.php
index f376e9e8567663ab555f05e6626dba5cd95fa869..2cc2394c19c42ad5ef8cf37fb4e35aa78df9c784 100644 (file)
@@ -60,15 +60,15 @@ function pubsubhubbub_init(App $a) {
                } elseif ($hub_mode === 'unsubscribe') {
                        $subscribe = 0;
                } else {
-                       Logger::log("Invalid hub_mode=$hub_mode, ignoring.");
+                       Logger::notice("Invalid hub_mode=$hub_mode, ignoring.");
                        throw new \Friendica\Network\HTTPException\NotFoundException();
                }
 
-               Logger::log("$hub_mode request from " . $_SERVER['REMOTE_ADDR']);
+               Logger::info("$hub_mode request from " . $_SERVER['REMOTE_ADDR']);
 
-               if ($a->argc > 1) {
+               if (DI::args()->getArgc() > 1) {
                        // Normally the url should now contain the nick name as last part of the url
-                       $nick = $a->argv[1];
+                       $nick = DI::args()->getArgv()[1];
                } else {
                        // Get the nick name from the topic as a fallback
                        $nick = $hub_topic;
@@ -77,7 +77,7 @@ function pubsubhubbub_init(App $a) {
                $nick = basename($nick, '.atom');
 
                if (!$nick) {
-                       Logger::log('Bad hub_topic=$hub_topic, ignoring.');
+                       Logger::notice('Bad hub_topic=$hub_topic, ignoring.');
                        throw new \Friendica\Network\HTTPException\NotFoundException();
                }
 
@@ -85,7 +85,7 @@ function pubsubhubbub_init(App $a) {
                $condition = ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false];
                $owner = DBA::selectFirst('user', ['uid', 'nickname'], $condition);
                if (!DBA::isResult($owner)) {
-                       Logger::log('Local account not found: ' . $nick . ' - topic: ' . $hub_topic . ' - callback: ' . $hub_callback);
+                       Logger::notice('Local account not found: ' . $nick . ' - topic: ' . $hub_topic . ' - callback: ' . $hub_callback);
                        throw new \Friendica\Network\HTTPException\NotFoundException();
                }
 
@@ -94,7 +94,7 @@ function pubsubhubbub_init(App $a) {
                        'pending' => false, 'self' => true];
                $contact = DBA::selectFirst('contact', ['poll'], $condition);
                if (!DBA::isResult($contact)) {
-                       Logger::log('Self contact for user ' . $owner['uid'] . ' not found.');
+                       Logger::notice('Self contact for user ' . $owner['uid'] . ' not found.');
                        throw new \Friendica\Network\HTTPException\NotFoundException();
                }
 
@@ -103,7 +103,7 @@ function pubsubhubbub_init(App $a) {
                $self = DI::baseUrl() . '/api/statuses/user_timeline/' . $owner['nickname'] . '.atom';
 
                if (!Strings::compareLink($hub_topic, $contact['poll']) && !Strings::compareLink($hub_topic2, $contact['poll']) && !Strings::compareLink($hub_topic, $self)) {
-                       Logger::log('Hub topic ' . $hub_topic . ' != ' . $contact['poll']);
+                       Logger::notice('Hub topic ' . $hub_topic . ' != ' . $contact['poll']);
                        throw new \Friendica\Network\HTTPException\NotFoundException();
                }
 
@@ -125,20 +125,20 @@ function pubsubhubbub_init(App $a) {
                $hub_callback = rtrim($hub_callback, ' ?&#');
                $separator = parse_url($hub_callback, PHP_URL_QUERY) === null ? '?' : '&';
 
-               $fetchResult = DI::httpRequest()->fetchFull($hub_callback . $separator . $params);
+               $fetchResult = DI::httpClient()->fetchFull($hub_callback . $separator . $params);
                $body = $fetchResult->getBody();
                $ret = $fetchResult->getReturnCode();
 
                // give up if the HTTP return code wasn't a success (2xx)
                if ($ret < 200 || $ret > 299) {
-                       Logger::log("Subscriber verification for $hub_topic at $hub_callback returned $ret, ignoring.");
+                       Logger::notice("Subscriber verification for $hub_topic at $hub_callback returned $ret, ignoring.");
                        throw new \Friendica\Network\HTTPException\NotFoundException();
                }
 
                // check that the correct hub_challenge code was echoed back
                if (trim($body) !== $hub_challenge) {
-                       Logger::log("Subscriber did not echo back hub.challenge, ignoring.");
-                       Logger::log("\"$hub_challenge\" != \"".trim($body)."\"");
+                       Logger::notice("Subscriber did not echo back hub.challenge, ignoring.");
+                       Logger::notice("\"$hub_challenge\" != \"".trim($body)."\"");
                        throw new \Friendica\Network\HTTPException\NotFoundException();
                }