]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
Avoid duplicated filed posts
[friendica.git] / include / conversation.php
index 684532345f5f0d082768dd9d1b2df6b8c717ad11..c49aacb17780cd3ed6a2c2713110b6adad8dbe14 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 use Friendica\App;
+use Friendica\BaseModule;
 use Friendica\Content\ContactSelector;
 use Friendica\Content\Feature;
 use Friendica\Core\ACL;
@@ -396,6 +397,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
        $threadsid = -1;
 
        $page_template = Renderer::getMarkupTemplate("conversation.tpl");
+       $formSecurityToken = BaseModule::getFormSecurityToken('contact_action');
 
        if (!empty($items)) {
                if (in_array($mode, ['community', 'contacts'])) {
@@ -417,7 +419,14 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
 
                        $tpl = 'search_item.tpl';
 
+                       $uriids = [];
+
                        foreach ($items as $item) {
+                               if (in_array($item['uri-id'], $uriids)) {
+                                       continue;
+                               }
+
+                               $uriids[] = $item['uri-id'];
 
                                if (!visible_activity($item)) {
                                        continue;
@@ -481,7 +490,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
 
                                $body_html = Item::prepareBody($item, true, $preview);
 
-                               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)) {
                                        $title = ucfirst($item['content-warning']);
@@ -502,7 +511,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                        'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link']),
                                        'linktitle' => DI::l10n()->t('View %s\'s profile @ %s', $profile_name, $item['author-link']),
                                        'profile_url' => $profile_link,
-                                       'item_photo_menu_html' => item_photo_menu($item),
+                                       'item_photo_menu_html' => item_photo_menu($item, $formSecurityToken),
                                        'name' => $profile_name,
                                        'sparkle' => $sparkle,
                                        'lock' => false,
@@ -590,7 +599,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                }
                        }
 
-                       $threads = $conv->getTemplateData($conv_responses);
+                       $threads = $conv->getTemplateData($conv_responses, $formSecurityToken);
                        if (!$threads) {
                                Logger::log('[ERROR] conversation : Failed to get template data.', Logger::DEBUG);
                                $threads = [];
@@ -782,7 +791,7 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
        return $items;
 }
 
-function item_photo_menu($item)
+function item_photo_menu($item, string $formSecurityToken)
 {
        DI::profiler()->startRecording('rendering');
        $sub_link = '';
@@ -825,8 +834,8 @@ function item_photo_menu($item)
        if (!empty($pcid)) {
                $contact_url = 'contact/' . $pcid;
                $posts_link  = $contact_url . '/posts';
-               $block_link  = $item['self'] ? '' : $contact_url . '/block';
-               $ignore_link = $item['self'] ? '' : $contact_url . '/ignore';
+               $block_link  = $item['self'] ? '' : $contact_url . '/block?t=' . $formSecurityToken;
+               $ignore_link = $item['self'] ? '' : $contact_url . '/ignore?t=' . $formSecurityToken;
        }
 
        if ($cid && !$item['self']) {
@@ -1068,11 +1077,14 @@ function format_activity(array $links, $verb, $id) {
 
 function status_editor(App $a, array $x = [], $notes_cid = 0, $popup = false)
 {
+       $user = User::getById($a->getLoggedInUserId(), ['uid', 'nickname', 'allow_location', 'default-location']);
+       if (empty($user['uid'])) {
+               return '';
+       }
+
        DI::profiler()->startRecording('rendering');
        $o = '';
 
-       $user = User::getById($a->getLoggedInUserId(), ['uid', 'nickname', 'allow_location', 'default-location']);
-
        $x['allow_location']   = $x['allow_location']   ?? $user['allow_location'];
        $x['default_location'] = $x['default_location'] ?? $user['default-location'];
        $x['nickname']         = $x['nickname']         ?? $user['nickname'];