fix(mentions): post reply mention missing notification on approval (#3738)

* Add PostWasApproved event

* Apply fixes from StyleCI

* fix: phpstan error

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

---------

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
This commit is contained in:
Tristian Kelly 2023-02-21 09:04:03 -06:00 committed by GitHub
parent a3a39caa44
commit 33e2bd1a77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -15,6 +15,7 @@ use Flarum\Api\Serializer\BasicUserSerializer;
use Flarum\Api\Serializer\CurrentUserSerializer;
use Flarum\Api\Serializer\GroupSerializer;
use Flarum\Api\Serializer\PostSerializer;
use Flarum\Approval\Event\PostWasApproved;
use Flarum\Extend;
use Flarum\Group\Group;
use Flarum\Post\Event\Deleted;
@ -106,6 +107,7 @@ return [
->listen(Posted::class, Listener\UpdateMentionsMetadataWhenVisible::class)
->listen(Restored::class, Listener\UpdateMentionsMetadataWhenVisible::class)
->listen(Revised::class, Listener\UpdateMentionsMetadataWhenVisible::class)
->listen(PostWasApproved::class, Listener\UpdateMentionsMetadataWhenVisible::class)
->listen(Hidden::class, Listener\UpdateMentionsMetadataWhenInvisible::class)
->listen(Deleted::class, Listener\UpdateMentionsMetadataWhenInvisible::class),

View File

@ -9,10 +9,12 @@
namespace Flarum\Mentions\Listener;
use Flarum\Approval\Event\PostWasApproved;
use Flarum\Mentions\Notification\GroupMentionedBlueprint;
use Flarum\Mentions\Notification\PostMentionedBlueprint;
use Flarum\Mentions\Notification\UserMentionedBlueprint;
use Flarum\Notification\NotificationSyncer;
use Flarum\Post\CommentPost;
use Flarum\Post\Event\Posted;
use Flarum\Post\Event\Restored;
use Flarum\Post\Event\Revised;
@ -36,10 +38,14 @@ class UpdateMentionsMetadataWhenVisible
}
/**
* @param Posted|Restored|Revised $event
* @param Posted|Restored|Revised|PostWasApproved $event
*/
public function handle($event)
{
if (! $event->post instanceof CommentPost) {
return;
}
$content = $event->post->parsed_content;
$this->syncUserMentions(