-- ------------------------------------------
-- Friendica 2022.05-rc (Siberian Iris)
--- DB_UPDATE_VERSION 1463
+-- DB_UPDATE_VERSION 1464
-- ------------------------------------------
`post-question`.`multiple` AS `question-multiple`,
`post-question`.`voters` AS `question-voters`,
`post-question`.`end-time` AS `question-end-time`,
+ EXISTS(SELECT `uri-id` FROM `post-category` WHERE `post-category`.`uri-id` = `post-user`.`uri-id` AND `post-category`.`uid` = `post-user`.`uid`) AS `has-categories`,
+ EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`) AS `has-media`,
`diaspora-interaction`.`interaction` AS `signed_text`,
`parent-item-uri`.`guid` AS `parent-guid`,
`parent-post`.`network` AS `parent-network`,
`post-question`.`multiple` AS `question-multiple`,
`post-question`.`voters` AS `question-voters`,
`post-question`.`end-time` AS `question-end-time`,
+ EXISTS(SELECT `uri-id` FROM `post-category` WHERE `post-category`.`uri-id` = `post-thread-user`.`uri-id` AND `post-category`.`uid` = `post-thread-user`.`uid`) AS `has-categories`,
+ EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`) AS `has-media`,
`diaspora-interaction`.`interaction` AS `signed_text`,
`parent-item-uri`.`guid` AS `parent-guid`,
`parent-post`.`network` AS `parent-network`,
`post-question`.`multiple` AS `question-multiple`,
`post-question`.`voters` AS `question-voters`,
`post-question`.`end-time` AS `question-end-time`,
+ 0 AS `has-categories`,
+ EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`) AS `has-media`,
`diaspora-interaction`.`interaction` AS `signed_text`,
`parent-item-uri`.`guid` AS `parent-guid`,
`parent-post`.`network` AS `parent-network`,
`post-question`.`multiple` AS `question-multiple`,
`post-question`.`voters` AS `question-voters`,
`post-question`.`end-time` AS `question-end-time`,
+ 0 AS `has-categories`,
+ EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`) AS `has-media`,
`diaspora-interaction`.`interaction` AS `signed_text`,
`parent-item-uri`.`guid` AS `parent-guid`,
`parent-post`.`network` AS `parent-network`,
$uid = $item['uid'] ?: $uid;
- if (!Post\Category::existsForURIId($item['uri-id'], $uid)) {
+ if (empty($item['has-categories'])) {
return [$categories, $folders];
}
'event-summary', 'event-desc', 'event-location', 'event-type',
'event-nofinish', 'event-ignore', 'event-id',
"question-id", "question-multiple", "question-voters", "question-end-time",
+ "has-categories", "has-media",
'delivery_queue_count', 'delivery_queue_done', 'delivery_queue_failed'
];
$shared_item = Post::selectFirst(['uri-id', 'plink'], ['guid' => $shared['guid']]);
$shared_uri_id = $shared_item['uri-id'] ?? 0;
$shared_links = [strtolower($shared_item['plink'] ?? '')];
- $shared_attachments = Post\Media::splitAttachments($shared_uri_id, $shared['guid']);
+ $shared_attachments = Post\Media::splitAttachments($shared_uri_id, $shared['guid'], [], $item['has-media']);
$shared_links = array_merge($shared_links, array_column($shared_attachments['visual'], 'url'));
$shared_links = array_merge($shared_links, array_column($shared_attachments['link'], 'url'));
$shared_links = array_merge($shared_links, array_column($shared_attachments['additional'], 'url'));
$shared_uri_id = 0;
$shared_links = [];
}
- $attachments = Post\Media::splitAttachments($item['uri-id'], $item['guid'] ?? '', $shared_links);
+ $attachments = Post\Media::splitAttachments($item['uri-id'], $item['guid'] ?? '', $shared_links, $item['has-media']);
$item['body'] = self::replaceVisualAttachments($attachments, $item['body'] ?? '');
$item['body'] = preg_replace("/\s*\[attachment .*?\].*?\[\/attachment\]\s*/ism", "\n", $item['body']);
* @param int $uri_id
* @param string $guid
* @param array $links list of links that shouldn't be added
+ * @param bool $has_media
* @return array attachments
*/
- public static function splitAttachments(int $uri_id, string $guid = '', array $links = [])
+ public static function splitAttachments(int $uri_id, string $guid = '', array $links = [], bool $has_media = true)
{
$attachments = ['visual' => [], 'link' => [], 'additional' => []];
+ if (!$has_media) {
+ return $attachments;
+ }
+
$media = self::getByURIId($uri_id);
if (empty($media)) {
return $attachments;
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
- define('DB_UPDATE_VERSION', 1463);
+ define('DB_UPDATE_VERSION', 1464);
}
return [
"question-multiple" => ["post-question", "multiple"],
"question-voters" => ["post-question", "voters"],
"question-end-time" => ["post-question", "end-time"],
+ "has-categories" => "EXISTS(SELECT `uri-id` FROM `post-category` WHERE `post-category`.`uri-id` = `post-user`.`uri-id` AND `post-category`.`uid` = `post-user`.`uid`)",
+ "has-media" => "EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-user`.`uri-id`)",
"signed_text" => ["diaspora-interaction", "interaction"],
"parent-guid" => ["parent-item-uri", "guid"],
"parent-network" => ["parent-post", "network"],
"question-multiple" => ["post-question", "multiple"],
"question-voters" => ["post-question", "voters"],
"question-end-time" => ["post-question", "end-time"],
+ "has-categories" => "EXISTS(SELECT `uri-id` FROM `post-category` WHERE `post-category`.`uri-id` = `post-thread-user`.`uri-id` AND `post-category`.`uid` = `post-thread-user`.`uid`)",
+ "has-media" => "EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-user`.`uri-id`)",
"signed_text" => ["diaspora-interaction", "interaction"],
"parent-guid" => ["parent-item-uri", "guid"],
"parent-network" => ["parent-post", "network"],
"question-multiple" => ["post-question", "multiple"],
"question-voters" => ["post-question", "voters"],
"question-end-time" => ["post-question", "end-time"],
+ "has-categories" => "0",
+ "has-media" => "EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post`.`uri-id`)",
"signed_text" => ["diaspora-interaction", "interaction"],
"parent-guid" => ["parent-item-uri", "guid"],
"parent-network" => ["parent-post", "network"],
"question-multiple" => ["post-question", "multiple"],
"question-voters" => ["post-question", "voters"],
"question-end-time" => ["post-question", "end-time"],
+ "has-categories" => "0",
+ "has-media" => "EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread`.`uri-id`)",
"signed_text" => ["diaspora-interaction", "interaction"],
"parent-guid" => ["parent-item-uri", "guid"],
"parent-network" => ["parent-post", "network"],