]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Post/Share.php
Changes:
[friendica.git] / src / Module / Post / Share.php
index df15dbbef99cbe9a821dd247d3624092583382c0..5ecf6508302c490b6c609f23b7176708bfa64027 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2024, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -24,6 +24,7 @@ namespace Friendica\Module\Post;
 use Friendica\App;
 use Friendica\Content;
 use Friendica\Core\L10n;
+use Friendica\Core\Protocol;
 use Friendica\Core\Session\Capability\IHandleUserSessions;
 use Friendica\Core\System;
 use Friendica\Model\Item;
@@ -47,7 +48,7 @@ class Share extends \Friendica\BaseModule
        public function __construct(Content\Item $contentItem, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
        {
                parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
-               
+
                $this->session     = $session;
                $this->contentItem = $contentItem;
        }
@@ -56,21 +57,23 @@ class Share extends \Friendica\BaseModule
        {
                $post_id = $this->parameters['post_id'];
                if (!$post_id || !$this->session->getLocalUserId()) {
-                       System::httpError(403);
+                       $this->httpError(403);
                }
 
-               $item = Post::selectFirst(['private', 'body', 'uri'], ['id' => $post_id]);
+               $item = Post::selectFirst(['private', 'body', 'uri', 'plink', 'network'], ['id' => $post_id]);
                if (!$item || $item['private'] == Item::PRIVATE) {
-                       System::httpError(404);
+                       $this->httpError(404);
                }
 
                $shared = $this->contentItem->getSharedPost($item, ['uri']);
                if ($shared && empty($shared['comment'])) {
                        $content = '[share]' . $shared['post']['uri'] . '[/share]';
+               } elseif (!empty($item['plink']) && !in_array($item['network'], Protocol::FEDERATED)) {
+                       $content = '[attachment]' . $item['plink'] . '[/attachment]';
                } else {
                        $content = '[share]' . $item['uri'] . '[/share]';
                }
 
-               System::httpExit($content);
+               $this->httpExit($content);
        }
 }