Commit d36fc658 authored by Mark Harding's avatar Mark Harding

(feat): send notifications when subscription requests are made

1 merge request!327Subscription Requests - #604
Pipeline #82751545 passed with stages
in 13 minutes and 12 seconds
<?php
namespace Minds\Core\Subscriptions\Requests\Delegates;
use Minds\Core\Di\Di;
use Minds\Core\Events\EventsDispatcher;
use Minds\Core\Subscriptions\Requests\SubscriptionRequest;
class NotificationsDelegate
{
/** @var EventsDispatcher */
private $eventsDispatcher;
public function __construct($eventsDispatcher = null)
{
$this->eventsDispatcher = $eventsDispatcher ?: Di::_()->get('EventsDispatcher');
}
/**
* Called when subscription request is made
* @param SubscriptionRequest $subscriptionRequest
......@@ -12,7 +22,13 @@ class NotificationsDelegate
*/
public function onAdd(SubscriptionRequest $subscriptionRequest): void
{
// TODO
$this->eventsDispatcher->trigger('notification', 'all', [
'to' => [ $subscriptionRequest->getPublisherGuid() ],
'entity' => $subscriptionRequest->getSubscriberGuid(),
'notification_view' => 'subscription_request_received',
'from' => $subscriptionRequest->getSubscriberGuid(),
'params' => [],
]);
}
/**
......@@ -22,7 +38,13 @@ class NotificationsDelegate
*/
public function onAccept(SubscriptionRequest $subscriptionRequest): void
{
// TODO
$this->eventsDispatcher->trigger('notification', 'all', [
'to' => [ $subscription->getSubscriberGuid() ],
'entity' => $subscription->getPublisherGuid(),
'notification_view' => 'subscription_request_accepted',
'from' => $subscription->getPublisherGuid(),
'params' => [],
]);
}
/**
......@@ -32,6 +54,12 @@ class NotificationsDelegate
*/
public function onDecline(SubscriptionRequest $subscriptionRequest): void
{
// TODO
$this->eventsDispatcher->trigger('notification', 'all', [
'to' => [ $subscription->getSubscriberGuid() ],
'entity' => $subscription->getPublisherGuid(),
'notification_view' => 'subscription_request_declined',
'from' => $subscription->getPublisherGuid(),
'params' => [],
]);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment