mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 04:31:57 +08:00
parent
86496f3e06
commit
3fc150cd23
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Flarum\Mentions\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([
|
||||
|
@ -15,14 +15,14 @@ use Flarum\Api\Controller\CreatePostController;
|
||||
use Flarum\Api\Controller\ListPostsController;
|
||||
use Flarum\Api\Controller\ShowDiscussionController;
|
||||
use Flarum\Api\Controller\ShowPostController;
|
||||
use Flarum\Api\Serializer\PostBasicSerializer;
|
||||
use Flarum\Core\Post;
|
||||
use Flarum\Core\Repository\PostRepository;
|
||||
use Flarum\Core\User;
|
||||
use Flarum\Event\ConfigureApiController;
|
||||
use Flarum\Api\Event\WillGetData;
|
||||
use Flarum\Api\Event\WillSerializeData;
|
||||
use Flarum\Api\Serializer\BasicPostSerializer;
|
||||
use Flarum\Event\GetApiRelationship;
|
||||
use Flarum\Event\GetModelRelationship;
|
||||
use Flarum\Event\PrepareApiData;
|
||||
use Flarum\Post\Post;
|
||||
use Flarum\Post\PostRepository;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class AddPostMentionedByRelationship
|
||||
@ -47,8 +47,8 @@ class AddPostMentionedByRelationship
|
||||
{
|
||||
$events->listen(GetModelRelationship::class, [$this, 'getModelRelationship']);
|
||||
$events->listen(GetApiRelationship::class, [$this, 'getApiRelationship']);
|
||||
$events->listen(ConfigureApiController::class, [$this, 'includeRelationships']);
|
||||
$events->listen(PrepareApiData::class, [$this, 'filterVisiblePosts']);
|
||||
$events->listen(WillGetData::class, [$this, 'includeRelationships']);
|
||||
$events->listen(WillSerializeData::class, [$this, 'filterVisiblePosts']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,23 +76,23 @@ class AddPostMentionedByRelationship
|
||||
*/
|
||||
public function getApiRelationship(GetApiRelationship $event)
|
||||
{
|
||||
if ($event->isRelationship(PostBasicSerializer::class, 'mentionedBy')) {
|
||||
return $event->serializer->hasMany($event->model, PostBasicSerializer::class, 'mentionedBy');
|
||||
if ($event->isRelationship(BasicPostSerializer::class, 'mentionedBy')) {
|
||||
return $event->serializer->hasMany($event->model, BasicPostSerializer::class, 'mentionedBy');
|
||||
}
|
||||
|
||||
if ($event->isRelationship(PostBasicSerializer::class, 'mentionsPosts')) {
|
||||
return $event->serializer->hasMany($event->model, PostBasicSerializer::class, 'mentionsPosts');
|
||||
if ($event->isRelationship(BasicPostSerializer::class, 'mentionsPosts')) {
|
||||
return $event->serializer->hasMany($event->model, BasicPostSerializer::class, 'mentionsPosts');
|
||||
}
|
||||
|
||||
if ($event->isRelationship(PostBasicSerializer::class, 'mentionsUsers')) {
|
||||
return $event->serializer->hasMany($event->model, PostBasicSerializer::class, 'mentionsUsers');
|
||||
if ($event->isRelationship(BasicPostSerializer::class, 'mentionsUsers')) {
|
||||
return $event->serializer->hasMany($event->model, BasicPostSerializer::class, 'mentionsUsers');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConfigureApiController $event
|
||||
* @param WillGetData $event
|
||||
*/
|
||||
public function includeRelationships(ConfigureApiController $event)
|
||||
public function includeRelationships(WillGetData $event)
|
||||
{
|
||||
if ($event->isController(ShowDiscussionController::class)) {
|
||||
$event->addInclude([
|
||||
@ -127,9 +127,9 @@ class AddPostMentionedByRelationship
|
||||
* additional posts so that the user can't see any posts which they don't
|
||||
* have access to.
|
||||
*
|
||||
* @param PrepareApiData $event
|
||||
* @param WillSerializeData $event
|
||||
*/
|
||||
public function filterVisiblePosts(PrepareApiData $event)
|
||||
public function filterVisiblePosts(WillSerializeData $event)
|
||||
{
|
||||
// Firstly we gather a list of posts contained within the API document.
|
||||
// This will vary according to the API endpoint that is being accessed.
|
||||
|
@ -11,10 +11,10 @@
|
||||
|
||||
namespace Flarum\Mentions\Listener;
|
||||
|
||||
use Flarum\Core\Post\CommentPost;
|
||||
use Flarum\Event\ConfigureFormatter;
|
||||
use Flarum\Event\ConfigureFormatterRenderer;
|
||||
use Flarum\Formatter\Event\Configuring;
|
||||
use Flarum\Formatter\Event\ConfiguringRenderer;
|
||||
use Flarum\Forum\UrlGenerator;
|
||||
use Flarum\Post\Post\CommentPost;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class FormatPostMentions
|
||||
@ -37,14 +37,14 @@ class FormatPostMentions
|
||||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(ConfigureFormatter::class, [$this, 'configure']);
|
||||
$events->listen(ConfigureFormatterRenderer::class, [$this, 'render']);
|
||||
$events->listen(Configuring::class, [$this, 'configure']);
|
||||
$events->listen(ConfiguringRenderer::class, [$this, 'render']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConfigureFormatter $event
|
||||
* @param Configuring $event
|
||||
*/
|
||||
public function configure(ConfigureFormatter $event)
|
||||
public function configure(Configuring $event)
|
||||
{
|
||||
$configurator = $event->configurator;
|
||||
|
||||
@ -69,9 +69,9 @@ class FormatPostMentions
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConfigureFormatterRenderer $event
|
||||
* @param ConfiguringRenderer $event
|
||||
*/
|
||||
public function render(ConfigureFormatterRenderer $event)
|
||||
public function render(ConfiguringRenderer $event)
|
||||
{
|
||||
$event->renderer->setParameter('DISCUSSION_URL', $this->url->toRoute('discussion', ['id' => '']));
|
||||
}
|
||||
|
@ -11,11 +11,11 @@
|
||||
|
||||
namespace Flarum\Mentions\Listener;
|
||||
|
||||
use Flarum\Core\Repository\UserRepository;
|
||||
use Flarum\Event\ConfigureFormatter;
|
||||
use Flarum\Event\ConfigureFormatterParser;
|
||||
use Flarum\Event\ConfigureFormatterRenderer;
|
||||
use Flarum\Formatter\Event\Configuring;
|
||||
use Flarum\Formatter\Event\ConfiguringParser;
|
||||
use Flarum\Formatter\Event\ConfiguringRenderer;
|
||||
use Flarum\Forum\UrlGenerator;
|
||||
use Flarum\User\UserRepository;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class FormatUserMentions
|
||||
@ -45,15 +45,15 @@ class FormatUserMentions
|
||||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(ConfigureFormatter::class, [$this, 'configure']);
|
||||
$events->listen(ConfigureFormatterParser::class, [$this, 'parse']);
|
||||
$events->listen(ConfigureFormatterRenderer::class, [$this, 'render']);
|
||||
$events->listen(Configuring::class, [$this, 'configure']);
|
||||
$events->listen(ConfiguringParser::class, [$this, 'parse']);
|
||||
$events->listen(ConfiguringRenderer::class, [$this, 'render']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConfigureFormatter $event
|
||||
* @param Configuring $event
|
||||
*/
|
||||
public function configure(ConfigureFormatter $event)
|
||||
public function configure(Configuring $event)
|
||||
{
|
||||
$configurator = $event->configurator;
|
||||
|
||||
@ -73,17 +73,17 @@ class FormatUserMentions
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConfigureFormatterParser $event
|
||||
* @param ConfiguringParser $event
|
||||
*/
|
||||
public function parse(ConfigureFormatterParser $event)
|
||||
public function parse(ConfiguringParser $event)
|
||||
{
|
||||
$event->parser->registeredVars['userRepository'] = $this->users;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConfigureFormatterRenderer $event
|
||||
* @param ConfiguringRenderer $event
|
||||
*/
|
||||
public function render(ConfigureFormatterRenderer $event)
|
||||
public function render(ConfiguringRenderer $event)
|
||||
{
|
||||
$event->renderer->setParameter('PROFILE_URL', $this->url->toRoute('user', ['username' => '']));
|
||||
}
|
||||
|
@ -11,16 +11,16 @@
|
||||
|
||||
namespace Flarum\Mentions\Listener;
|
||||
|
||||
use Flarum\Api\Serializer\PostBasicSerializer;
|
||||
use Flarum\Core\Notification\NotificationSyncer;
|
||||
use Flarum\Core\Post;
|
||||
use Flarum\Api\Serializer\BasicPostSerializer;
|
||||
use Flarum\Event\ConfigureNotificationTypes;
|
||||
use Flarum\Event\PostWasDeleted;
|
||||
use Flarum\Event\PostWasHidden;
|
||||
use Flarum\Event\PostWasPosted;
|
||||
use Flarum\Event\PostWasRestored;
|
||||
use Flarum\Event\PostWasRevised;
|
||||
use Flarum\Mentions\Notification\PostMentionedBlueprint;
|
||||
use Flarum\Notification\NotificationSyncer;
|
||||
use Flarum\Post\Event\Deleted;
|
||||
use Flarum\Post\Event\Hidden;
|
||||
use Flarum\Post\Event\Posted;
|
||||
use Flarum\Post\Event\Restored;
|
||||
use Flarum\Post\Event\Revised;
|
||||
use Flarum\Post\Post;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use s9e\TextFormatter\Utils;
|
||||
|
||||
@ -45,11 +45,11 @@ class UpdatePostMentionsMetadata
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(ConfigureNotificationTypes::class, [$this, 'addNotificationType']);
|
||||
$events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted']);
|
||||
$events->listen(PostWasRevised::class, [$this, 'whenPostWasRevised']);
|
||||
$events->listen(PostWasHidden::class, [$this, 'whenPostWasHidden']);
|
||||
$events->listen(PostWasRestored::class, [$this, 'whenPostWasRestored']);
|
||||
$events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']);
|
||||
$events->listen(Posted::class, [$this, 'whenPosted']);
|
||||
$events->listen(Revised::class, [$this, 'whenRevised']);
|
||||
$events->listen(Hidden::class, [$this, 'whenHidden']);
|
||||
$events->listen(Restored::class, [$this, 'whenRestored']);
|
||||
$events->listen(Deleted::class, [$this, 'whenDeleted']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -57,45 +57,45 @@ class UpdatePostMentionsMetadata
|
||||
*/
|
||||
public function addNotificationType(ConfigureNotificationTypes $event)
|
||||
{
|
||||
$event->add(PostMentionedBlueprint::class, PostBasicSerializer::class, ['alert']);
|
||||
$event->add(PostMentionedBlueprint::class, BasicPostSerializer::class, ['alert']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PostWasPosted $event
|
||||
* @param Posted $event
|
||||
*/
|
||||
public function whenPostWasPosted(PostWasPosted $event)
|
||||
public function whenPosted(Posted $event)
|
||||
{
|
||||
$this->replyBecameVisible($event->post);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PostWasRevised $event
|
||||
* @param Revised $event
|
||||
*/
|
||||
public function whenPostWasRevised(PostWasRevised $event)
|
||||
public function whenRevised(Revised $event)
|
||||
{
|
||||
$this->replyBecameVisible($event->post);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PostWasHidden $event
|
||||
* @param Hidden $event
|
||||
*/
|
||||
public function whenPostWasHidden(PostWasHidden $event)
|
||||
public function whenHidden(Hidden $event)
|
||||
{
|
||||
$this->replyBecameInvisible($event->post);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PostWasRestored $event
|
||||
* @param Restored $event
|
||||
*/
|
||||
public function whenPostWasRestored(PostWasRestored $event)
|
||||
public function whenRestored(Restored $event)
|
||||
{
|
||||
$this->replyBecameVisible($event->post);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PostWasDeleted $event
|
||||
* @param Deleted $event
|
||||
*/
|
||||
public function whenPostWasDeleted(PostWasDeleted $event)
|
||||
public function whenDeleted(Deleted $event)
|
||||
{
|
||||
$this->replyBecameInvisible($event->post);
|
||||
}
|
||||
|
@ -11,17 +11,17 @@
|
||||
|
||||
namespace Flarum\Mentions\Listener;
|
||||
|
||||
use Flarum\Api\Serializer\PostBasicSerializer;
|
||||
use Flarum\Core\Notification\NotificationSyncer;
|
||||
use Flarum\Core\Post;
|
||||
use Flarum\Core\User;
|
||||
use Flarum\Api\Serializer\BasicPostSerializer;
|
||||
use Flarum\Event\ConfigureNotificationTypes;
|
||||
use Flarum\Event\PostWasDeleted;
|
||||
use Flarum\Event\PostWasHidden;
|
||||
use Flarum\Event\PostWasPosted;
|
||||
use Flarum\Event\PostWasRestored;
|
||||
use Flarum\Event\PostWasRevised;
|
||||
use Flarum\Mentions\Notification\UserMentionedBlueprint;
|
||||
use Flarum\Notification\NotificationSyncer;
|
||||
use Flarum\Post\Event\Deleted;
|
||||
use Flarum\Post\Event\Hidden;
|
||||
use Flarum\Post\Event\Posted;
|
||||
use Flarum\Post\Event\Restored;
|
||||
use Flarum\Post\Event\Revised;
|
||||
use Flarum\Post\Post;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use s9e\TextFormatter\Utils;
|
||||
|
||||
@ -46,11 +46,11 @@ class UpdateUserMentionsMetadata
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(ConfigureNotificationTypes::class, [$this, 'addNotificationType']);
|
||||
$events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted']);
|
||||
$events->listen(PostWasRevised::class, [$this, 'whenPostWasRevised']);
|
||||
$events->listen(PostWasHidden::class, [$this, 'whenPostWasHidden']);
|
||||
$events->listen(PostWasRestored::class, [$this, 'whenPostWasRestored']);
|
||||
$events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']);
|
||||
$events->listen(Posted::class, [$this, 'whenPosted']);
|
||||
$events->listen(Revised::class, [$this, 'whenRevised']);
|
||||
$events->listen(Hidden::class, [$this, 'whenHidden']);
|
||||
$events->listen(Restored::class, [$this, 'whenRestored']);
|
||||
$events->listen(Deleted::class, [$this, 'whenDeleted']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,45 +58,45 @@ class UpdateUserMentionsMetadata
|
||||
*/
|
||||
public function addNotificationType(ConfigureNotificationTypes $event)
|
||||
{
|
||||
$event->add(UserMentionedBlueprint::class, PostBasicSerializer::class, ['alert']);
|
||||
$event->add(UserMentionedBlueprint::class, BasicPostSerializer::class, ['alert']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PostWasPosted $event
|
||||
* @param Posted $event
|
||||
*/
|
||||
public function whenPostWasPosted(PostWasPosted $event)
|
||||
public function whenPosted(Posted $event)
|
||||
{
|
||||
$this->postBecameVisible($event->post);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PostWasRevised $event
|
||||
* @param Revised $event
|
||||
*/
|
||||
public function whenPostWasRevised(PostWasRevised $event)
|
||||
public function whenRevised(Revised $event)
|
||||
{
|
||||
$this->postBecameVisible($event->post);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PostWasHidden $event
|
||||
* @param Hidden $event
|
||||
*/
|
||||
public function whenPostWasHidden(PostWasHidden $event)
|
||||
public function whenHidden(Hidden $event)
|
||||
{
|
||||
$this->postBecameInvisible($event->post);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PostWasRestored $event
|
||||
* @param Restored $event
|
||||
*/
|
||||
public function whenPostWasRestored(PostWasRestored $event)
|
||||
public function whenRestored(Restored $event)
|
||||
{
|
||||
$this->postBecameVisible($event->post);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PostWasDeleted $event
|
||||
* @param Deleted $event
|
||||
*/
|
||||
public function whenPostWasDeleted(PostWasDeleted $event)
|
||||
public function whenDeleted(Deleted $event)
|
||||
{
|
||||
$this->postBecameInvisible($event->post);
|
||||
}
|
||||
|
@ -11,9 +11,9 @@
|
||||
|
||||
namespace Flarum\Mentions\Notification;
|
||||
|
||||
use Flarum\Core\Notification\BlueprintInterface;
|
||||
use Flarum\Core\Notification\MailableInterface;
|
||||
use Flarum\Core\Post;
|
||||
use Flarum\Notification\Blueprint\BlueprintInterface;
|
||||
use Flarum\Post\Post;
|
||||
|
||||
class PostMentionedBlueprint implements BlueprintInterface, MailableInterface
|
||||
{
|
||||
|
@ -11,9 +11,9 @@
|
||||
|
||||
namespace Flarum\Mentions\Notification;
|
||||
|
||||
use Flarum\Core\Notification\BlueprintInterface;
|
||||
use Flarum\Core\Notification\MailableInterface;
|
||||
use Flarum\Core\Post;
|
||||
use Flarum\Notification\Blueprint\BlueprintInterface;
|
||||
use Flarum\Post\Post;
|
||||
|
||||
class UserMentionedBlueprint implements BlueprintInterface, MailableInterface
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user