]> git.mxchange.org Git - friendica.git/blobdiff - mod/pubsub.php
Forgot one Logpoint ..
[friendica.git] / mod / pubsub.php
index cbf678a93f8cc7de4c08f815bf9cb8fb9cdae205..1dfbd0b3dc9960f72848dc156400f6e2e489b5d9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -25,11 +25,11 @@ use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
-use Friendica\Protocol\Feed;
 use Friendica\Protocol\OStatus;
 use Friendica\Util\Strings;
 use Friendica\Util\Network;
-use Friendica\Core\System;
+use Friendica\Model\GServer;
+use Friendica\Model\Post;
 
 function hub_return($valid, $body)
 {
@@ -50,8 +50,8 @@ function hub_post_return()
 
 function pubsub_init(App $a)
 {
-       $nick       = (($a->argc > 1) ? Strings::escapeTags(trim($a->argv[1])) : '');
-       $contact_id = (($a->argc > 2) ? intval($a->argv[2])       : 0 );
+       $nick       = ((DI::args()->getArgc() > 1) ? Strings::escapeTags(trim(DI::args()->getArgv()[1])) : '');
+       $contact_id = ((DI::args()->getArgc() > 2) ? intval(DI::args()->getArgv()[2])       : 0 );
 
        if ($_SERVER['REQUEST_METHOD'] === 'GET') {
                $hub_mode      = Strings::escapeTags(trim($_GET['hub_mode'] ?? ''));
@@ -96,7 +96,7 @@ function pubsub_init(App $a)
                }
 
                if (!empty($hub_mode)) {
-                       DBA::update('contact', ['subhub' => $subscribe], ['id' => $contact['id']]);
+                       Contact::update(['subhub' => $subscribe], ['id' => $contact['id']]);
                        Logger::log($hub_mode . ' success for contact ' . $contact_id . '.');
                }
                hub_return(true, $hub_challenge);
@@ -110,8 +110,8 @@ function pubsub_post(App $a)
        Logger::log('Feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' .  DI::args()->getCommand() . ' with user-agent: ' . $_SERVER['HTTP_USER_AGENT']);
        Logger::log('Data: ' . $xml, Logger::DATA);
 
-       $nick       = (($a->argc > 1) ? Strings::escapeTags(trim($a->argv[1])) : '');
-       $contact_id = (($a->argc > 2) ? intval($a->argv[2])       : 0 );
+       $nick       = ((DI::args()->getArgc() > 1) ? Strings::escapeTags(trim(DI::args()->getArgv()[1])) : '');
+       $contact_id = ((DI::args()->getArgc() > 2) ? intval(DI::args()->getArgv()[2])       : 0 );
 
        $importer = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
        if (!DBA::isResult($importer)) {
@@ -134,6 +134,10 @@ function pubsub_post(App $a)
                }
        }
 
+       if (!empty($contact['gsid'])) {
+               GServer::setProtocol($contact['gsid'], Post\DeliveryData::OSTATUS);
+       }
+
        if (!in_array($contact['rel'], [Contact::SHARING, Contact::FRIEND]) && ($contact['network'] != Protocol::FEED)) {
                Logger::log('Contact ' . $contact['id'] . ' is not expected to share with us - ignored.');
                hub_post_return();