]> 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 1e287b2ce441fd8f18205db7d05b7bee9a22892e..e1bf8a823fd4b810c147a049d26cd8083a387765 100644 (file)
@@ -8,25 +8,24 @@ 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\PConfig;
 use Friendica\Core\L10n;
-use Friendica\Core\Logger;
 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;
 use Friendica\Model\Contact;
 use Friendica\Model\Conversation;
 use Friendica\Model\GContact;
-use Friendica\Model\APContact;
 use Friendica\Model\Item;
 use Friendica\Model\User;
 use Friendica\Network\Probe;
-use Friendica\Object\Image;
-use Friendica\Protocol\Activity\Namespaces;
 use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Images;
 use Friendica\Util\Network;
 use Friendica\Util\Proxy as ProxyUtils;
 use Friendica\Util\Strings;
@@ -262,14 +261,14 @@ class OStatus
                @$doc->loadXML($xml);
 
                $xpath = new DOMXPath($doc);
-               $xpath->registerNamespace('atom', Namespaces::ATOM1);
-               $xpath->registerNamespace('thr', Namespaces::THREAD);
-               $xpath->registerNamespace('georss', Namespaces::GEORSS);
-               $xpath->registerNamespace('activity', Namespaces::ACTIVITY);
-               $xpath->registerNamespace('media', Namespaces::MEDIA);
-               $xpath->registerNamespace('poco', Namespaces::POCO);
-               $xpath->registerNamespace('ostatus', Namespaces::OSTATUS);
-               $xpath->registerNamespace('statusnet', Namespaces::STATUSNET);
+               $xpath->registerNamespace('atom', ActivityNamespace::ATOM1);
+               $xpath->registerNamespace('thr', ActivityNamespace::THREAD);
+               $xpath->registerNamespace('georss', ActivityNamespace::GEORSS);
+               $xpath->registerNamespace('activity', ActivityNamespace::ACTIVITY);
+               $xpath->registerNamespace('media', ActivityNamespace::MEDIA);
+               $xpath->registerNamespace('poco', ActivityNamespace::POCO);
+               $xpath->registerNamespace('ostatus', ActivityNamespace::OSTATUS);
+               $xpath->registerNamespace('statusnet', ActivityNamespace::STATUSNET);
 
                $contact = ["id" => 0];
 
@@ -343,14 +342,14 @@ class OStatus
                @$doc->loadXML($xml);
 
                $xpath = new DOMXPath($doc);
-               $xpath->registerNamespace('atom', Namespaces::ATOM1);
-               $xpath->registerNamespace('thr', Namespaces::THREAD);
-               $xpath->registerNamespace('georss', Namespaces::GEORSS);
-               $xpath->registerNamespace('activity', Namespaces::ACTIVITY);
-               $xpath->registerNamespace('media', Namespaces::MEDIA);
-               $xpath->registerNamespace('poco', Namespaces::POCO);
-               $xpath->registerNamespace('ostatus', Namespaces::OSTATUS);
-               $xpath->registerNamespace('statusnet', Namespaces::STATUSNET);
+               $xpath->registerNamespace('atom', ActivityNamespace::ATOM1);
+               $xpath->registerNamespace('thr', ActivityNamespace::THREAD);
+               $xpath->registerNamespace('georss', ActivityNamespace::GEORSS);
+               $xpath->registerNamespace('activity', ActivityNamespace::ACTIVITY);
+               $xpath->registerNamespace('media', ActivityNamespace::MEDIA);
+               $xpath->registerNamespace('poco', ActivityNamespace::POCO);
+               $xpath->registerNamespace('ostatus', ActivityNamespace::OSTATUS);
+               $xpath->registerNamespace('statusnet', ActivityNamespace::STATUSNET);
 
                $hub = "";
                $hub_items = $xpath->query("/atom:feed/atom:link[@rel='hub']")->item(0);
@@ -434,7 +433,7 @@ class OStatus
                                continue;
                        }
 
-                       if (in_array($item["verb"], [Namespaces::OSTATUS . "/unfavorite", Activity::UNFAVORITE])) {
+                       if (in_array($item["verb"], [Activity::O_UNFAVOURITE, Activity::UNFAVORITE])) {
                                // Ignore "Unfavorite" message
                                Logger::log("Ignore unfavorite message ".print_r($item, true), Logger::DEBUG);
                                continue;
@@ -465,7 +464,7 @@ class OStatus
                                continue;
                        }
 
-                       if ($item["verb"] == Namespaces::OSTATUS."/unfollow") {
+                       if ($item["verb"] == Activity::O_UNFOLLOW) {
                                $dummy = null;
                                Contact::removeFollower($importer, $contact, $item, $dummy);
                                continue;
@@ -478,7 +477,7 @@ class OStatus
                                $item["verb"] = Activity::LIKE;
                                $item["parent-uri"] = $orig_uri;
                                $item["gravity"] = GRAVITY_ACTIVITY;
-                               $item["object-type"] = Activity::OBJ_NOTE;
+                               $item["object-type"] = Activity\ObjectType::NOTE;
                        }
 
                        // http://activitystrea.ms/schema/1.0/rsvp-yes
@@ -495,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);
                                                }
@@ -540,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);
@@ -593,10 +592,10 @@ class OStatus
        {
                $item["body"] = HTML::toBBCode(XML::getFirstNodeValue($xpath, 'atom:content/text()', $entry));
                $item["object-type"] = XML::getFirstNodeValue($xpath, 'activity:object-type/text()', $entry);
-               if (($item["object-type"] == Activity::OBJ_BOOKMARK) || ($item["object-type"] == Activity::OBJ_EVENT)) {
+               if (($item["object-type"] == Activity\ObjectType::BOOKMARK) || ($item["object-type"] == Activity\ObjectType::EVENT)) {
                        $item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
                        $item["body"] = XML::getFirstNodeValue($xpath, 'atom:summary/text()', $entry);
-               } elseif ($item["object-type"] == Activity::OBJ_QUESTION) {
+               } elseif ($item["object-type"] == Activity\ObjectType::QUESTION) {
                        $item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
                }
 
@@ -647,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]';
                                        }
                                }
                        }
@@ -804,9 +803,9 @@ class OStatus
                @$doc->loadXML($xml);
 
                $xpath = new DOMXPath($doc);
-               $xpath->registerNamespace('atom', Namespaces::ATOM1);
-               $xpath->registerNamespace('thr', Namespaces::THREAD);
-               $xpath->registerNamespace('ostatus', Namespaces::OSTATUS);
+               $xpath->registerNamespace('atom', ActivityNamespace::ATOM1);
+               $xpath->registerNamespace('thr', ActivityNamespace::THREAD);
+               $xpath->registerNamespace('ostatus', ActivityNamespace::OSTATUS);
 
                $entries = $xpath->query('/atom:feed/atom:entry');
 
