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
173
Issues
173
List
Boards
Labels
Service Desk
Milestones
Merge Requests
43
Merge Requests
43
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
9f3bcb40
Commit
9f3bcb40
authored
2 hours ago
by
Ben Hayward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed failing tests
parent
6c616c16
feat/rate-limit-boost-475
1 merge request
!251
[Sprint/InterestingIguana](feat): Offchain boost rate limiting #475
Pipeline
#72258346
passed with stages
in 8 minutes and 59 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
boost.php
Controllers/api/v2/boost.php
+2
-2
ManagerSpec.php
Spec/Core/Boost/Network/ManagerSpec.php
+8
-4
No files found.
Controllers/api/v2/boost.php
View file @
9f3bcb40
...
...
@@ -298,10 +298,10 @@ class boost implements Interfaces\Api
}
if
(
$manager
->
boostLimitReached
(
$boost
))
{
$maxDaily
=
Di
::
_
()
->
get
(
'Config'
)
->
get
(
'max_daily_boost_views'
);
$maxDaily
=
Di
::
_
()
->
get
(
'Config'
)
->
get
(
'max_daily_boost_views'
)
/
1000
;
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
"
This boost would exceeded the
maximum of "
.
$maxDaily
.
" offchain tokens per day."
'message'
=>
"
Exceeded
maximum of "
.
$maxDaily
.
" offchain tokens per day."
]);
}
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Boost/Network/ManagerSpec.php
View file @
9f3bcb40
...
...
@@ -13,6 +13,7 @@ use Minds\Entities\Activity;
use
Minds\Entities\User
;
use
PhpSpec\ObjectBehavior
;
use
Prophecy\Argument
;
use
Minds\Core\Di\Di
;
class
ManagerSpec
extends
ObjectBehavior
{
...
...
@@ -321,12 +322,13 @@ class ManagerSpec extends ObjectBehavior
function
it_should_recognise_a_user_has_reached_the_offchain_boost_limit
(
Boost
$boost
)
{
$boostArray
=
[];
for
(
$i
=
1
;
$i
<
11
;
$i
++
)
{
for
(
$i
=
0
;
$i
<
10
;
$i
++
)
{
$newBoost
=
new
Boost
();
$newBoost
->
setCreatedTimestamp
(
'9999999999999999'
);
$newBoost
->
setImpressions
(
1000
);
array_push
(
$boostArray
,
$newBoost
);
}
Di
::
_
()
->
get
(
'Config'
)
->
set
(
'max_daily_boost_views'
,
10000
);
$this
->
runThroughGetList
(
$boost
,
$boostArray
);
$this
->
boostLimitReached
(
$boost
)
->
shouldReturn
(
true
);
}
...
...
@@ -334,12 +336,13 @@ class ManagerSpec extends ObjectBehavior
function
it_should_recognise_a_user_has_NOT_reached_the_offchain_boost_limit
(
Boost
$boost
)
{
$boostArray
=
[];
for
(
$i
=
1
;
$i
<
10
;
$i
++
)
{
for
(
$i
=
0
;
$i
<
9
;
$i
++
)
{
$newBoost
=
new
Boost
();
$newBoost
->
setCreatedTimestamp
(
'9999999999999999'
);
$newBoost
->
setImpressions
(
1000
);
array_push
(
$boostArray
,
$newBoost
);
}
Di
::
_
()
->
get
(
'Config'
)
->
set
(
'max_daily_boost_views'
,
10000
);
$this
->
runThroughGetList
(
$boost
,
$boostArray
);
$this
->
boostLimitReached
(
$boost
)
->
shouldReturn
(
false
);
}
...
...
@@ -348,14 +351,15 @@ class ManagerSpec extends ObjectBehavior
function
it_should_recognise_a_boost_would_take_user_above_offchain_limit
(
Boost
$boost
)
{
$boostArray
=
[];
for
(
$i
=
1
;
$i
<
2
;
$i
++
)
{
for
(
$i
=
0
;
$i
<
2
;
$i
++
)
{
$newBoost
=
new
Boost
();
$newBoost
->
setCreatedTimestamp
(
'9999999999999999'
);
$newBoost
->
setImpressions
(
4501
);
array_push
(
$boostArray
,
$newBoost
);
}
Di
::
_
()
->
get
(
'Config'
)
->
set
(
'max_daily_boost_views'
,
10000
);
$this
->
runThroughGetList
(
$boost
,
$boostArray
);
$this
->
boostLimitReached
(
$boost
)
->
shouldReturn
(
fals
e
);
$this
->
boostLimitReached
(
$boost
)
->
shouldReturn
(
tru
e
);
}
function
runThroughGetList
(
$boost
,
$existingBoosts
)
{
...
...
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