Prevent post mirroring by blocked users

This commit is contained in:
Hypolite Petovan 2023-07-26 07:50:15 +02:00
parent a905cdfd09
commit eff605b1f3
1 changed files with 17 additions and 12 deletions

View File

@ -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;
@ -2333,12 +2334,7 @@ class Item
return;
}
$cdata = Contact::getPublicAndUserContactID($item['author-id'], $item['uid']);
if (empty($cdata['user']) || ($cdata['user'] != $item['contact-id'])) {
return;
}
if (!DBA::exists('contact', ['id' => $cdata['user'], 'remote_self' => Contact::MIRROR_NATIVE_RESHARE])) {
if (!DBA::exists('contact', ['id' => $cdata['user'], 'remote_self' => LocalRelationship::MIRROR_NATIVE_RESHARE])) {
return;
}
@ -2346,6 +2342,10 @@ class Item
return;
}
if (User::getById($item['uid'], ['blocked'])['blocked'] ?? false) {
return;
}
Logger::info('Automatically reshare item', ['uid' => $item['uid'], 'id' => $item['id'], 'guid' => $item['guid'], 'uri-id' => $item['uri-id']]);
self::performActivity($item['id'], 'announce', $item['uid']);
@ -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]);
@ -3222,7 +3227,7 @@ class Item
$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);
@ -3628,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']
];
@ -3721,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'],
];