@@ -1106,8 +1105,8 @@ class OStatus
                                switch ($attribute['rel']) {
                                        case "alternate":
                                                $item["plink"] = $attribute['href'];
-                                               if (($item["object-type"] == Activity::OBJ_QUESTION)
-                                                       || ($item["object-type"] == Activity::OBJ_EVENT)
+                                               if (($item["object-type"] == Activity\ObjectType::QUESTION)
+                                                       || ($item["object-type"] == Activity\ObjectType::EVENT)
                                                ) {
                                                        $item["body"] .= add_page_info($attribute['href']);
                                                }
@@ -1136,7 +1135,7 @@ class OStatus
                                                }
                                                break;
                                        case "related":
-                                               if ($item["object-type"] != Activity::OBJ_BOOKMARK) {
+                                               if ($item["object-type"] != Activity\ObjectType::BOOKMARK) {
                                                        if (!isset($item["parent-uri"])) {
                                                                $item["parent-uri"] = $attribute['href'];
                                                        }
@@ -1198,37 +1197,12 @@ class OStatus
         */
        private static function getResharedGuid(array $item)
        {
-               $body = trim($item["body"]);
-
-               // Skip if it isn't a pure repeated messages
-               // Does it start with a share?
-               if (strpos($body, "[share") > 0) {
-                       return "";
-               }
-
-               // Does it end with a share?
-               if (strlen($body) > (strrpos($body, "[/share]") + 8)) {
-                       return "";
-               }
-
-               $attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "$1", $body);
-               // Skip if there is no shared message in there
-               if ($body == $attributes) {
-                       return false;
-               }
-
-               $guid = "";
-               preg_match("/guid='(.*?)'/ism", $attributes, $matches);
-               if (!empty($matches[1])) {
-                       $guid = $matches[1];
-               }
-
-               preg_match('/guid="(.*?)"/ism', $attributes, $matches);
-               if (!empty($matches[1])) {
-                       $guid = $matches[1];
+               $reshared = Item::getShareArray($item);
+               if (empty($reshared['guid']) || !empty($reshared['comment'])) {
+                       return '';
                }
 
-               return $guid;
+               return $reshared['guid'];
        }
 
        /**
@@ -1282,17 +1256,17 @@ class OStatus
         */
        private static function addHeader(DOMDocument $doc, array $owner, $filter, $feed_mode = false)
        {
-               $root = $doc->createElementNS(Namespaces::ATOM1, 'feed');
+               $root = $doc->createElementNS(ActivityNamespace::ATOM1, 'feed');
                $doc->appendChild($root);
 
-               $root->setAttribute("xmlns:thr", Namespaces::THREAD);
-               $root->setAttribute("xmlns:georss", Namespaces::GEORSS);
-               $root->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
-               $root->setAttribute("xmlns:media", Namespaces::MEDIA);
-               $root->setAttribute("xmlns:poco", Namespaces::POCO);
-               $root->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
-               $root->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
-               $root->setAttribute("xmlns:mastodon", Namespaces::MASTODON);
+               $root->setAttribute("xmlns:thr", ActivityNamespace::THREAD);
+               $root->setAttribute("xmlns:georss", ActivityNamespace::GEORSS);
+               $root->setAttribute("xmlns:activity", ActivityNamespace::ACTIVITY);
+               $root->setAttribute("xmlns:media", ActivityNamespace::MEDIA);
+               $root->setAttribute("xmlns:poco", ActivityNamespace::POCO);
+               $root->setAttribute("xmlns:ostatus", ActivityNamespace::OSTATUS);
+               $root->setAttribute("xmlns:statusnet", ActivityNamespace::STATUSNET);
+               $root->setAttribute("xmlns:mastodon", ActivityNamespace::MASTODON);
 
                $title = '';
                $selfUri = '/feed/' . $owner["nick"] . '/';
@@ -1316,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"]);
@@ -1329,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) {
@@ -1369,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"]);
        }
 
@@ -1389,7 +1363,7 @@ class OStatus
                switch ($siteinfo["type"]) {
                        case 'photo':
                                if (!empty($siteinfo["image"])) {
-                                       $imgdata = Image::getInfoFromURL($siteinfo["image"]);
+                                       $imgdata = Images::getInfoFromURLCached($siteinfo["image"]);
                                        if ($imgdata) {
                                                $attributes = ["rel" => "enclosure",
                                                                "href" => $siteinfo["image"],
@@ -1413,7 +1387,7 @@ class OStatus
                }
 
                if (!Config::get('system', 'ostatus_not_attach_preview') && ($siteinfo["type"] != "photo") && isset($siteinfo["image"])) {
-                       $imgdata = Image::getInfoFromURL($siteinfo["image"]);
+                       $imgdata = Images::getInfoFromURLCached($siteinfo["image"]);
                        if ($imgdata) {
                                $attributes = ["rel" => "enclosure",
                                                "href" => $siteinfo["image"],
@@ -1462,9 +1436,9 @@ class OStatus
                $author = $doc->createElement("author");
                XML::addElement($doc, $author, "id", $owner["url"]);
                if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
-                       XML::addElement($doc, $author, "activity:object-type", Activity::OBJ_GROUP);
+                       XML::addElement($doc, $author, "activity:object-type", Activity\ObjectType::GROUP);
                } else {
-                       XML::addElement($doc, $author, "activity:object-type", Activity::OBJ_PERSON);
+                       XML::addElement($doc, $author, "activity:object-type", Activity\ObjectType::PERSON);
                }
                XML::addElement($doc, $author, "uri", $owner["url"]);
                XML::addElement($doc, $author, "name", $owner["nick"]);
@@ -1515,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"]) {
@@ -1557,11 +1531,11 @@ class OStatus
         */
        private static function constructObjecttype(array $item)
        {
-               if (!empty($item['object-type']) && in_array($item['object-type'], [Activity::OBJ_NOTE, Activity::OBJ_COMMENT])) {
+               if (!empty($item['object-type']) && in_array($item['object-type'], [Activity\ObjectType::NOTE, Activity\ObjectType::COMMENT])) {
                        return $item['object-type'];
                }
 
-               return Activity::OBJ_NOTE;
+               return Activity\ObjectType::NOTE;
        }
 
        /**
@@ -1592,7 +1566,7 @@ class OStatus
 
                if ($item["verb"] == Activity::LIKE) {
                        return self::likeEntry($doc, $item, $owner, $toplevel);
-               } elseif (in_array($item["verb"], [Activity::FOLLOW, Namespaces::OSTATUS . "/unfollow"])) {
+               } elseif (in_array($item["verb"], [Activity::FOLLOW, Activity::O_UNFOLLOW])) {
                        return self::followEntry($doc, $item, $owner, $toplevel);
                } else {
                        return self::noteEntry($doc, $item, $owner, $toplevel, $feed_mode);
@@ -1710,7 +1684,7 @@ class OStatus
 
                $as_object = $doc->createElement("activity:object");
 
-               XML::addElement($doc, $as_object, "activity:object-type", Namespaces::ACTIVITY_SCHEMA . "activity");
+               XML::addElement($doc, $as_object, "activity:object-type", ActivityNamespace::ACTIVITY_SCHEMA . "activity");
 
                self::entryContent($doc, $as_object, $repeated_item, $owner, "", "", false);
 
@@ -1760,7 +1734,7 @@ class OStatus
 
                $entry = self::entryHeader($doc, $owner, $item, $toplevel);
 
-               $verb = Activity\Namespaces::ACTIVITY_SCHEMA."favorite";
+               $verb = ActivityNamespace::ACTIVITY_SCHEMA . "favorite";
                self::entryContent($doc, $entry, $item, $owner, "Favorite", $verb, false);
 
                $parent = Item::selectFirst([], ['uri' => $item["thr-parent"], 'uid' => $item["uid"]]);
@@ -1791,7 +1765,7 @@ class OStatus
        private static function addPersonObject(DOMDocument $doc, array $owner, array $contact)
        {
                $object = $doc->createElement("activity:object");
-               XML::addElement($doc, $object, "activity:object-type", Activity::OBJ_PERSON);
+               XML::addElement($doc, $object, "activity:object-type", Activity\ObjectType::PERSON);
 
                if ($contact['network'] == Protocol::PHANTOM) {
                        XML::addElement($doc, $object, "id", $contact['url']);
@@ -1870,7 +1844,7 @@ class OStatus
                }
 
                $item["uri"] = $item['parent-uri'] = $item['thr-parent']
-                               = 'tag:'.get_app()->getHostName().
+                               = 'tag:' . DI::baseUrl()->getHostname().
                                ','.date('Y-m-d').':'.$action.':'.$owner['uid'].
                                ':person:'.$connect_id.':'.$item['created'];
 
@@ -1919,7 +1893,7 @@ class OStatus
 
                $entry = self::entryHeader($doc, $owner, $item, $toplevel);
 
-               XML::addElement($doc, $entry, "activity:object-type", Activity::OBJ_NOTE);
+               XML::addElement($doc, $entry, "activity:object-type", Activity\ObjectType::NOTE);
 
                self::entryContent($doc, $entry, $item, $owner, $title, '', true, $feed_mode);
 
@@ -1951,16 +1925,16 @@ class OStatus
                                $entry->appendChild($author);
                        }
                } else {
-                       $entry = $doc->createElementNS(Namespaces::ATOM1, "entry");
+                       $entry = $doc->createElementNS(ActivityNamespace::ATOM1, "entry");
 
-                       $entry->setAttribute("xmlns:thr", Namespaces::THREAD);
-                       $entry->setAttribute("xmlns:georss", Namespaces::GEORSS);
-                       $entry->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
-                       $entry->setAttribute("xmlns:media", Namespaces::MEDIA);
-                       $entry->setAttribute("xmlns:poco", Namespaces::POCO);
-                       $entry->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
-                       $entry->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
-                       $entry->setAttribute("xmlns:mastodon", Namespaces::MASTODON);
+                       $entry->setAttribute("xmlns:thr", ActivityNamespace::THREAD);
+                       $entry->setAttribute("xmlns:georss", ActivityNamespace::GEORSS);
+                       $entry->setAttribute("xmlns:activity", ActivityNamespace::ACTIVITY);
+                       $entry->setAttribute("xmlns:media", ActivityNamespace::MEDIA);
+                       $entry->setAttribute("xmlns:poco", ActivityNamespace::POCO);
+                       $entry->setAttribute("xmlns:ostatus", ActivityNamespace::OSTATUS);
+                       $entry->setAttribute("xmlns:statusnet", ActivityNamespace::STATUSNET);
+                       $entry->setAttribute("xmlns:mastodon", ActivityNamespace::MASTODON);
 
                        $author = self::addAuthor($doc, $owner);
                        $entry->appendChild($author);
@@ -2003,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)) {
@@ -2047,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 = [
@@ -2112,14 +2086,14 @@ class OStatus
                                XML::addElement($doc, $entry, "link", "",
                                        [
                                                "rel" => "mentioned",
-                                               "ostatus:object-type" => Activity::OBJ_GROUP,
+                                               "ostatus:object-type" => Activity\ObjectType::GROUP,
                                                "href" => $mention]
                                );
                        } else {
                                XML::addElement($doc, $entry, "link", "",
                                        [
                                                "rel" => "mentioned",
-                                               "ostatus:object-type" => Activity::OBJ_PERSON,
+                                               "ostatus:object-type" => Activity\ObjectType::PERSON,
                                                "href" => $mention]
                                );
                        }
@@ -2211,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'];
@@ -2232,7 +2206,7 @@ class OStatus
 
                if ($filter === 'comments') {
                        $condition[0] .= " AND `object-type` = ? ";
-                       $condition[] = Activity::OBJ_COMMENT;
+                       $condition[] = Activity\ObjectType::COMMENT;
                }
 
                if ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
@@ -2272,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);