]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/Post.php
Change FollowRequest to return the user ID so is compatible with POST endpoint
[friendica.git] / src / Object / Post.php
index 87951c19ccf52d4c5f69e6fd3ce4ee7066c9a4f2..0a05429dfda19e7f02c8f7c4021f69a40356198b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -191,7 +191,7 @@ class Post
                $pinned = '';
                $pin = false;
                $star = false;
-               $ignore = false;
+               $ignore_thread = false;
                $ispinned = 'unpinned';
                $isstarred = 'unstarred';
                $indent = '';
@@ -220,7 +220,7 @@ class Post
                                if ($item['event-id'] != 0) {
                                        $edpost = ['calendar/event/edit/' . $item['event-id'], DI::l10n()->t('Edit')];
                                } else {
-                                       $edpost = ['editpost/' . $item['id'], DI::l10n()->t('Edit')];
+                                       $edpost = [sprintf('post/%s/edit', $item['id']), DI::l10n()->t('Edit')];
                                }
                        }
                        $dropping = in_array($item['uid'], [0, DI::userSession()->getLocalUserId()]);
@@ -246,8 +246,9 @@ class Post
                // Showing the one or the other text, depending upon if we can only hide it or really delete it.
                $delete = $origin ? DI::l10n()->t('Delete globally') : DI::l10n()->t('Remove locally');
 
-               $drop = false;
-               $block = false;
+               $drop   = false;
+               $block  = false;
+               $ignore = false;
                if (DI::userSession()->getLocalUserId()) {
                        $drop = [
                                'dropping' => $dropping,
@@ -259,9 +260,14 @@ class Post
 
                if (!$item['self'] && DI::userSession()->getLocalUserId()) {
                        $block = [
-                               'blocking' => true,
-                               'block'   => DI::l10n()->t('Block %s', $item['author-name']),
-                               'author_id'   => $item['author-id'],
+                               'blocking'  => true,
+                               'block'     => DI::l10n()->t('Block %s', $item['author-name']),
+                               'author_id' => $item['author-id'],
+                       ];
+                       $ignore = [
+                               'ignoring'  => true,
+                               'ignore'    => DI::l10n()->t('Ignore %s', $item['author-name']),
+                               'author_id' => $item['author-id'],
                        ];
                }
 
@@ -327,14 +333,14 @@ class Post
 
                if ($this->isToplevel()) {
                        if (DI::userSession()->getLocalUserId()) {
-                               $ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], DI::userSession()->getLocalUserId());
-                               if ($item['mention'] || $ignored) {
-                                       $ignore = [
+                               $ignored_thread = PostModel\ThreadUser::getIgnored($item['uri-id'], DI::userSession()->getLocalUserId());
+                               if ($item['mention'] || $ignored_thread) {
+                                       $ignore_thread = [
                                                '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_thread ? 'hidden' : '',
+                                               'classundo' => $ignored_thread ? '' : 'hidden',
                                                'ignored'   => DI::l10n()->t('Ignored'),
                                        ];
                                }
@@ -518,12 +524,13 @@ class Post
                        'pinned'          => $pinned,
                        'isstarred'       => $isstarred,
                        'star'            => $star,
-                       'ignore'          => $ignore,
+                       'ignore'          => $ignore_thread,
                        'tagger'          => $tagger,
                        'filer'           => $filer,
                        'language'        => $languages,
                        'drop'            => $drop,
                        'block'           => $block,
+                       'ignore_author'   => $ignore,
                        'vote'            => $buttons,
                        'like_html'       => $responses['like']['output'],
                        'dislike_html'    => $responses['dislike']['output'],
@@ -622,7 +629,7 @@ class Post
        public function addChild(Post $item)
        {
                if (!$item->getId()) {
-                       Logger::fatal('Post object has no id', ['post' => $item]);
+                       Logger::error('Post object has no id', ['post' => $item]);
                        return false;
                } elseif ($this->getChild($item->getId())) {
                        Logger::warning('Post object already exists', ['post' => $item]);
@@ -633,7 +640,7 @@ class Post
                 * Only add what will be displayed
                 */
                if ($item->getDataValue('network') === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item->getDataValue('uid')) {
-                       Logger::warning('Post object does not belong to local user', ['post' => $item, 'local_user' => $local_user]);
+                       Logger::warning('Post object does not belong to local user', ['post' => $item, 'local_user' => DI::userSession()->getLocalUserId()]);
                        return false;
                } elseif (DI::activity()->match($item->getDataValue('verb'), Activity::LIKE) ||
                          DI::activity()->match($item->getDataValue('verb'), Activity::DISLIKE)) {