]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/Post.php
Superfluous todo removed
[friendica.git] / src / Object / Post.php
index dcb7ad208b2dede4e3ff95e3ceffe2ccb15eadc2..fe271b5a87afae50ea6ba75a95923085b440ef18 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
  *
@@ -29,10 +29,10 @@ use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
 use Friendica\Core\Session;
-use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
+use Friendica\Model\Photo;
 use Friendica\Model\Post as PostModel;
 use Friendica\Model\Tag;
 use Friendica\Model\User;
@@ -42,6 +42,7 @@ use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Proxy;
 use Friendica\Util\Strings;
 use Friendica\Util\Temporal;
+use InvalidArgumentException;
 
 /**
  * An item
@@ -105,7 +106,7 @@ class Post
                                // Only add will be displayed
                                if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
                                        continue;
-                               } elseif (!visible_activity($item)) {
+                               } elseif (!DI::contentItem()->isVisibleActivity($item)) {
                                        continue;
                                }
 
@@ -121,33 +122,63 @@ class Post
                }
        }
 
+       /**
+        * Fetch the privacy of the post
+        *
+        * @param array $item Item record
+        * @return string Item privacy message
+        * @throws InvalidArgumentException If $item['private'] is unknown
+        */
+       private function fetchPrivacy(array $item): string
+       {
+               switch ($item['private']) {
+                       case Item::PRIVATE:
+                               $output = DI::l10n()->t('Private Message');
+                               break;
+
+                       case Item::PUBLIC:
+                               $output = DI::l10n()->t('Public Message');
+                               break;
+
+                       case Item::UNLISTED:
+                               $output = DI::l10n()->t('Unlisted Message');
+                               break;
+
+                       default:
+                               throw new InvalidArgumentException('Item privacy ' . $item['privacy'] . ' is unsupported');
+               }
+
+               return $output;
+       }
+
        /**
         * Get data in a form usable by a conversation template
         *
         * @param array   $conv_responses conversation responses
+        * @param string $formSecurityToken A security Token to avoid CSF attacks
         * @param integer $thread_level   default = 1
         *
-        * @return mixed The data requested on success
-        *               false on failure
+        * @return mixed The data requested on success, false on failure
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       public function getTemplateData(array $conv_responses, $thread_level = 1)
+       public function getTemplateData(array $conv_responses, string $formSecurityToken, int $thread_level = 1)
        {
-               $a = DI::app();
-
                $item = $this->getData();
                $edited = false;
-               // If the time between "created" and "edited" differs we add
-               // a notice that the post was edited.
-               // Note: In some networks reshared items seem to have (sometimes) a difference
-               // between creation time and edit time of a second. Thats why we add the notice
-               // only if the difference is more than 1 second.
+
+               /*
+                * If the time between "created" and "edited" differs we add
+                * a notice that the post was edited.
+                * Note: In some networks reshared items seem to have (sometimes) a difference
+                * between creation time and edit time of a second. Thats why we add the notice
+                * only if the difference is more than 1 second.
+                */
                if (strtotime($item['edited']) - strtotime($item['created']) > 1) {
                        $edited = [
                                'label'    => DI::l10n()->t('This entry was edited'),
                                'date'     => DateTimeFormat::local($item['edited'], 'r'),
-                               'relative' => Temporal::getRelativeDate($item['edited'])
+                               'relative' => Temporal::getRelativeDate($item['edited']),
                        ];
                }
                $sparkle = '';
@@ -162,8 +193,8 @@ class Post
                $pin = false;
                $star = false;
                $ignore = false;
-               $ispinned = "unpinned";
-               $isstarred = "unstarred";
+               $ispinned = 'unpinned';
+               $isstarred = 'unstarred';
                $indent = '';
                $shiny = '';
                $osparkle = '';
@@ -171,10 +202,9 @@ class Post
 
                $conv = $this->getThread();
 
-               $lock = ((($item['private'] == Item::PRIVATE) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
-                       || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
-                       ? DI::l10n()->t('Private Message')
-                       : false);
+               $privacy   = $this->fetchPrivacy($item);
+               $lock      = ($item['private'] == Item::PRIVATE) ? $privacy : false;
+               $connector = !in_array($item['network'], Protocol::NATIVE_SUPPORT) ? DI::l10n()->t('Connector Message') : false;
 
                $shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != Item::PRIVATE;
                $announceable = $shareable && in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER]);
@@ -188,10 +218,10 @@ class Post
 
                if (local_user()) {
                        if (Strings::compareLink(Session::get('my_url'), $item['author-link'])) {
-                               if ($item["event-id"] != 0) {
-                                       $edpost = ["events/event/" . $item['event-id'], DI::l10n()->t("Edit")];
+                               if ($item['event-id'] != 0) {
+                                       $edpost = ['events/event/' . $item['event-id'], DI::l10n()->t('Edit')];
                                } else {
-                                       $edpost = ["editpost/" . $item['id'], DI::l10n()->t("Edit")];
+                                       $edpost = ['editpost/' . $item['id'], DI::l10n()->t('Edit')];
                                }
                        }
                        $dropping = in_array($item['uid'], [0, local_user()]);
@@ -210,7 +240,7 @@ class Post
 
                $origin = $item['origin'] || $item['parent-origin'];
 
-               if ($item['pinned']) {
+               if (!empty($item['featured'])) {
                        $pinned = DI::l10n()->t('Pinned item');
                }
 
@@ -228,7 +258,7 @@ class Post
                        ];
                }
 
-               if (!$item['self']) {
+               if (!$item['self'] && local_user()) {
                        $block = [
                                'blocking' => true,
                                'block'   => DI::l10n()->t('Block %s', $item['author-name']),
@@ -236,7 +266,7 @@ class Post
                        ];
                }
 
-               $filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? DI::l10n()->t('Save to folder') : false);
+               $filer = local_user() ? DI::l10n()->t('Save to folder') : false;
 
                $profile_name = $item['author-name'];
                if (!empty($item['author-link']) && empty($item['author-name'])) {
@@ -268,6 +298,7 @@ class Post
                        $response_verbs[] = 'attendyes';
                        $response_verbs[] = 'attendno';
                        $response_verbs[] = 'attendmaybe';
+
                        if ($conv->isWritable()) {
                                $isevent = true;
                                $attend = [DI::l10n()->t('I will attend'), DI::l10n()->t('I will not attend'), DI::l10n()->t('I might attend')];
@@ -278,7 +309,7 @@ class Post
                foreach ($response_verbs as $value => $verb) {
                        $responses[$verb] = [
                                'self'   => $conv_responses[$verb][$item['uri-id']]['self'] ?? 0,
-                               'output' => !empty($conv_responses[$verb][$item['uri-id']]) ? format_activity($conv_responses[$verb][$item['uri-id']]['links'], $verb, $item['uri-id']) : '',
+                               'output' => !empty($conv_responses[$verb][$item['uri-id']]) ? DI::conversation()->formatActivity($conv_responses[$verb][$item['uri-id']]['links'], $verb, $item['uri-id']) : '',
                        ];
                }
 
@@ -296,47 +327,47 @@ class Post
                $tagger = '';
 
                if ($this->isToplevel()) {
-                       if(local_user()) {
+                       if (local_user()) {
                                $ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], local_user());
                                if ($item['mention'] || $ignored) {
                                        $ignore = [
                                                'do'        => DI::l10n()->t('Ignore thread'),
                                                'undo'      => DI::l10n()->t('Unignore thread'),
                                                'toggle'    => DI::l10n()->t('Toggle ignore status'),
-                                               'classdo'   => $ignored ? "hidden" : "",
-                                               'classundo' => $ignored ? "" : "hidden",
+                                               'classdo'   => $ignored ? 'hidden' : '',
+                                               'classundo' => $ignored ? '' : 'hidden',
                                                'ignored'   => DI::l10n()->t('Ignored'),
                                        ];
                                }
 
+                               $isstarred = (($item['starred']) ? 'starred' : 'unstarred');
+
+                               $star = [
+                                       'do'        => DI::l10n()->t('Add star'),
+                                       'undo'      => DI::l10n()->t('Remove star'),
+                                       'toggle'    => DI::l10n()->t('Toggle star status'),
+                                       'classdo'   => $item['starred'] ? 'hidden' : '',
+                                       'classundo' => $item['starred'] ? '' : 'hidden',
+                                       'starred'   => DI::l10n()->t('Starred'),
+                               ];
+
                                if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) {
-                                       if ($origin) {
-                                               $ispinned = ($item['pinned'] ? 'pinned' : 'unpinned');
+                                       if ($origin && in_array($item['private'], [Item::PUBLIC, Item::UNLISTED])) {
+                                               $ispinned = ($item['featured'] ? 'pinned' : 'unpinned');
 
                                                $pin = [
                                                        'do'        => DI::l10n()->t('Pin'),
                                                        'undo'      => DI::l10n()->t('Unpin'),
                                                        'toggle'    => DI::l10n()->t('Toggle pin status'),
-                                                       'classdo'   => $item['pinned'] ? 'hidden' : '',
-                                                       'classundo' => $item['pinned'] ? '' : 'hidden',
+                                                       'classdo'   => $item['featured'] ? 'hidden' : '',
+                                                       'classundo' => $item['featured'] ? '' : 'hidden',
                                                        'pinned'   => DI::l10n()->t('Pinned'),
                                                ];
                                        }
 
-                                       $isstarred = (($item['starred']) ? "starred" : "unstarred");
-
-                                       $star = [
-                                               'do'        => DI::l10n()->t('Add star'),
-                                               'undo'      => DI::l10n()->t('Remove star'),
-                                               'toggle'    => DI::l10n()->t('Toggle star status'),
-                                               'classdo'   => $item['starred'] ? "hidden" : "",
-                                               'classundo' => $item['starred'] ? "" : "hidden",
-                                               'starred'   => DI::l10n()->t('Starred'),
-                                       ];
-
                                        $tagger = [
                                                'add'   => DI::l10n()->t('Add tag'),
-                                               'class' => "",
+                                               'class' => '',
                                        ];
                                }
                        }
@@ -362,16 +393,18 @@ class Post
                        $shiny = 'shiny';
                }
 
-               localize_item($item);
+               DI::contentItem()->localize($item);
 
                $body_html = Item::prepareBody($item, true);
 
-               list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item);
+               list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, local_user());
 
