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
176
Issues
176
List
Boards
Labels
Service Desk
Milestones
Merge Requests
38
Merge Requests
38
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
56d97028
Commit
56d97028
authored
7 minutes ago
by
Ben Hayward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated for feedback
parent
5f801ecc
feat/plus-tiers-578
1 merge request
!279
[Sprint/JollyJellyfish](feat): Added plus tiers to endpoint and passed through #578
Pipeline
#72560318
failed with stages
in 4 minutes and 23 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
7 deletions
+26
-7
wire.php
Controllers/api/v1/wire.php
+1
-1
Plus.php
Core/Wire/Delegates/Plus.php
+8
-5
Manager.php
Core/Wire/Manager.php
+17
-1
No files found.
Controllers/api/v1/wire.php
View file @
56d97028
...
...
@@ -70,7 +70,7 @@ class wire implements Interfaces\Api
$manager
=
Core\Di\Di
::
_
()
->
get
(
'Wire\Manager'
);
$tier
=
$_POST
[
'tier'
]
??
''
;
$tier
=
$_POST
[
'tier'
]
??
MONTHLY
;
$payload
=
(
array
)
$_POST
[
'payload'
]
??
[];
try
{
...
...
This diff is collapsed.
Click to expand it.
Core/Wire/Delegates/Plus.php
View file @
56d97028
...
...
@@ -6,9 +6,12 @@ namespace Minds\Core\Wire\Delegates;
use
Minds\Core\Config
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Wire\Manager
;
class
Plus
{
{
/* @var const LIFETIME_TIMESTAMP */
const
LIFETIME_TIMESTAMP
=
9999999999
;
/** @var Config $config */
private
$config
;
...
...
@@ -62,11 +65,11 @@ class Plus
// check the users tier if passed in. If not, it's a standard monthly subscription.
switch
(
$tier
)
{
case
'lifetime'
:
$user
->
setPlusExpires
(
9999999999
);
//life
case
Manager
::
LIFETIME
:
$user
->
setPlusExpires
(
static
::
LIFETIME_TIMESTAMP
);
//life
break
;
case
'yearly'
:
case
Manager
::
YEARLY
:
$user
->
setPlusExpires
(
$this
->
calculatePlusExpires
(
'+1 year'
,
$wire
->
getTimestamp
(),
$user
->
plus_expires
));
break
;
...
...
@@ -91,7 +94,7 @@ class Plus
*/
public
function
calculatePlusExpires
(
$timespan
,
$wireTimestamp
,
$previousTimestamp
=
null
)
{
if
(
$previousTimestamp
===
9999999999
)
{
if
(
$previousTimestamp
===
static
::
LIFETIME_TIMESTAMP
)
{
throw
new
\Exception
(
'Already existing lifetime subscription'
);
}
...
...
This diff is collapsed.
Click to expand it.
Core/Wire/Manager.php
View file @
56d97028
...
...
@@ -17,6 +17,7 @@ use Minds\Core\Wire\Subscriptions\Manager as SubscriptionsManager;
use
Minds\Common\Urn
;
use
Minds\Entities
;
use
Minds\Entities\User
;
use
Twilio\Rest\Api\V2010\Account\Usage\Record\YearlyInstance
;
class
Manager
{
...
...
@@ -80,6 +81,15 @@ class Manager
/** @var Core\Blockchain\Wallets\OffChain\Transactions */
protected
$offchainTxs
;
/** @var const MONTHLY **/
const
MONTHLY
=
'month'
;
/** @var const YEARLY **/
const
YEARLY
=
'year'
;
/** @var const LIFETIME **/
const
LIFETIME
=
'lifetime'
;
public
function
__construct
(
$cache
=
null
,
$repository
=
null
,
...
...
@@ -160,7 +170,13 @@ class Manager
return
$this
;
}
public
function
setTier
(
$tier
=
''
)
/**
* Sets the tier of the wire e.g. 'monthly', 'yearly', 'lifetime
*
* @param string $tier - the tier
* @return $this
*/
public
function
setTier
(
$tier
=
MONTHLY
)
{
$this
->
tier
=
$tier
;
...
...
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