]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Fix posting/editing empty text image posts through Mastodon API
[friendica.git] / src / Model / Item.php
index 78275c8356f147350e9be19699e975841077d148..12184a3a55d69de9ea00861b971af5278754aecf 100644 (file)
@@ -201,6 +201,8 @@ class Item
                $notify_items = [];
 
                while ($item = DBA::fetch($items)) {
+                       Post\Media::deleteByURIId($item['uri-id'], [Post\Media::HTML]);
+
                        if (!empty($fields['body'])) {
                                if (!empty($item['quote-uri-id'])) {
                                        $fields['body'] = BBCode::removeSharedData($fields['body']);
@@ -587,7 +589,7 @@ class Item
        public static function isValid(array $item): bool
        {
                // When there is no content then we don't post it
-               if (($item['body'] . $item['title'] == '') && empty($item['quote-uri-id']) && (empty($item['uri-id']) || !Post\Media::existsByURIId($item['uri-id']))) {
+               if (($item['body'] . $item['title'] == '') && empty($item['quote-uri-id']) && empty($item['attachments']) && (empty($item['uri-id']) || !Post\Media::existsByURIId($item['uri-id']))) {
                        Logger::notice('No body, no title.');
                        return false;
                }