X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FItem.php;h=e74ca846dadf4889ca9f232276fdac9071e1a9c2;hb=eafe54f2ddf58a38a1a8a73761d7c394cbfdea1f;hp=a60b12663de03a4fa11a2b90c73f6813d0366274;hpb=5fd3d4bda37b401429115503d65ac51fe5240146;p=friendica.git diff --git a/src/Content/Item.php b/src/Content/Item.php index a60b12663d..e74ca846da 100644 --- a/src/Content/Item.php +++ b/src/Content/Item.php @@ -398,10 +398,11 @@ class Item } if (!empty($pcid)) { - $contact_url = 'contact/' . $pcid; - $posts_link = $contact_url . '/posts'; - $block_link = $item['self'] ? '' : $contact_url . '/block?t=' . $formSecurityToken; - $ignore_link = $item['self'] ? '' : $contact_url . '/ignore?t=' . $formSecurityToken; + $contact_url = 'contact/' . $pcid; + $posts_link = $contact_url . '/posts'; + $block_link = $item['self'] ? '' : $contact_url . '/block?t=' . $formSecurityToken; + $ignore_link = $item['self'] ? '' : $contact_url . '/ignore?t=' . $formSecurityToken; + $collapse_link = $item['self'] ? '' : $contact_url . '/collapse?t=' . $formSecurityToken; } if ($cid && !$item['self']) { @@ -423,7 +424,8 @@ class Item $this->l10n->t('View Contact') => $contact_url, $this->l10n->t('Send PM') => $pm_url, $this->l10n->t('Block') => $block_link, - $this->l10n->t('Ignore') => $ignore_link + $this->l10n->t('Ignore') => $ignore_link, + $this->l10n->t('Collapse') => $collapse_link ]; if (!empty($item['language'])) { @@ -857,7 +859,7 @@ class Item $user = User::getById($post['uid'], ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']); if (!$user) { - throw new HTTPException\NotFoundException($this->l10n->t('Unable to locate original post.')); + throw new HTTPException\NotFoundException($this->l10n->t('Unable to fetch user.')); } $post['allow_cid'] = isset($request['contact_allow']) ? $this->aclFormatter->toString($request['contact_allow']) : $user['allow_cid'] ?? ''; @@ -901,7 +903,7 @@ class Item if ($post['attach']) { $post['attach'] .= ','; } - $post['attach'] .= Post\Media::getAttachElement($this->baseURL->get() . '/attach/' . $attachment['id'], + $post['attach'] .= Post\Media::getAttachElement($this->baseURL . '/attach/' . $attachment['id'], $attachment['filesize'], $attachment['filetype'], $attachment['filename'] ?? ''); $fields = ['allow_cid' => $post['allow_cid'], 'allow_gid' => $post['allow_gid'], @@ -923,7 +925,7 @@ class Item // embedded bookmark or attachment in post? set bookmark flag $data = BBCode::getAttachmentData($post['body']); - if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $post['body'], $match, PREG_SET_ORDER) || isset($data['type'])) + if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $post['body'], $match, PREG_SET_ORDER) || !empty($data['type'])) && ($post['post-type'] != ItemModel::PT_PERSONAL_NOTE)) { $post['post-type'] = ItemModel::PT_PAGE; $post['object-type'] = Activity\ObjectType::BOOKMARK; @@ -932,33 +934,44 @@ class Item // Setting the object type if not defined before if (empty($post['object-type'])) { $post['object-type'] = ($post['gravity'] == ItemModel::GRAVITY_PARENT) ? Activity\ObjectType::NOTE : Activity\ObjectType::COMMENT; - - $objectdata = BBCode::getAttachedData($post['body']); - - if ($objectdata['type'] == 'link') { - $post['object-type'] = Activity\ObjectType::BOOKMARK; - } elseif ($objectdata['type'] == 'video') { - $post['object-type'] = Activity\ObjectType::VIDEO; - } elseif ($objectdata['type'] == 'photo') { - $post['object-type'] = Activity\ObjectType::IMAGE; - } } return $post; } public function initializePost(array $post): array { - $post['network'] = Protocol::DFRN; - $post['protocol'] = Conversation::PARCEL_DIRECT; - $post['direction'] = Conversation::PUSH; - $post['received'] = DateTimeFormat::utcNow(); - $post['origin'] = true; - $post['wall'] = $post['wall'] ?? true; - $post['guid'] = $post['guid'] ?? System::createUUID(); - $post['uri'] = $post['uri'] ?? ItemModel::newURI($post['guid']); - $post['verb'] = $post['verb'] ?? Activity::POST; + $post['network'] = Protocol::DFRN; + $post['protocol'] = Conversation::PARCEL_DIRECT; + $post['direction'] = Conversation::PUSH; + $post['received'] = DateTimeFormat::utcNow(); + $post['origin'] = true; + $post['wall'] = $post['wall'] ?? true; + $post['guid'] = $post['guid'] ?? System::createUUID(); + $post['verb'] = $post['verb'] ?? Activity::POST; + $post['uri'] = $post['uri'] ?? ItemModel::newURI($post['guid']); + $post['thr-parent'] = $post['thr-parent'] ?? $post['uri']; + + if (empty($post['gravity'])) { + $post['gravity'] = ($post['uri'] == $post['thr-parent']) ? ItemModel::GRAVITY_PARENT : ItemModel::GRAVITY_COMMENT; + } + $owner = User::getOwnerDataById($post['uid']); + if (!isset($post['allow_cid']) || !isset($post['allow_gid']) || !isset($post['deny_cid']) || !isset($post['deny_gid'])) { + $post['allow_cid'] = $owner['allow_cid']; + $post['allow_gid'] = $owner['allow_gid']; + $post['deny_cid'] = $owner['deny_cid']; + $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 (empty($post['contact-id'])) { $post['contact-id'] = $owner['id']; } @@ -989,7 +1002,6 @@ class Item // Convert links with empty descriptions to links without an explicit description $post['body'] = trim(preg_replace('#\[url=([^\]]*?)\]\[/url\]#ism', '[url]$1[/url]', $post['body'])); $post['body'] = $this->bbCodeVideo->transform($post['body']); - $post['body'] = BBCode::scaleExternalImages($post['body']); $post = $this->setObjectType($post); // Personal notes must never be altered to a forum post.