OurSpace/app/Listeners/NoteRepliedListener.php
2025-01-09 22:36:02 -05:00

43 lines
819 B
PHP

<?php
namespace App\Listeners;
use App\Models\User;
use App\Events\NoteRepliedEvent;
use Illuminate\Support\Facades\Log;
use App\Notifications\UserNotification;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class NoteRepliedListener
{
/**
* Create the event listener.
*/
public function __construct()
{
//
}
/**
* Handle the event.
*/
public function handle(NoteRepliedEvent $event): void
{
$note_actor = $event->object->get_actor ()->first ();
if (!$note_actor || !$note_actor->user)
return;
$note_actor->user->notify (new UserNotification(
"Reply",
$event->actor->id,
$event->object->id,
$event->activity->id
));
}
}