X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fitem.php;h=70c5c9a8b61f338d1d1d43fd75bfe2ac44b09a1e;hb=1ede164450f2651a2ea04dcb16af113459393663;hp=f43e78e6ba35fe32c89cda0e010fabbf50189e70;hpb=5fd3d4bda37b401429115503d65ac51fe5240146;p=friendica.git diff --git a/mod/item.php b/mod/item.php index f43e78e6ba..70c5c9a8b6 100644 --- a/mod/item.php +++ b/mod/item.php @@ -19,7 +19,7 @@ * * This is the POST destination for most all locally posted * text stuff. This function handles status, wall-to-wall status, - * local comments, and remote coments that are posted on this site + * local comments, and remote comments that are posted on this site * (as opposed to being delivered in a feed). * Also processed here are posts and comments coming through the * statusnet/twitter API. @@ -29,6 +29,7 @@ */ use Friendica\App; +use Friendica\Content\Conversation; use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; use Friendica\Core\Logger; @@ -40,10 +41,8 @@ use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; use Friendica\Model\ItemURI; -use Friendica\Model\Photo; use Friendica\Model\Post; use Friendica\Network\HTTPException; -use Friendica\Protocol\Activity; use Friendica\Util\DateTimeFormat; function item_post(App $a) { @@ -105,8 +104,9 @@ function item_edit(int $uid, array $request, bool $preview, string $return_path) } $post['edit'] = $post; - $post['file'] = Post\Category::getTextByURIId($post['uri-id'], $post['uid']); + $post['file'] = Post\Category::getTextByURIId($post['uri-id'], $post['uid']); + Post\Media::deleteByURIId($post['uri-id'], [Post\Media::AUDIO, Post\Media::VIDEO, Post\Media::IMAGE, Post\Media::HTML]); $post = item_process($post, $request, $preview, $return_path); $fields = [ @@ -180,11 +180,13 @@ function item_insert(int $uid, array $request, bool $preview, string $return_pat Logger::info('Public item stored for user', ['uri-id' => $toplevel_item['uri-id'], 'uid' => $post['uid'], 'stored' => $stored]); } + $post['parent'] = $toplevel_item['id']; $post['gravity'] = Item::GRAVITY_COMMENT; $post['thr-parent'] = $parent_item['uri']; $post['wall'] = $toplevel_item['wall']; } else { $parent_item = []; + $post['parent'] = 0; $post['gravity'] = Item::GRAVITY_PARENT; $post['thr-parent'] = $post['uri']; } @@ -219,6 +221,10 @@ function item_insert(int $uid, array $request, bool $preview, string $return_pat DI::contentItem()->postProcessPost($post, $recipients); + if (($post['private'] == Item::PRIVATE) && ($post['thr-parent-id'] != $post['uri-id'])) { + DI::contentItem()->copyPermissions($post['thr-parent-id'], $post['uri-id']); + } + Logger::debug('post_complete'); item_post_return(DI::baseUrl(), $return_path); @@ -237,14 +243,6 @@ function item_process(array $post, array $request, bool $preview, string $return $post = DI::contentItem()->addCategories($post, $request['category'] ?? ''); - if (!$preview) { - if (Photo::setPermissionFromBody($post['body'], $post['uid'], $post['contact-id'], $post['allow_cid'], $post['allow_gid'], $post['deny_cid'], $post['deny_gid'])) { - $post['object-type'] = Activity\ObjectType::IMAGE; - } - - $post = DI::contentItem()->moveAttachmentsFromBodyToAttach($post); - } - // Add the attachment to the body. if (!empty($request['has_attachment'])) { $post['body'] .= DI::contentItem()->storeAttachmentFromRequest($request); @@ -272,6 +270,7 @@ function item_process(array $post, array $request, bool $preview, string $return $post['uri-id'] = -1; $post['author-network'] = Protocol::DFRN; $post['author-updated'] = ''; + $post['author-alias'] = ''; $post['author-gsid'] = 0; $post['author-uri-id'] = ItemURI::getIdByURI($post['author-link']); $post['owner-updated'] = ''; @@ -280,7 +279,7 @@ function item_process(array $post, array $request, bool $preview, string $return $post['body'] = BBCode::removeSharedData(Item::setHashtags($post['body'])); $post['writable'] = true; - $o = DI::conversation()->create([$post], 'search', false, true); + $o = DI::conversation()->render([$post], Conversation::MODE_SEARCH, false, true); System::jsonExit(['preview' => $o]); } @@ -346,7 +345,7 @@ function item_content(App $a) $args = DI::args(); - if (!$args->has(3)) { + if (!$args->has(2)) { throw new HTTPException\BadRequestException(); } @@ -374,6 +373,38 @@ function item_content(App $a) Contact\User::setBlocked($item['author-id'], DI::userSession()->getLocalUserId(), true); + if (DI::mode()->isAjax()) { + // ajax return: [, 0 (no perm) | ] + System::jsonExit([intval($args->get(2)), DI::userSession()->getLocalUserId()]); + } else { + item_redirect_after_action($item, $args->get(3)); + } + break; + + case 'ignore': + $item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), ['guid', 'author-id', 'parent', 'gravity'], ['id' => $args->get(2)]); + if (empty($item['author-id'])) { + throw new HTTPException\NotFoundException('Item not found'); + } + + Contact\User::setIgnored($item['author-id'], DI::userSession()->getLocalUserId(), true); + + if (DI::mode()->isAjax()) { + // ajax return: [, 0 (no perm) | ] + System::jsonExit([intval($args->get(2)), DI::userSession()->getLocalUserId()]); + } else { + item_redirect_after_action($item, $args->get(3)); + } + break; + + case 'collapse': + $item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), ['guid', 'author-id', 'parent', 'gravity'], ['id' => $args->get(2)]); + if (empty($item['author-id'])) { + throw new HTTPException\NotFoundException('Item not found'); + } + + Contact\User::setCollapsed($item['author-id'], DI::userSession()->getLocalUserId(), true); + if (DI::mode()->isAjax()) { // ajax return: [, 0 (no perm) | ] System::jsonExit([intval($args->get(2)), DI::userSession()->getLocalUserId()]);