Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Dependency List
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
185
Issues
185
List
Boards
Labels
Service Desk
Milestones
Merge Requests
31
Merge Requests
31
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
8c72435a
Commit
8c72435a
authored
9 minutes ago
by
Mark Harding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat): send notification is reached the max
parent
5f6907b7
chore/max-subscriptions-5000
No related merge requests found
Pipeline
#73671883
running with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
SendNotificationDelegate.php
Core/Subscriptions/Delegates/SendNotificationDelegate.php
+14
-0
Manager.php
Core/Subscriptions/Manager.php
+5
-4
ManagerSpec.php
Spec/Core/Subscriptions/ManagerSpec.php
+2
-0
No files found.
Core/Subscriptions/Delegates/SendNotificationDelegate.php
View file @
8c72435a
...
...
@@ -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
],
]);
}
}
This diff is collapsed.
Click to expand it.
Core/Subscriptions/Manager.php
View file @
8c72435a
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Subscriptions/ManagerSpec.php
View file @
8c72435a
...
...
@@ -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'
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment