X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FItem.php;h=c7438d2593b57ec0f939f643bcc1c4e067590430;hb=ddd2c72be8e7245389f97d74dd847f5a20410936;hp=c25e5296f01e78504a0c5f4cfb28588b3fda3961;hpb=09a612670ad79960dba46b58d87780513e8e4c3f;p=friendica.git diff --git a/src/Content/Item.php b/src/Content/Item.php index c25e5296f0..c7438d2593 100644 --- a/src/Content/Item.php +++ b/src/Content/Item.php @@ -1,6 +1,6 @@ activity->match($item['verb'], Activity::TAG)) { $fields = [ - 'author-id', 'author-link', 'author-name', 'author-network', + 'author-id', 'author-link', 'author-name', 'author-network', 'author-link', 'author-alias', 'verb', 'object-type', 'resource-id', 'body', 'plink' ]; $obj = Post::selectFirst($fields, ['uri' => $item['parent-uri']]); @@ -367,7 +370,7 @@ class Item { $this->profiler->startRecording('rendering'); $sub_link = $contact_url = $pm_url = $status_link = ''; - $photos_link = $posts_link = $block_link = $ignore_link = ''; + $photos_link = $posts_link = $block_link = $ignore_link = $collapse_link = $ignoreserver_link = ''; if ($this->userSession->getLocalUserId() && $this->userSession->getLocalUserId() == $item['uid'] && $item['gravity'] == ItemModel::GRAVITY_PARENT && !$item['self'] && !$item['mention']) { $sub_link = 'javascript:doFollowThread(' . $item['id'] . '); return false;'; @@ -380,7 +383,7 @@ class Item 'url' => $item['author-link'], 'alias' => $item['author-alias'], ]; - $profile_link = Contact::magicLinkByContact($author, $item['author-link']); + $profile_link = Contact::magicLinkByContact($author, Contact::getProfileLink($author)); if (strpos($profile_link, 'contact/redir/') === 0) { $status_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/status']); $photos_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/photos']); @@ -407,6 +410,11 @@ class Item $collapse_link = $item['self'] ? '' : $contact_url . '/collapse?t=' . $formSecurityToken; } + $authorBaseUri = new Uri($item['author-baseurl'] ?? ''); + if (!empty($item['author-gsid']) && $authorBaseUri->getHost() && !DI::baseUrl()->isLocalUrl($authorBaseUri)) { + $ignoreserver_link = 'settings/server/' . $item['author-gsid'] . '/ignore'; + } + if ($cid && !$item['self']) { $contact_url = 'contact/' . $cid; $posts_link = $contact_url . '/posts'; @@ -427,7 +435,8 @@ class Item $this->l10n->t('Send PM') => $pm_url, $this->l10n->t('Block') => $block_link, $this->l10n->t('Ignore') => $ignore_link, - $this->l10n->t('Collapse') => $collapse_link + $this->l10n->t('Collapse') => $collapse_link, + $this->l10n->t("Ignore %s server", $authorBaseUri->getHost()) => $ignoreserver_link, ]; if (!empty($item['language'])) { @@ -627,10 +636,10 @@ class Item public function addSharedPost(array $item, string $body = ''): string { if (empty($body)) { - $body = $item['body']; + $body = $item['body'] ?? ''; } - if (empty($item['quote-uri-id'])) { + if (empty($item['quote-uri-id']) || ($item['quote-uri-id'] == $item['uri-id'])) { return $body; } @@ -721,7 +730,7 @@ class Item */ public function getSharedPost(array $item, array $fields = []): array { - if (!empty($item['quote-uri-id'])) { + if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) { $shared = Post::selectFirst($fields, ['uri-id' => $item['quote-uri-id'], 'uid' => [0, $item['uid'] ?? 0]]); if (is_array($shared)) { return [ @@ -762,7 +771,7 @@ class Item return $attributes; } - if (!empty($item['quote-uri-id'])) { + if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) { $shared = Post::selectFirst(['author-name', 'author-link', 'author-avatar', 'plink', 'created', 'guid', 'uri', 'body'], ['uri-id' => $item['quote-uri-id']]); if (!empty($shared)) { return [ @@ -983,12 +992,14 @@ class Item $post['deny_gid'] = $owner['deny_gid']; } - if ($post['allow_gid'] || $post['allow_cid'] || $post['deny_gid'] || $post['deny_cid']) { - $post['private'] = ItemModel::PRIVATE; - } elseif ($this->pConfig->get($post['uid'], 'system', 'unlisted')) { - $post['private'] = ItemModel::UNLISTED; - } else { - $post['private'] = ItemModel::PUBLIC; + if (!isset($post['private'])) { + if ($post['allow_gid'] || $post['allow_cid'] || $post['deny_gid'] || $post['deny_cid']) { + $post['private'] = ItemModel::PRIVATE; + } elseif ($this->pConfig->get($post['uid'], 'system', 'unlisted')) { + $post['private'] = ItemModel::UNLISTED; + } else { + $post['private'] = ItemModel::PUBLIC; + } } if (empty($post['contact-id'])) { @@ -1058,4 +1069,40 @@ class Item )); } } + + public function copyPermissions(int $fromUriId, int $toUriId, int $parentUriId) + { + $from = Post::selectFirstPost(['author-id'], ['uri-id' => $fromUriId]); + $from_author = DBA::selectFirst('account-view', ['ap-followers'], ['id' => $from['author-id']]); + $to = Post::selectFirstPost(['author-id'], ['uri-id' => $toUriId]); + $to_author = DBA::selectFirst('account-view', ['ap-followers'], ['id' => $to['author-id']]); + $parent = Post::selectFirstPost(['author-id'], ['uri-id' => $parentUriId]); + $parent_author = DBA::selectFirst('account-view', ['ap-followers'], ['id' => $parent['author-id']]); + + $followers = ''; + foreach (array_column(Tag::getByURIId($parentUriId, [Tag::TO, Tag::CC, Tag::BCC]), 'url') as $url) { + if ($url == $parent_author['ap-followers']) { + $followers = $url; + break; + } + } + + $existing = array_column(Tag::getByURIId($toUriId, [Tag::TO, Tag::CC, Tag::BCC]), 'url'); + + foreach (Tag::getByURIId($fromUriId, [Tag::TO, Tag::CC, Tag::BCC]) as $receiver) { + if ($receiver['url'] == $from_author['ap-followers']) { + if (!empty($followers)) { + $receiver['url'] = $followers; + $receiver['name'] = trim(parse_url($receiver['url'], PHP_URL_PATH), '/'); + Tag::store($toUriId, $receiver['type'], $receiver['name'], $receiver['url']); + } + $receiver['url'] = $to_author['ap-followers']; + $receiver['name'] = trim(parse_url($receiver['url'], PHP_URL_PATH), '/'); + } + if (in_array($receiver['url'], $existing)) { + continue; + } + Tag::store($toUriId, $receiver['type'], $receiver['name'], $receiver['url']); + } + } }