diff --git a/extensions/approval/extend.php b/extensions/approval/extend.php index 92cc6f878..cce1c7954 100644 --- a/extensions/approval/extend.php +++ b/extensions/approval/extend.php @@ -9,7 +9,9 @@ use Flarum\Approval\Access; use Flarum\Approval\Listener; +use Flarum\Discussion\Discussion; use Flarum\Extend; +use Flarum\Post\Post; use Illuminate\Contracts\Events\Dispatcher; return [ @@ -20,6 +22,14 @@ return [ (new Extend\Frontend('admin')) ->js(__DIR__.'/js/dist/admin.js'), + // Discussions should be approved by default + (new Extend\Model(Discussion::class)) + ->default('is_approved', true), + + // Posts should be approved by default + (new Extend\Model(Post::class)) + ->default('is_approved', true), + function (Dispatcher $events) { $events->subscribe(Listener\AddPostApprovalAttributes::class); $events->subscribe(Listener\ApproveContent::class); diff --git a/extensions/approval/src/Listener/UnapproveNewContent.php b/extensions/approval/src/Listener/UnapproveNewContent.php index 92b53cbbc..84cdf2180 100644 --- a/extensions/approval/src/Listener/UnapproveNewContent.php +++ b/extensions/approval/src/Listener/UnapproveNewContent.php @@ -10,7 +10,6 @@ namespace Flarum\Approval\Listener; use Flarum\Discussion\Discussion; -use Flarum\Event\ConfigureModelDefaultAttributes; use Flarum\Event\GetModelIsPrivate; use Flarum\Flags\Flag; use Flarum\Post\Event\Saving; @@ -24,21 +23,10 @@ class UnapproveNewContent */ public function subscribe(Dispatcher $events) { - $events->listen(ConfigureModelDefaultAttributes::class, [$this, 'approveByDefault']); $events->listen(Saving::class, [$this, 'unapproveNewPosts']); $events->listen(GetModelIsPrivate::class, [$this, 'markUnapprovedContentAsPrivate']); } - /** - * @param ConfigureModelDefaultAttributes $event - */ - public function approveByDefault(ConfigureModelDefaultAttributes $event) - { - if ($event->isModel(Post::class) || $event->isModel(Discussion::class)) { - $event->attributes['is_approved'] = true; - } - } - /** * @param Saving $event */