Commit 8c72435a authored by Mark Harding's avatar Mark Harding

(feat): send notification is reached the max

No related merge requests found
Pipeline #73671883 running with stages
......@@ -34,4 +34,18 @@ class SendNotificationDelegate
}
public function onMaxSubscriptions($subscription)
{
$message = "You are unable to subscribe to new channels as you are have over 5000 subscriptions.";
$this->eventsDispatcher->trigger('notification', 'all', [
'to' => [ $subscription->getSubscriberGuid() ],
'entity' => $subscription->getPublisherGuid(),
'notification_view' => 'custom_message',
'from' => 100000000000000519,
'message' => $message,
'params' => [ 'message' => $message],
]);
}
}
......@@ -99,14 +99,15 @@ class Manager
*/
public function subscribe($publisher)
{
if ($this->getSubscriptionsCount() >= static::MAX_SUBSCRIPTIONS) {
throw new TooManySubscriptionsException();
}
$subscription = new Subscription();
$subscription->setSubscriberGuid($this->subscriber->getGuid())
->setPublisherGuid($publisher->getGuid());
if ($this->getSubscriptionsCount() >= static::MAX_SUBSCRIPTIONS) {
$this->sendNotificationDelegate->onMaxSubscriptions($subscription);
throw new TooManySubscriptionsException();
}
$subscription = $this->repository->add($subscription);
$this->eventsDelegate->trigger($subscription);
......
......@@ -121,6 +121,8 @@ class ManagerSpec extends ObjectBehavior
$subscriber->getSubscriptionsCount()
->willReturn(5000);
$subscriber->getGUID()
->willReturn(123);
$this->setSubscriber($subscriber);
$this->shouldThrow('Minds\Core\Subscriptions\TooManySubscriptionsException')
......
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