Don't accept ignored author via relay

This commit is contained in:
Michael 2020-10-02 03:35:22 +00:00
parent 9cd9ad647d
commit 9b1918c650
4 changed files with 19 additions and 4 deletions

View file

@ -806,6 +806,9 @@ class Processor
return true;
}
$attributed_to = JsonLD::fetchElement($activity['as:object'], 'as:attributedTo', '@id');
$authorid = Contact::getIdForURL($attributed_to);
$body = HTML::toBBCode(JsonLD::fetchElement($activity['as:object'], 'as:content', '@value'));
$messageTags = [];
@ -819,7 +822,7 @@ class Processor
}
}
return Relay::isSolicitedPost($messageTags, $body, $id, Protocol::ACTIVITYPUB);
return Relay::isSolicitedPost($messageTags, $body, $authorid, $id, Protocol::ACTIVITYPUB);
}
/**

View file

@ -2277,7 +2277,7 @@ class DFRN
$taglist = Tag::getByURIId($item['uri-id'], [Tag::HASHTAG]);
$tags = array_column($taglist, 'name');
return Relay::isSolicitedPost($tags, $item['body'], $item['uri'], Protocol::DFRN);
return Relay::isSolicitedPost($tags, $item['body'], $item['author-id'], $item['uri'], Protocol::DFRN);
}
/**

View file

@ -2807,7 +2807,7 @@ class Diaspora
$taglist = Tag::getByURIId($uriid, [Tag::HASHTAG]);
$tags = array_column($taglist, 'name');
return Relay::isSolicitedPost($tags, $body, $url, Protocol::DIASPORA);
return Relay::isSolicitedPost($tags, $body, $contact['id'], $url, Protocol::DIASPORA);
}
/**

View file

@ -24,6 +24,7 @@ namespace Friendica\Protocol;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Logger;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Search;
/**
@ -36,10 +37,11 @@ class Relay
*
* @param array $tags
* @param string $body
* @param int $authorid
* @param string $url
* @return boolean "true" is the post is wanted by the system
*/
public static function isSolicitedPost(array $tags, string $body, string $url, string $network = '')
public static function isSolicitedPost(array $tags, string $body, int $authorid, string $url, string $network = '')
{
$config = DI::config();
@ -55,6 +57,16 @@ class Relay
return false;
}
if (Contact::isBlocked($authorid)) {
Logger::info('Author is blocked - rejected', ['author' => $authorid, 'network' => $network, 'url' => $url]);
return false;
}
if (Contact::isHidden($authorid)) {
Logger::info('Author is hidden - rejected', ['author' => $authorid, 'network' => $network, 'url' => $url]);
return false;
}
$systemTags = [];
$userTags = [];
$denyTags = [];