2015-06-26 12:24:07 +09:30
|
|
|
<?php
|
|
|
|
|
2015-09-04 12:30:01 +09:30
|
|
|
/*
|
|
|
|
* This file is part of Flarum.
|
|
|
|
*
|
2019-11-29 23:02:31 +00:00
|
|
|
* For detailed copyright and license information, please view the
|
|
|
|
* LICENSE file that was distributed with this source code.
|
2015-09-04 12:30:01 +09:30
|
|
|
*/
|
|
|
|
|
2018-12-16 15:00:02 +01:00
|
|
|
use Flarum\Api\Event\Serializing;
|
|
|
|
use Flarum\Api\Serializer\BasicDiscussionSerializer;
|
|
|
|
use Flarum\Discussion\Event\Saving;
|
|
|
|
use Flarum\Discussion\Event\Searching;
|
|
|
|
use Flarum\Event\ConfigureDiscussionGambits;
|
|
|
|
use Flarum\Event\ConfigureNotificationTypes;
|
|
|
|
use Flarum\Event\ConfigureUserPreferences;
|
2018-01-16 23:21:48 +01:00
|
|
|
use Flarum\Extend;
|
2018-12-16 15:00:02 +01:00
|
|
|
use Flarum\Post\Event\Deleted;
|
|
|
|
use Flarum\Post\Event\Hidden;
|
|
|
|
use Flarum\Post\Event\Posted;
|
|
|
|
use Flarum\Post\Event\Restored;
|
|
|
|
use Flarum\Subscriptions\Gambit\SubscriptionGambit;
|
2015-10-11 17:30:11 +10:30
|
|
|
use Flarum\Subscriptions\Listener;
|
2018-12-16 15:00:02 +01:00
|
|
|
use Flarum\Subscriptions\Notification\NewPostBlueprint;
|
2015-10-11 17:30:11 +10:30
|
|
|
use Illuminate\Contracts\Events\Dispatcher;
|
|
|
|
use Illuminate\Contracts\View\Factory;
|
2015-06-26 12:24:07 +09:30
|
|
|
|
2018-01-16 23:21:48 +01:00
|
|
|
return [
|
2018-07-23 16:31:08 +02:00
|
|
|
(new Extend\Frontend('forum'))
|
2018-06-20 13:36:12 +09:30
|
|
|
->js(__DIR__.'/js/dist/forum.js')
|
2018-07-23 16:31:08 +02:00
|
|
|
->css(__DIR__.'/less/forum.less')
|
2018-07-23 14:33:49 +00:00
|
|
|
->route('/following', 'following'),
|
2018-06-20 13:36:12 +09:30
|
|
|
|
2020-06-19 22:22:54 -04:00
|
|
|
new Extend\Locales(__DIR__.'/locale'),
|
|
|
|
|
2020-07-17 12:11:25 +02:00
|
|
|
(new Extend\View)
|
|
|
|
->namespace('flarum-subscriptions', __DIR__.'/views'),
|
|
|
|
|
2018-01-16 23:21:48 +01:00
|
|
|
function (Dispatcher $events, Factory $views) {
|
2018-12-16 15:00:02 +01:00
|
|
|
$events->listen(Serializing::class, Listener\AddDiscussionSubscriptionAttribute::class);
|
|
|
|
$events->listen(Saving::class, Listener\SaveSubscriptionToDatabase::class);
|
|
|
|
|
|
|
|
$events->listen(ConfigureDiscussionGambits::class, function (ConfigureDiscussionGambits $event) {
|
|
|
|
$event->gambits->add(SubscriptionGambit::class);
|
|
|
|
});
|
|
|
|
$events->listen(Searching::class, Listener\FilterDiscussionListBySubscription::class);
|
|
|
|
|
|
|
|
$events->listen(ConfigureNotificationTypes::class, function (ConfigureNotificationTypes $event) {
|
|
|
|
$event->add(NewPostBlueprint::class, BasicDiscussionSerializer::class, ['alert', 'email']);
|
|
|
|
});
|
|
|
|
$events->listen(Posted::class, Listener\SendNotificationWhenReplyIsPosted::class);
|
|
|
|
$events->listen(Hidden::class, Listener\DeleteNotificationWhenPostIsHiddenOrDeleted::class);
|
|
|
|
$events->listen(Restored::class, Listener\RestoreNotificationWhenPostIsRestored::class);
|
|
|
|
$events->listen(Deleted::class, Listener\DeleteNotificationWhenPostIsHiddenOrDeleted::class);
|
|
|
|
|
|
|
|
$events->listen(ConfigureUserPreferences::class, function (ConfigureUserPreferences $event) {
|
|
|
|
$event->add('followAfterReply', 'boolval', false);
|
|
|
|
});
|
|
|
|
$events->listen(Posted::class, Listener\FollowAfterReply::class);
|
2018-01-16 23:21:48 +01:00
|
|
|
}
|
|
|
|
];
|