X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FItem.php;h=f2fd0bf6e699f65e0187b1040f0b419cf22ef680;hb=f2c1ecd19bb344137a91faab58d9a2524e0c8893;hp=e31009753b8933c3fb98e6fd66a02dbe7748b6ac;hpb=0da2391c4911ceb423a83bccfdbf3fff2a076a5c;p=friendica.git diff --git a/src/Model/Item.php b/src/Model/Item.php index e31009753b..f2fd0bf6e6 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -21,6 +21,7 @@ namespace Friendica\Model; +use Friendica\Contact\LocalRelationship\Entity\LocalRelationship; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Hook; @@ -94,9 +95,9 @@ class Item 'wall', 'private', 'starred', 'origin', 'parent-origin', 'title', 'body', 'language', 'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object', 'quote-uri', 'quote-uri-id', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'mention', 'global', - 'author-id', 'author-link', 'author-alias', 'author-name', 'author-avatar', 'author-network', 'author-updated', 'author-gsid', 'author-addr', 'author-uri-id', - 'owner-id', 'owner-link', 'owner-alias', 'owner-name', 'owner-avatar', 'owner-network', 'owner-contact-type', 'owner-updated', - 'causer-id', 'causer-link', 'causer-alias', 'causer-name', 'causer-avatar', 'causer-contact-type', 'causer-network', + 'author-id', 'author-link', 'author-alias', 'author-name', 'author-avatar', 'author-network', 'author-updated', 'author-gsid', 'author-baseurl', 'author-addr', 'author-uri-id', + 'owner-id', 'owner-link', 'owner-alias', 'owner-name', 'owner-avatar', 'owner-network', 'owner-contact-type', 'owner-updated', 'owner-gsid', + 'causer-id', 'causer-link', 'causer-alias', 'causer-name', 'causer-avatar', 'causer-contact-type', 'causer-network', 'causer-gsid', 'contact-id', 'contact-uid', 'contact-link', 'contact-name', 'contact-avatar', 'writable', 'self', 'cid', 'alias', 'event-created', 'event-edited', 'event-start', 'event-finish', @@ -2333,16 +2334,15 @@ class Item return; } - $cdata = Contact::getPublicAndUserContactID($item['author-id'], $item['uid']); - if (empty($cdata['user']) || ($cdata['user'] != $item['contact-id'])) { + if (!DBA::exists('contact', ['id' => $cdata['user'], 'remote_self' => LocalRelationship::MIRROR_NATIVE_RESHARE])) { return; } - if (!DBA::exists('contact', ['id' => $cdata['user'], 'remote_self' => Contact::MIRROR_NATIVE_RESHARE])) { + if (!in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN])) { return; } - if (!in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN])) { + if (User::getById($item['uid'], ['blocked'])['blocked'] ?? false) { return; } @@ -2353,7 +2353,7 @@ class Item public static function isRemoteSelf(array $contact, array &$datarray): bool { - if ($contact['remote_self'] != Contact::MIRROR_OWN_POST) { + if ($contact['remote_self'] != LocalRelationship::MIRROR_OWN_POST) { return false; } @@ -2380,6 +2380,11 @@ class Item return false; } + if (User::getById($contact['uid'], ['blocked'])['blocked'] ?? false) { + Logger::info('User is blocked', ['contact' => $contact]); + return false; + } + $datarray2 = $datarray; Logger::info('remote-self start', ['contact' => $contact['url'], 'remote_self' => $contact['remote_self'], 'item' => $datarray]); @@ -3138,7 +3143,7 @@ class Item if (!empty($quote_uri_id)) { if (isset($shared_item['plink'])) { - $item['body'] .= "\n" . DI::contentItem()->createSharedBlockByArray($shared_item); + $item['body'] .= "\n" . DI::contentItem()->createSharedBlockByArray($shared_item, false, true); } else { DI::logger()->warning('Missing plink in shared item', ['item' => $item, 'shared' => $shared, 'quote_uri_id' => $quote_uri_id, 'shared_item' => $shared_item]); } @@ -3217,6 +3222,12 @@ class Item $body = BBCode::removeSharedData($body); } + $pos = strpos($s, BBCode::SHARED_ANCHOR); + if ($pos) { + $shared_html = substr($s, $pos + strlen(BBCode::SHARED_ANCHOR)); + $s = substr($s, 0, $pos); + } + $s = self::addGallery($s, $attachments, $item['uri-id']); $s = self::addVisualAttachments($attachments, $item, $s, false); $s = self::addLinkAttachment($item['uri-id'], $attachments, $body, $s, false, $shared_links); @@ -3237,6 +3248,10 @@ class Item $s = preg_replace('|(]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|', "$1-" . $ps, $s); } + if (!empty($shared_html)) { + $s .= $shared_html; + } + $s = HTML::applyContentFilter($s, $filter_reasons); $hook_data = ['item' => $item, 'html' => $s]; @@ -3618,9 +3633,9 @@ class Item } $author = [ - 'uid' => 0, + 'uid' => 0, 'id' => $item['author-id'], - 'network' => $item['author-network'], + 'network' => $item['author-network'], 'url' => $item['author-link'], 'alias' => $item['author-alias'] ]; @@ -3711,9 +3726,9 @@ class Item if (!empty($plink) && ($item['private'] == self::PRIVATE)) { $author = [ - 'uid' => 0, + 'uid' => 0, 'id' => $item['author-id'], - 'network' => $item['author-network'], + 'network' => $item['author-network'], 'url' => $item['author-link'], 'alias' => $item['author-alias'], ];