js(__DIR__.'/js/dist/admin.js'), (new Extend\Frontend('forum')) ->js(__DIR__.'/js/dist/forum.js') ->css(__DIR__.'/less/forum.less') ->route('/following', 'following'), new Extend\Locales(__DIR__.'/locale'), (new Extend\Model(User::class)) ->cast('last_read_post_number', 'integer'), (new Extend\Model(UserState::class)) ->cast('subscription', 'string'), (new Extend\View) ->namespace('flarum-subscriptions', __DIR__.'/views'), (new Extend\Notification()) ->type(NewPostBlueprint::class, BasicDiscussionSerializer::class, ['alert', 'email']) ->beforeSending(FilterVisiblePostsBeforeSending::class), (new Extend\ApiSerializer(DiscussionSerializer::class)) ->attribute('subscription', function (DiscussionSerializer $serializer, Discussion $discussion) { if ($state = $discussion->state) { return $state->subscription; } }), (new Extend\User()) ->registerPreference('followAfterReply', 'boolval', false), (new Extend\Event()) ->listen(Saving::class, Listener\SaveSubscriptionToDatabase::class) ->listen(Posted::class, Listener\SendNotificationWhenReplyIsPosted::class) ->listen(PostWasApproved::class, Listener\SendNotificationWhenReplyIsPosted::class) ->listen(Hidden::class, Listener\DeleteNotificationWhenPostIsHiddenOrDeleted::class) ->listen(Restored::class, Listener\RestoreNotificationWhenPostIsRestored::class) ->listen(Deleted::class, Listener\DeleteNotificationWhenPostIsHiddenOrDeleted::class) ->listen(Posted::class, Listener\FollowAfterReply::class), (new Extend\SearchDriver(DatabaseSearchDriver::class)) ->addFilter(DiscussionSearcher::class, SubscriptionFilter::class) ->addMutator(DiscussionSearcher::class, HideIgnoredFromAllDiscussionsPage::class), (new Extend\User()) ->registerPreference('flarum-subscriptions.notify_for_all_posts', 'boolval', false), ];