-               if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) {
+               if (!empty($item['title'])) {
+                       $title = $item['title'];
+               } elseif (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) {
                        $title = ucfirst($item['content-warning']);
                } else {
-                       $title = $item['title'];
+                       $title = '';
                }
 
                if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) {
@@ -379,17 +412,17 @@ class Post
                }
 
                // Disable features that aren't available in several networks
-               if (!in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA])) {
-                       if ($buttons["dislike"]) {
-                               $buttons["dislike"] = false;
+               if (!in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA])) {
+                       if ($buttons['dislike']) {
+                               $buttons['dislike'] = false;
                        }
 
                        $isevent = false;
                        $tagger = '';
                }
 
-               if ($buttons["like"] && in_array($item["network"], [Protocol::FEED, Protocol::MAIL])) {
-                       $buttons["like"] = false;
+               if ($buttons['like'] && in_array($item['network'], [Protocol::FEED, Protocol::MAIL])) {
+                       $buttons['like'] = false;
                }
 
                $tags = Tag::populateFromItem($item);
@@ -415,12 +448,6 @@ class Post
                $direction = [];
                if (!empty($item['direction'])) {
                        $direction = $item['direction'];
-               } elseif (DI::config()->get('debug', 'show_direction')) {
-                       $conversation = DBA::selectFirst('conversation', ['direction'], ['item-uri' => $item['uri']]);
-                       if (!empty($conversation['direction']) && in_array($conversation['direction'], [1, 2])) {
-                               $direction_title = [1 => DI::l10n()->t('Pushed'), 2 => DI::l10n()->t('Pulled')];
-                               $direction = ['direction' => $conversation['direction'], 'title' => $direction_title[$conversation['direction']]];
-                       }
                }
 
                $languages = [];
@@ -428,9 +455,15 @@ class Post
                        $languages = [DI::l10n()->t('Languages'), Item::getLanguageMessage($item)];
                }
 
