]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/OStatus.php
Move PConfig::get() to DI::pConfig()->get()
[friendica.git] / src / Protocol / OStatus.php
index bd045c0200564bef4b3712b0e4881c00b159929f..e1bf8a823fd4b810c147a049d26cd8083a387765 100644 (file)
@@ -8,14 +8,13 @@ use DOMDocument;
 use DOMXPath;
 use Friendica\Content\Text\BBCode;
 use Friendica\Content\Text\HTML;
-use Friendica\Core\Cache;
+use Friendica\Core\Cache\Cache;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\Lock;
 use Friendica\Core\Logger;
 use Friendica\Core\PConfig;
 use Friendica\Core\Protocol;
-use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\APContact;
@@ -25,8 +24,6 @@ use Friendica\Model\GContact;
 use Friendica\Model\Item;
 use Friendica\Model\User;
 use Friendica\Network\Probe;
-use Friendica\Object\Image;
-use Friendica\Protocol\ActivityNamespace;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Images;
 use Friendica\Util\Network;
@@ -497,7 +494,7 @@ class OStatus
 
                                        if (!$valid) {
                                                // If not, then it depends on this setting
-                                               $valid = ((self::$itemlist[0]['uid'] == 0) || !PConfig::get(self::$itemlist[0]['uid'], 'system', 'accept_only_sharer', false));
+                                               $valid = ((self::$itemlist[0]['uid'] == 0) || !DI::pConfig()->get(self::$itemlist[0]['uid'], 'system', 'accept_only_sharer', false));
                                                if ($valid) {
                                                        Logger::log("Item with uri ".self::$itemlist[0]['uri']." will be imported due to the system settings.", Logger::DEBUG);
                                                }
@@ -542,9 +539,9 @@ class OStatus
                                                        Logger::log("Item with uri ".$item["uri"]." is from a blocked contact.", Logger::DEBUG);
                                                } else {
                                                        // We are having duplicated entries. Hopefully this solves it.
-                                                       if (Lock::acquire('ostatus_process_item_insert')) {
+                                                       if (DI::lock()->acquire('ostatus_process_item_insert')) {
                                                                $ret = Item::insert($item);
-                                                               Lock::release('ostatus_process_item_insert');
+                                                               DI::lock()->release('ostatus_process_item_insert');
                                                                Logger::log("Item with uri ".$item["uri"]." for user ".$importer["uid"].' stored. Return value: '.$ret);
                                                        } else {
                                                                $ret = Item::insert($item);
@@ -649,7 +646,7 @@ class OStatus
                                                        $item['tag'] = '';
                                                }
 
-                                               $item['tag'] .= '#[url=' . System::baseUrl() . '/search?tag=' . $term . ']' . $term . '[/url]';
+                                               $item['tag'] .= '#[url=' . DI::baseUrl() . '/search?tag=' . $term . ']' . $term . '[/url]';
                                        }
                                }
                        }
@@ -1293,7 +1290,7 @@ class OStatus
 
                $attributes = ["uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION];
                XML::addElement($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
-               XML::addElement($doc, $root, "id", System::baseUrl() . "/profile/" . $owner["nick"]);
+               XML::addElement($doc, $root, "id", DI::baseUrl() . "/profile/" . $owner["nick"]);
                XML::addElement($doc, $root, "title", $title);
                XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], Config::get('config', 'sitename')));
                XML::addElement($doc, $root, "logo", $owner["photo"]);
@@ -1306,23 +1303,23 @@ class OStatus
                XML::addElement($doc, $root, "link", "", $attributes);
 
                /// @TODO We have to find out what this is
-               /// $attributes = array("href" => System::baseUrl()."/sup",
+               /// $attributes = array("href" => DI::baseUrl()."/sup",
                ///             "rel" => "http://api.friendfeed.com/2008/03#sup",
                ///             "type" => "application/json");
                /// XML::addElement($doc, $root, "link", "", $attributes);
 
                self::hublinks($doc, $root, $owner["nick"]);
 
-               $attributes = ["href" => System::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "salmon"];
+               $attributes = ["href" => DI::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "salmon"];
                XML::addElement($doc, $root, "link", "", $attributes);
 
-               $attributes = ["href" => System::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "http://salmon-protocol.org/ns/salmon-replies"];
+               $attributes = ["href" => DI::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "http://salmon-protocol.org/ns/salmon-replies"];
                XML::addElement($doc, $root, "link", "", $attributes);
 
-               $attributes = ["href" => System::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "http://salmon-protocol.org/ns/salmon-mention"];
+               $attributes = ["href" => DI::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "http://salmon-protocol.org/ns/salmon-mention"];
                XML::addElement($doc, $root, "link", "", $attributes);
 
-               $attributes = ["href" => System::baseUrl() . $selfUri, "rel" => "self", "type" => "application/atom+xml"];
+               $attributes = ["href" => DI::baseUrl() . $selfUri, "rel" => "self", "type" => "application/atom+xml"];
                XML::addElement($doc, $root, "link", "", $attributes);
 
                if ($owner['account-type'] == Contact::TYPE_COMMUNITY) {
@@ -1346,7 +1343,7 @@ class OStatus
         */
        public static function hublinks(DOMDocument $doc, $root, $nick)
        {
-               $h = System::baseUrl() . '/pubsubhubbub/'.$nick;
+               $h = DI::baseUrl() . '/pubsubhubbub/'.$nick;
                XML::addElement($doc, $root, "link", "", ["href" => $h, "rel" => "hub"]);
        }
 
@@ -1492,7 +1489,7 @@ class OStatus
                                $author->appendChild($urls);
                        }
 
-                       XML::addElement($doc, $author, "followers", "", ["url" => System::baseUrl() . "/profile/" . $owner["nick"] . "/contacts/followers"]);
+                       XML::addElement($doc, $author, "followers", "", ["url" => DI::baseUrl() . "/profile/" . $owner["nick"] . "/contacts/followers"]);
                        XML::addElement($doc, $author, "statusnet:profile_info", "", ["local_id" => $owner["uid"]]);
 
                        if ($profile["publish"]) {
@@ -1980,7 +1977,7 @@ class OStatus
                XML::addElement($doc, $entry, "content", $body, ["type" => "html"]);
 
                XML::addElement($doc, $entry, "link", "", ["rel" => "alternate", "type" => "text/html",
-                                                               "href" => System::baseUrl()."/display/".$item["guid"]]
+                                                               "href" => DI::baseUrl()."/display/".$item["guid"]]
                );
 
                if (!$feed_mode && $complete && ($item["id"] > 0)) {
@@ -2024,7 +2021,7 @@ class OStatus
                        } else {
                                $mentioned[$parent["author-link"]] = $parent["author-link"];
                                $mentioned[$parent["owner-link"]] = $parent["owner-link"];
-                               $parent_plink = System::baseUrl()."/display/".$parent["guid"];
+                               $parent_plink = DI::baseUrl()."/display/".$parent["guid"];
                        }
 
                        $attributes = [
@@ -2188,7 +2185,7 @@ class OStatus
 
                // Don't cache when the last item was posted less then 15 minutes ago (Cache duration)
                if ((time() - strtotime($owner['last-item'])) < 15*60) {
-                       $result = Cache::get($cachekey);
+                       $result = DI::cache()->get($cachekey);
                        if (!$nocache && !is_null($result)) {
                                Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created . ' (cached)', Logger::DEBUG);
                                $last_update = $result['last_update'];
@@ -2249,7 +2246,7 @@ class OStatus
                $feeddata = trim($doc->saveXML());
 
                $msg = ['feed' => $feeddata, 'last_update' => $last_update];
-               Cache::set($cachekey, $msg, Cache::QUARTER_HOUR);
+               DI::cache()->set($cachekey, $msg, Cache::QUARTER_HOUR);
 
                Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, Logger::DEBUG);