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

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]);