[CORE] Add option to filter notes even when there's no actor

This commit is contained in:
Phablulo 2021-12-21 10:34:04 -03:00
parent ce91826d31
commit dd5d46c556
4 changed files with 7 additions and 6 deletions

View File

@ -29,14 +29,16 @@ use App\Entity\Note;
use App\Util\Formatting;
use App\Util\Functional as GSF;
use Doctrine\Common\Collections\ExpressionBuilder;
use Symfony\Component\HttpFoundation\Request;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder;
use Functional as F;
class Language extends Component
{
public function onFilterNoteList(Actor $actor, array &$notes)
public function onFilterNoteList(?Actor $actor, array &$notes, Request $request)
{
if (\is_null($actor)) return Event::next;
$notes = F\select(
$notes,
fn (Note $n) => \in_array($n->getLanguageId(), ActorLanguage::getActorRelatedLanguagesIds($actor)),

View File

@ -76,8 +76,9 @@ class TagBasedFiltering extends Plugin
];
}
public function onFilterNoteList(Actor $actor, array &$notes)
public function onFilterNoteList(?Actor $actor, array &$notes, Request $request)
{
if (\is_null($actor)) return Event::next;
$blocked_note_tags = Cache::get(
self::cacheKeys($actor)['note'],
fn () => DB::dql('select ntb from note_tag_block ntb where ntb.blocker = :blocker', ['blocker' => $actor->getId()]),

View File

@ -49,9 +49,7 @@ abstract class FeedController extends Controller
if (\array_key_exists('notes', $result)) {
$notes = $result['notes'];
if (!\is_null($actor)) {
Event::handle('FilterNoteList', [$actor, &$notes]);
}
Event::handle('FilterNoteList', [$actor, &$notes, $result['request']]);
if ($result['should_format'] ?? true) {
$notes_out = null;

View File

@ -9,7 +9,7 @@
{% endblock stylesheets %}
{% block body %}
{% for block in handle_event('BeforeFeed') %}
{% for block in handle_event('BeforeFeed', app.request) %}
{{ block | raw }}
{% endfor %}
{# Backwards compatibility with hAtom 0.1 #}