Hi, I've been working on trying to get the ignore extension to actually behave as it should and ignore a user is really just that, not see anything from that ignored user.
My approach has been based on adding an extender to the main Flarum file, but my knowledge of Falrum is still limited.
I don't know if datitisev @luceos and @IanM what were involved in the development of the extension could give me any clues.
<?php
use Flarum\Extend;
use Flarum\Discussion\Filter\DiscussionFilterer;
use Flarum\User\User;
use Flarum\Discussion\Discussion;
return [
// Tu código de bloqueo de discusión existente...
// Relación de usuarios ignorados
(new Extend\Model(User::class))
->relationship('ignoredUsers', function ($model) {
return $model->belongsToMany(User::class, 'ignored_user', 'user_id', 'ignored_user_id')
->withPivot('ignored_at');
}),
// Modificar la consulta de discusiones
(new Extend\Event)
->listen(\Flarum\Api\Event\WillGetData::class, function ($event) {
// Verificar si es un controlador de lista de discusiones
if ($event->controller instanceof \Flarum\Api\Controller\ListDiscussionsController) {
$actor = $event->actor;
if ($actor && $actor->ignoredUsers && $actor->ignoredUsers->isNotEmpty()) {
$event->query->whereNotIn('discussions.user_id', $actor->ignoredUsers->pluck('id'));
}
}
}),
];
Of course, my approach is not working and I keep seeing the ignored user's discussions in the main discussions feed.