]> git.mxchange.org Git - friendica.git/blobdiff - mod/item.php
Delete the attached HTML media on content updates
[friendica.git] / mod / item.php
index aa673969f6f344d749440a3f38b2b0cfb8670b33..3e4de2abafe329bc54e17744cc3b14be8b9d31f7 100644 (file)
@@ -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) {
@@ -107,6 +106,7 @@ 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\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'];
        }
@@ -237,14 +239,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);
@@ -280,7 +274,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()->create([$post], Conversation::MODE_SEARCH, false, true);
 
                System::jsonExit(['preview' => $o]);
        }