fix: not changing recipients visibility when recipients change

This commit is contained in:
Daniël Klabbers 2024-06-13 19:27:14 +02:00
parent a9dc8bfb16
commit d252a17586
2 changed files with 19 additions and 10 deletions

View File

@ -15,8 +15,7 @@ namespace Blomstra\Search\Seeders;
use Blomstra\Search\Save\Document; use Blomstra\Search\Save\Document;
use Flarum\Api\Serializer\PostSerializer; use Flarum\Api\Serializer\PostSerializer;
use Flarum\Post\CommentPost; use Flarum\Post\CommentPost;
use Flarum\Post\Event\Deleted; use Flarum\Post\Event as Core;
use Flarum\Post\Event\Posted;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
@ -49,14 +48,18 @@ class CommentSeeder extends Seeder
public static function savingOn(Dispatcher $events, callable $callable) public static function savingOn(Dispatcher $events, callable $callable)
{ {
$events->listen(Posted::class, function (Posted $event) use ($callable) { $events->listen([
Core\Posted::class,
], function ($event) use ($callable) {
$callable($event->post); $callable($event->post);
}); });
} }
public static function deletingOn(Dispatcher $events, callable $callable) public static function deletingOn(Dispatcher $events, callable $callable)
{ {
$events->listen(Deleted::class, function (Deleted $event) use ($callable) { $events->listen([
Core\Deleted::class
], function ($event) use ($callable) {
$callable($event->post); $callable($event->post);
}); });
} }

View File

@ -15,10 +15,8 @@ namespace Blomstra\Search\Seeders;
use Blomstra\Search\Save\Document; use Blomstra\Search\Save\Document;
use Flarum\Api\Serializer\DiscussionSerializer; use Flarum\Api\Serializer\DiscussionSerializer;
use Flarum\Discussion\Discussion; use Flarum\Discussion\Discussion;
use Flarum\Discussion\Event\Deleted; use Flarum\Discussion\Event as Core;
use Flarum\Discussion\Event\Hidden; use FoF\Byobu\Events as Byobu;
use Flarum\Discussion\Event\Restored;
use Flarum\Discussion\Event\Started;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
@ -50,14 +48,22 @@ class DiscussionSeeder extends Seeder
public static function savingOn(Dispatcher $events, callable $callable) public static function savingOn(Dispatcher $events, callable $callable)
{ {
$events->listen([Started::class, Restored::class], function ($event) use ($callable) { $events->listen([
// flarum/core events
Core\Started::class, Core\Restored::class,
// fof/byobu discussion recipients events.
Byobu\DiscussionMadePublic::class, Byobu\RemovedSelf::class, Byobu\RecipientsChanged::class,
], function ($event) use ($callable) {
return $callable($event->discussion); return $callable($event->discussion);
}); });
} }
public static function deletingOn(Dispatcher $events, callable $callable) public static function deletingOn(Dispatcher $events, callable $callable)
{ {
$events->listen([Deleted::class, Hidden::class], function ($event) use ($callable) { $events->listen([
// flarum/core events.
Core\Deleted::class, Core\Hidden::class
], function ($event) use ($callable) {
return $callable($event->discussion); return $callable($event->discussion);
}); });
} }