mirror of
https://github.com/flarum/framework.git
synced 2025-02-01 12:26:15 +08:00
parent
c134843633
commit
e2c97286e1
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Flarum\Subscriptions\Listener;
|
||||
|
||||
use Flarum\Event\ConfigureWebApp;
|
||||
use Flarum\Frontend\Event\Rendering;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class AddClientAssets
|
||||
|
@ -21,13 +21,13 @@ class AddClientAssets
|
|||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(ConfigureWebApp::class, [$this, 'addAssets']);
|
||||
$events->listen(Rendering::class, [$this, 'addAssets']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConfigureClientView $event
|
||||
* @param Rendering $event
|
||||
*/
|
||||
public function addAssets(ConfigureWebApp $event)
|
||||
public function addAssets(Rendering $event)
|
||||
{
|
||||
if ($event->isForum()) {
|
||||
$event->addAssets([
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Flarum\Subscriptions\Listener;
|
||||
|
||||
use Flarum\Api\Event\Serializing;
|
||||
use Flarum\Api\Serializer\DiscussionSerializer;
|
||||
use Flarum\Event\PrepareApiAttributes;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class AddDiscussionSubscriptionAttribute
|
||||
|
@ -22,13 +22,13 @@ class AddDiscussionSubscriptionAttribute
|
|||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(PrepareApiAttributes::class, [$this, 'addAttributes']);
|
||||
$events->listen(Serializing::class, [$this, 'addAttributes']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PrepareApiAttributes $event
|
||||
* @param Serializing $event
|
||||
*/
|
||||
public function addAttributes(PrepareApiAttributes $event)
|
||||
public function addAttributes(Serializing $event)
|
||||
{
|
||||
if ($event->isSerializer(DiscussionSerializer::class)
|
||||
&& ($state = $event->model->state)) {
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Flarum\Subscriptions\Listener;
|
||||
|
||||
use Flarum\Discussion\Event\Searching;
|
||||
use Flarum\Event\ConfigureDiscussionGambits;
|
||||
use Flarum\Event\ConfigureDiscussionSearch;
|
||||
use Flarum\Event\ConfigureForumRoutes;
|
||||
use Flarum\Subscriptions\Gambit\SubscriptionGambit;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
@ -26,7 +26,7 @@ class FilterDiscussionListBySubscription
|
|||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(ConfigureDiscussionGambits::class, [$this, 'addGambit']);
|
||||
$events->listen(ConfigureDiscussionSearch::class, [$this, 'filterIgnored']);
|
||||
$events->listen(Searching::class, [$this, 'filterIgnored']);
|
||||
$events->listen(ConfigureForumRoutes::class, [$this, 'addRoutes']);
|
||||
}
|
||||
|
||||
|
@ -39,9 +39,9 @@ class FilterDiscussionListBySubscription
|
|||
}
|
||||
|
||||
/**
|
||||
* @param ConfigureDiscussionSearch $event
|
||||
* @param Searching $event
|
||||
*/
|
||||
public function filterIgnored(ConfigureDiscussionSearch $event)
|
||||
public function filterIgnored(Searching $event)
|
||||
{
|
||||
if (! $event->criteria->query) {
|
||||
// might be better as `id IN (subquery)`?
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Flarum\Subscriptions\Listener;
|
||||
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Event\ConfigureUserPreferences;
|
||||
use Flarum\Event\PostWasPosted;
|
||||
use Flarum\Post\Event\Posted;
|
||||
use Flarum\User\AssertPermissionTrait;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class FollowAfterReply
|
||||
|
@ -26,7 +26,7 @@ class FollowAfterReply
|
|||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(ConfigureUserPreferences::class, [$this, 'addUserPreference']);
|
||||
$events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted']);
|
||||
$events->listen(Posted::class, [$this, 'whenPosted']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,9 +38,9 @@ class FollowAfterReply
|
|||
}
|
||||
|
||||
/**
|
||||
* @param PostWasPosted $event
|
||||
* @param Posted $event
|
||||
*/
|
||||
public function whenPostWasPosted(PostWasPosted $event)
|
||||
public function whenPosted(Posted $event)
|
||||
{
|
||||
$actor = $event->actor;
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Flarum\Subscriptions\Listener;
|
||||
|
||||
use Flarum\Core\Access\AssertPermissionTrait;
|
||||
use Flarum\Event\DiscussionWillBeSaved;
|
||||
use Flarum\Discussion\Event\Saving;
|
||||
use Flarum\User\AssertPermissionTrait;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class SaveSubscriptionToDatabase
|
||||
|
@ -24,13 +24,13 @@ class SaveSubscriptionToDatabase
|
|||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(DiscussionWillBeSaved::class, [$this, 'whenDiscussionWillBeSaved']);
|
||||
$events->listen(Saving::class, [$this, 'whenSaving']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DiscussionWillBeSaved $event
|
||||
* @param Saving $event
|
||||
*/
|
||||
public function whenDiscussionWillBeSaved(DiscussionWillBeSaved $event)
|
||||
public function whenSaving(Saving $event)
|
||||
{
|
||||
$discussion = $event->discussion;
|
||||
$data = $event->data;
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
|
||||
namespace Flarum\Subscriptions\Listener;
|
||||
|
||||
use Flarum\Api\Serializer\DiscussionBasicSerializer;
|
||||
use Flarum\Api\Serializer\BasicDiscussionSerializer;
|
||||
use Flarum\Core\Notification\NotificationSyncer;
|
||||
use Flarum\Core\Post;
|
||||
use Flarum\Event\ConfigureNotificationTypes;
|
||||
use Flarum\Event\PostWasDeleted;
|
||||
use Flarum\Event\PostWasHidden;
|
||||
use Flarum\Event\PostWasPosted;
|
||||
use Flarum\Event\PostWasRestored;
|
||||
use Flarum\Post\Event\Deleted;
|
||||
use Flarum\Post\Event\Hidden;
|
||||
use Flarum\Post\Event\Posted;
|
||||
use Flarum\Post\Event\Restored;
|
||||
use Flarum\Post\Post;
|
||||
use Flarum\Subscriptions\Notification\NewPostBlueprint;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
|
@ -47,10 +47,10 @@ class SendNotificationWhenReplyIsPosted
|
|||
// Register with '1' as priority so this runs before discussion metadata
|
||||
// is updated, as we need to compare the user's last read number to that
|
||||
// of the previous post.
|
||||
$events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted'], 1);
|
||||
$events->listen(PostWasHidden::class, [$this, 'whenPostWasHidden']);
|
||||
$events->listen(PostWasRestored::class, [$this, 'whenPostWasRestored']);
|
||||
$events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']);
|
||||
$events->listen(Posted::class, [$this, 'whenPosted'], 1);
|
||||
$events->listen(Hidden::class, [$this, 'whenHidden']);
|
||||
$events->listen(Restored::class, [$this, 'whenRestored']);
|
||||
$events->listen(Deleted::class, [$this, 'whenDeleted']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,13 +58,13 @@ class SendNotificationWhenReplyIsPosted
|
|||
*/
|
||||
public function addNotificationType(ConfigureNotificationTypes $event)
|
||||
{
|
||||
$event->add(NewPostBlueprint::class, DiscussionBasicSerializer::class, ['alert', 'email']);
|
||||
$event->add(NewPostBlueprint::class, BasicDiscussionSerializer::class, ['alert', 'email']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PostWasPosted $event
|
||||
* @param Posted $event
|
||||
*/
|
||||
public function whenPostWasPosted(PostWasPosted $event)
|
||||
public function whenPosted(Posted $event)
|
||||
{
|
||||
$post = $event->post;
|
||||
$discussion = $post->discussion;
|
||||
|
@ -82,25 +82,25 @@ class SendNotificationWhenReplyIsPosted
|
|||
}
|
||||
|
||||
/**
|
||||
* @param PostWasHidden $event
|
||||
* @param Hidden $event
|
||||
*/
|
||||
public function whenPostWasHidden(PostWasHidden $event)
|
||||
public function whenHidden(Hidden $event)
|
||||
{
|
||||
$this->notifications->delete($this->getNotification($event->post));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PostWasRestored $event
|
||||
* @param Restored $event
|
||||
*/
|
||||
public function whenPostWasRestored(PostWasRestored $event)
|
||||
public function whenRestored(Restored $event)
|
||||
{
|
||||
$this->notifications->restore($this->getNotification($event->post));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PostWasDeleted $event
|
||||
* @param Deleted $event
|
||||
*/
|
||||
public function whenPostWasDeleted(PostWasDeleted $event)
|
||||
public function whenDeleted(Deleted $event)
|
||||
{
|
||||
$this->notifications->delete($this->getNotification($event->post));
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
|
||||
namespace Flarum\Subscriptions\Notification;
|
||||
|
||||
use Flarum\Core\Discussion;
|
||||
use Flarum\Core\Notification\BlueprintInterface;
|
||||
use Flarum\Core\Notification\MailableInterface;
|
||||
use Flarum\Core\Post;
|
||||
use Flarum\Discussion\Discussion;
|
||||
use Flarum\Notification\Blueprint\BlueprintInterface;
|
||||
use Flarum\Post\Post;
|
||||
|
||||
class NewPostBlueprint implements BlueprintInterface, MailableInterface
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user