+               if (in_array($item['private'], [Item::PUBLIC, Item::UNLISTED]) && in_array($item['network'], Protocol::FEDERATED)) {
+                       $browsershare = [DI::l10n()->t('Share via ...'), DI::l10n()->t('Share via external services')];
+               } else {
+                       $browsershare = null;
+               }
+
                $tmp_item = [
                        'template'        => $this->getTemplate(),
-                       'type'            => implode("", array_slice(explode("/", $item['verb']), -1)),
+                       'type'            => implode('', array_slice(explode('/', $item['verb']), -1)),
                        'comment_firstcollapsed' => false,
                        'comment_lastcollapsed' => false,
                        'suppress_tags'   => DI::config()->get('system', 'suppress_tags'),
@@ -458,8 +491,8 @@ class Post
                        'vwall'           => DI::l10n()->t('via Wall-To-Wall:'),
                        'profile_url'     => $profile_link,
                        'name'            => $profile_name,
-                       'item_photo_menu_html' => item_photo_menu($item),
-                       'thumb'           => DI::baseUrl()->remove(Contact::getAvatarUrlForUrl($item['author-link'], $item['uid'], Proxy::SIZE_THUMB)),
+                       'item_photo_menu_html' => DI::contentItem()->photoMenu($item, $formSecurityToken),
+                       'thumb'           => DI::baseUrl()->remove(DI::contentItem()->getAuthorAvatar($item)),
                        'osparkle'        => $osparkle,
                        'sparkle'         => $sparkle,
                        'title'           => $title,
@@ -468,14 +501,18 @@ class Post
                        'app'             => $item['app'],
                        'created'         => $ago,
                        'lock'            => $lock,
+                       'private'         => $item['private'],
+                       'privacy'         => $privacy,
+                       'connector'       => $connector,
                        'location_html'   => $location_html,
                        'indent'          => $indent,
                        'shiny'           => $shiny,
                        'owner_self'      => $item['author-link'] == Session::get('my_url'),
                        'owner_url'       => $this->getOwnerUrl(),
-                       'owner_photo'     => DI::baseUrl()->remove(Contact::getAvatarUrlForUrl($item['owner-link'], $item['uid'], Proxy::SIZE_THUMB)),
+                       'owner_photo'     => DI::baseUrl()->remove(DI::contentItem()->getOwnerAvatar($item)),
                        'owner_name'      => $this->getOwnerName(),
                        'plink'           => Item::getPlink($item),
+                       'browsershare'    => $browsershare,
                        'edpost'          => $edpost,
                        'ispinned'        => $ispinned,
                        'pin'             => $pin,
@@ -501,9 +538,9 @@ class Post
                        'wait'            => DI::l10n()->t('Please wait'),
                        'thread_level'    => $thread_level,
                        'edited'          => $edited,
-                       'network'         => $item["network"],
-                       'network_name'    => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network']),
-                       'network_icon'    => ContactSelector::networkToIcon($item['network'], $item['author-link']),
+                       'network'         => $item['network'],
+                       'network_name'    => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network'], $item['author-gsid']),
+                       'network_icon'    => ContactSelector::networkToIcon($item['network'], $item['author-link'], $item['author-gsid']),
                        'received'        => $item['received'],
                        'commented'       => $item['commented'],
                        'created_date'    => $item['created'],
@@ -532,7 +569,7 @@ class Post
                $nb_children = count($children);
                if ($nb_children > 0) {
                        foreach ($children as $child) {
-                               $result['children'][] = $child->getTemplateData($conv_responses, $thread_level + 1);
+                               $result['children'][] = $child->getTemplateData($conv_responses, $formSecurityToken, $thread_level + 1);
                        }
 
                        // Collapse
@@ -568,7 +605,7 @@ class Post
        /**
         * @return integer
         */
-       public function getId()
+       public function getId(): int
        {
                return $this->getDataValue('id');
        }
@@ -576,7 +613,7 @@ class Post
        /**
         * @return boolean
         */
-       public function isThreaded()
+       public function isThreaded(): bool
        {
                return $this->threaded;
        }
@@ -593,10 +630,10 @@ class Post
        {
                $item_id = $item->getId();
                if (!$item_id) {
-                       Logger::log('[ERROR] Post::addChild : Item has no ID!!', Logger::DEBUG);
+                       Logger::info('[ERROR] Post::addChild : Item has no ID!!');
                        return false;
                } elseif ($this->getChild($item->getId())) {
-                       Logger::log('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').', Logger::DEBUG);
+                       Logger::info('[WARN] Post::addChild : Item already exists (' . $item->getId() . ').');
                        return false;
                }
 
@@ -622,10 +659,9 @@ class Post
         * Get a child by its ID
         *
         * @param integer $id The child id
-        *
         * @return mixed
         */
-       public function getChild($id)
+       public function getChild(int $id)
        {
                foreach ($this->getChildren() as $child) {
                        if ($child->getId() == $id) {
@@ -641,7 +677,7 @@ class Post
         *
         * @return Post[]
         */
-       public function getChildren()
+       public function getChildren(): array
        {
                return $this->children;
        }
@@ -650,7 +686,6 @@ class Post
         * Set our parent
         *
         * @param Post $item The item to set as parent
-        *
         * @return void
         */
        protected function setParent(Post $item)
@@ -679,11 +714,10 @@ class Post
         * Remove a child
         *
         * @param Post $item The child to be removed
-        *
         * @return boolean Success or failure
         * @throws \Exception
         */
-       public function removeChild(Post $item)
+       public function removeChild(Post $item): bool
        {
                $id = $item->getId();
                foreach ($this->getChildren() as $key => $child) {
@@ -695,7 +729,8 @@ class Post
                                return true;
                        }
                }
-               Logger::log('[WARN] Item::removeChild : Item is not a child (' . $id . ').', Logger::DEBUG);
+
+               Logger::info('[WARN] Item::removeChild : Item is not a child (' . $id . ').');
                return false;
        }
 
@@ -712,8 +747,7 @@ class Post
        /**
         * Set conversation thread
         *
-        * @param Thread $thread
-        *
+        * @param Thread|null $thread
         * @return void
         */
        public function setThread(Thread $thread = null)
@@ -729,7 +763,7 @@ class Post
        /**
         * Get conversation
         *
-        * @return Thread
+        * @return Thread|null
         */
        public function getThread()
        {
@@ -743,7 +777,7 @@ class Post
         *
         * @return array
         */
-       public function getData()
+       public function getData(): array
        {
                return $this->data;
        }
@@ -752,14 +786,12 @@ class Post
         * Get a data value
         *
         * @param string $name key
-        *
-        * @return mixed value on success
-        *               false on failure
+        * @return mixed value on success, false on failure
         */
-       public function getDataValue($name)
+       public function getDataValue(string $name)
        {
                if (!isset($this->data[$name])) {
-                       // Logger::log('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".', Logger::DEBUG);
+                       // Logger::info('[ERROR] Item::getDataValue : Item has no value name "'. $name .'".');
                        return false;
                }
 
@@ -769,15 +801,15 @@ class Post
        /**
         * Set template
         *
-        * @param string $name template name
-        * @return bool
-        * @throws \Exception
+        * @param string $name Template name
+        * @return bool If template was set
+        * @throws InvalidArgumentException
         */
-       private function setTemplate($name)
+       private function setTemplate(string $name): bool
        {
                if (empty($this->available_templates[$name])) {
-                       Logger::log('[ERROR] Item::setTemplate : Template not available ("' . $name . '").', Logger::DEBUG);
-                       return false;
+                       // Throw exception
+                       throw new InvalidArgumentException('[ERROR] Item::setTemplate : Template not available ("' . $name . '").');
                }
 
                $this->template = $this->available_templates[$name];
@@ -800,7 +832,7 @@ class Post
         *
         * @return boolean
         */
-       private function isToplevel()
+       private function isToplevel(): bool
        {
                return $this->toplevel;
        }
@@ -810,7 +842,7 @@ class Post
         *
         * @return boolean
         */
-       private function isWritable()
+       private function isWritable(): bool
        {
                $conv = $this->getThread();
 
@@ -833,7 +865,7 @@ class Post
         *
         * @return integer
         */
-       private function countDescendants()
+       private function countDescendants(): int
        {
                $children = $this->getChildren();
                $total = count($children);
@@ -851,7 +883,7 @@ class Post
         *
         * @return string
         */
-       private function getCommentBoxTemplate()
+       private function getCommentBoxTemplate(): string
        {
                return $this->comment_box_template;
        }
@@ -862,7 +894,7 @@ class Post
         * @return string
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       private function getDefaultText()
+       private function getDefaultText(): string
        {
                $a = DI::app();
 
@@ -871,21 +903,20 @@ class Post
                }
 
                $owner = User::getOwnerDataById($a->getLoggedInUserId());
+               $item = $this->getData();
 
-               if (!Feature::isEnabled(local_user(), 'explicit_mentions')) {
-                       return '';
+               if (!empty($item['content-warning']) && Feature::isEnabled(local_user(), 'add_abstract')) {
+                       $text = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $item['content-warning'] . "[/abstract]\n";
+               } else {
+                       $text = '';
                }
 
-               $item = PostModel::selectFirst(['author-addr', 'uri-id', 'network', 'gravity'], ['id' => $this->getId()]);
-               if (!DBA::isResult($item) || empty($item['author-addr'])) {
-                       // Should not happen
-                       return '';
+               if (!Feature::isEnabled(local_user(), 'explicit_mentions')) {
+                       return $text;
                }
 
                if (($item['author-addr'] != $owner['addr']) && (($item['gravity'] != GRAVITY_PARENT) || !in_array($item['network'], [Protocol::DIASPORA]))) {
-                       $text = '@' . $item['author-addr'] . ' ';
-               } else {
-                       $text = '';
+                       $text .= '@' . $item['author-addr'] . ' ';
                }
 
                $terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
@@ -909,12 +940,11 @@ class Post
         * Get the comment box
         *
         * @param string $indent Indent value
-        *
-        * @return mixed The comment box string (empty if no comment box)
-        *               false on failure
+        * @return mixed The comment box string (empty if no comment box), false on failure
         * @throws \Exception
+        * @todo return false is nowhere in this method?
         */
-       private function getCommentBox($indent)
+       private function getCommentBox(string $indent)
        {
                $a = DI::app();
 
@@ -936,7 +966,7 @@ class Post
                        $uid = $conv->getProfileOwner();
                        $parent_uid = $this->getDataValue('uid');
 
-                       $contact = Contact::getById($a->getContactId());
+                       $owner = User::getOwnerDataById($a->getLoggedInUserId());
 
                        $default_text = $this->getDefaultText();
 
@@ -955,9 +985,9 @@ class Post
                                '$qcomment'    => $qcomment,
                                '$default'     => $default_text,
                                '$profile_uid' => $uid,
-                               '$mylink'      => DI::baseUrl()->remove($contact['url'] ?? ''),
+                               '$mylink'      => DI::baseUrl()->remove($owner['url'] ?? ''),
                                '$mytitle'     => DI::l10n()->t('This is you'),
-                               '$myphoto'     => DI::baseUrl()->remove($contact['thumb'] ?? ''),
+                               '$myphoto'     => DI::baseUrl()->remove($owner['thumb'] ?? ''),
                                '$comment'     => DI::l10n()->t('Comment'),
                                '$submit'      => DI::l10n()->t('Submit'),
                                '$loading'     => DI::l10n()->t('Loading...'),
@@ -982,7 +1012,7 @@ class Post
        /**
         * @return string
         */
-       private function getRedirectUrl()
+       private function getRedirectUrl(): string
        {
                return $this->redirect_url;
        }
@@ -1007,21 +1037,24 @@ class Post
                                        $owner_namematch = (($this->getDataValue('owner-name')) && $this->getDataValue('owner-name') == $this->getDataValue('author-name'));
 
                                        if (!$owner_linkmatch && !$alias_linkmatch && !$owner_namematch) {
-                                               // The author url doesn't match the owner (typically the contact)
-                                               // and also doesn't match the contact alias.
-                                               // The name match is a hack to catch several weird cases where URLs are
-                                               // all over the park. It can be tricked, but this prevents you from
-                                               // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn
-                                               // well that it's the same Bob Smith.
-                                               // But it could be somebody else with the same name. It just isn't highly likely.
-
-
+                                               /*
+                                                * The author url doesn't match the owner (typically the contact)
+                                                * and also doesn't match the contact alias.
+                                                * The name match is a hack to catch several weird cases where URLs are
+                                                * all over the park. It can be tricked, but this prevents you from
+                                                * seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn
+                                                * well that it's the same Bob Smith.
+                                                * But it could be somebody else with the same name. It just isn't highly likely.
+                                                */
                                                $this->owner_name = $this->getDataValue('owner-name');
                                                $this->wall_to_wall = true;
 
-                                               $owner = ['uid' => 0, 'id' => $this->getDataValue('owner-id'),
+                                               $owner = [
+                                                       'uid' => 0,
+                                                       'id' => $this->getDataValue('owner-id'),
                                                        'network' => $this->getDataValue('owner-network'),
-                                                       'url' => $this->getDataValue('owner-link')];
+                                                       'url' => $this->getDataValue('owner-link'),
+                                               ];
                                                $this->owner_url = Contact::magicLinkByContact($owner);
                                        }
                                }
@@ -1038,7 +1071,7 @@ class Post
        /**
         * @return boolean
         */
-       private function isWallToWall()
+       private function isWallToWall(): bool
        {
                return $this->wall_to_wall;
        }
@@ -1046,7 +1079,7 @@ class Post
        /**
         * @return string
         */
-       private function getOwnerUrl()
+       private function getOwnerUrl(): string
        {
                return $this->owner_url;
        }
@@ -1054,7 +1087,7 @@ class Post
        /**
         * @return string
         */
-       private function getOwnerName()
+       private function getOwnerName(): string
        {
                return $this->owner_name;
        }
@@ -1062,7 +1095,7 @@ class Post
        /**
         * @return boolean
         */
-       private function isVisiting()
+       private function isVisiting(): bool
        {
                return $this->visiting;
        }