X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FItem.php;h=f923fe2691d84109e6ec20f0e918fed26a4d2da6;hb=6dbbd081795fa1c8fe57db2248ac162efeeada88;hp=923d72c11bcd37cf7955897553759bc9c93d2d45;hpb=edcfeaf66d797cc6bc9edf966b91b5eb95e5f127;p=friendica.git diff --git a/src/Model/Item.php b/src/Model/Item.php index 923d72c11b..f923fe2691 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1,6 +1,6 @@ startRecording('rendering'); - // @ToDo Check only for audio and video - $preview = empty($attachments['visual']); + // Don't show a preview when there is a visual attachment (audio or video) + $types = array_column($attachments['visual'], 'type'); + $preview = !in_array(Post\Media::IMAGE, $types) && !in_array(Post\Media::VIDEO, $types); if (!empty($attachments['link'])) { foreach ($attachments['link'] as $link) { @@ -3262,6 +3265,18 @@ class Item return $item_id; } + $hookData = [ + 'uri' => $uri, + 'uid' => $uid, + 'item_id' => null, + ]; + + Hook::callAll('item_by_link', $hookData); + + if (isset($hookData['item_id'])) { + return is_numeric($hookData['item_id']) ? $hookData['item_id'] : 0; + } + if ($fetched_uri = ActivityPub\Processor::fetchMissingActivity($uri)) { $item_id = self::searchByLink($fetched_uri, $uid); } else { @@ -3354,7 +3369,7 @@ class Item $body = $shared_item['body']; } - $item['body'] = preg_replace("/\[share ([^\[\]]*)\].*\[\/share\]/ism", '[share $1]' . $body . '[/share]', $item['body']); + $item['body'] = preg_replace("/\[share ([^\[\]]*)\].*\[\/share\]/ism", '[share $1]' . str_replace('$', '\$', $body) . '[/share]', $item['body']); unset($shared_item['body']); return array_merge($item, $shared_item);