Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
221
Issues
221
List
Boards
Labels
Service Desk
Milestones
Merge Requests
35
Merge Requests
35
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
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
209a5da9
Commit
209a5da9
authored
53 minutes ago
by
Brian Hatchet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged and cleanup
parent
36b9df4c
feat/permissions-on-entities-737
No related merge requests found
Pipeline
#82219582
passed with stages
in 10 minutes and 5 seconds
Changes
39
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
2331 additions
and
1508 deletions
+2331
-1508
Notification.php
Controllers/Cli/Notification.php
+77
-0
reports.php
Controllers/api/v1/admin/reports.php
+1
-1
container.php
Controllers/api/v2/feeds/container.php
+3
-0
connect.php
Controllers/api/v2/payments/stripe/connect.php
+8
-1
photoid.php
Controllers/api/v2/payments/stripe/connect/photoid.php
+41
-0
terms.php
Controllers/api/v2/payments/stripe/connect/terms.php
+41
-0
transactions.php
Controllers/api/v2/payments/stripe/transactions.php
+54
-0
Manager.php
Core/Boost/Network/Manager.php
+1
-1
wire-received.tpl
Core/Email/Campaigns/Templates/wire-received.tpl
+1
-1
wire-sent.tpl
Core/Email/Campaigns/Templates/wire-sent.tpl
+1
-1
Manager.php
Core/Feeds/Top/Manager.php
+1
-0
Repository.php
Core/Feeds/Top/Repository.php
+22
-5
Account.php
Core/Payments/Stripe/Connect/Account.php
+30
-0
Balance.php
Core/Payments/Stripe/Connect/Balance.php
+34
-0
Manager.php
Core/Payments/Stripe/Connect/Manager.php
+77
-6
BalanceInstance.php
Core/Payments/Stripe/Instances/BalanceInstance.php
+20
-0
ChargeInstance.php
Core/Payments/Stripe/Instances/ChargeInstance.php
+19
-0
FileInstance.php
Core/Payments/Stripe/Instances/FileInstance.php
+19
-0
TransferInstance.php
Core/Payments/Stripe/Instances/TransferInstance.php
+19
-0
Manager.php
Core/Payments/Stripe/Intents/Manager.php
+3
-0
Manager.php
Core/Payments/Stripe/Transactions/Manager.php
+57
-0
Transaction.php
Core/Payments/Stripe/Transactions/Transaction.php
+53
-0
ChannelRoleCalculator.php
Core/Permissions/Delegates/ChannelRoleCalculator.php
+2
-1
GroupRoleCalculator.php
Core/Permissions/Delegates/GroupRoleCalculator.php
+3
-2
Manager.php
Core/Permissions/Entities/Manager.php
+6
-5
Manager.php
Core/Permissions/Manager.php
+9
-5
Permissions.php
Core/Permissions/Permissions.php
+19
-11
BaseRole.php
Core/Permissions/Roles/BaseRole.php
+4
-3
Role.php
Core/Permissions/Roles/Role.php
+8
-0
Events.php
Core/Security/Events.php
+1
-0
Spam.php
Core/Security/Spam.php
+1
-0
Manager.php
Core/Wire/Manager.php
+3
-0
ManagerSpec.php
Spec/Core/Feeds/Top/ManagerSpec.php
+35
-0
RepositorySpec.php
Spec/Core/Feeds/Top/RepositorySpec.php
+7
-0
ManagerSpec.php
Spec/Core/Payments/Stripe/Connect/ManagerSpec.php
+58
-2
ManagerSpec.php
Spec/Core/Permissions/ManagerSpec.php
+33
-0
PermissionsSpec.php
Spec/Core/Permissions/PermissionsSpec.php
+4
-4
ElggEntity.php
classes/ElggEntity.php
+1555
-1458
setup.sh
tools/setup.sh
+1
-1
No files found.
Controllers/Cli/Notification.php
0 → 100644
View file @
209a5da9
<?php
namespace
Minds\Controllers\Cli
;
use
Minds\Cli
;
use
Minds\Core\Events\Dispatcher
;
use
Minds\Interfaces
;
class
Notification
extends
Cli\Controller
implements
Interfaces\CliControllerInterface
{
public
function
help
(
$command
=
null
)
{
switch
(
$command
)
{
case
'send'
:
$this
->
out
(
'Send a notification'
);
$this
->
out
(
'--namespace=<type> Notification namespace'
);
$this
->
out
(
'--to=<user guid> User to send notification to'
);
$this
->
out
(
'--from=<entity guid> Entity notification is from (defaults to system user)'
);
$this
->
out
(
'--view=<view> Notification view'
);
$this
->
out
(
'--params=<params> JSON payload data'
);
// no break
default
:
$this
->
out
(
'Syntax usage: cli notification <cmd>'
);
$this
->
displayCommandHelp
();
}
}
public
function
exec
()
{
$this
->
help
();
}
public
function
send
()
{
$namespace
=
$this
->
getOpt
(
'namespace'
);
$to
=
$this
->
getOpt
(
'to'
);
$from
=
$this
->
getOpt
(
'from'
)
??
\Minds\Core\Notification\Notification
::
SYSTEM_ENTITY
;
$view
=
$this
->
getOpt
(
'view'
);
$params
=
$this
->
getOpt
(
'params'
)
??
'{}'
;
if
(
is_null
(
$namespace
))
{
$this
->
out
(
'namespace must be set'
);
return
;
}
if
(
is_null
(
$to
))
{
$this
->
out
(
'to must be set'
);
return
;
}
if
(
is_null
(
$view
))
{
$this
->
out
(
'view must be set'
);
return
;
}
$paramsDecoded
=
json_decode
(
$params
,
true
);
if
(
is_null
(
$paramsDecoded
))
{
$this
->
out
(
'Params is not valid JSON'
);
return
;
}
$eventParams
=
[
'to'
=>
[
$to
],
'from'
=>
$from
,
'notification_view'
=>
$view
,
'params'
=>
$paramsDecoded
];
$sent
=
Dispatcher
::
trigger
(
'notification'
,
$namespace
,
$eventParams
);
if
(
$sent
)
{
$this
->
out
(
'Notification sent'
);
}
else
{
$this
->
out
(
'Error sending notification - is from guid valid?'
);
}
}
}
This diff is collapsed.
Click to expand it.
Controllers/api/v1/admin/reports.php
View file @
209a5da9
...
...
@@ -31,7 +31,7 @@ class reports implements Interfaces\Api, Interfaces\ApiAdminPam
/** @var Core\Reports\Repository $repository */
$repository
=
Di
::
_
()
->
get
(
'Reports\Repository'
);
$reports
=
$repository
->
get
All
([
$reports
=
$repository
->
get
List
([
'state'
=>
$state
,
'limit'
=>
$limit
,
'offset'
=>
$offset
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/feeds/container.php
View file @
209a5da9
...
...
@@ -58,6 +58,9 @@ class container implements Interfaces\Api
case
'blogs'
:
$type
=
'object:blog'
;
break
;
case
'all'
:
$type
=
'all'
;
break
;
}
$hardLimit
=
5000
;
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/payments/stripe/connect.php
View file @
209a5da9
...
...
@@ -20,7 +20,14 @@ class connect implements Interfaces\Api
$connectManager
=
new
Stripe\Connect\Manager
();
$account
=
$connectManager
->
getByUser
(
$user
);
try
{
$account
=
$connectManager
->
getByUser
(
$user
);
}
catch
(
\Exception
$e
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'There was an error returning the usd account'
,
]);
}
return
Factory
::
response
([
'account'
=>
$account
->
export
(),
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/payments/stripe/connect/photoid.php
0 → 100644
View file @
209a5da9
<?php
/**
*
*/
namespace
Minds\Controllers\api\v2\payments\stripe\connect
;
use
Minds\Api\Factory
;
use
Minds\Common\Cookie
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Config
;
use
Minds\Core\Session
;
use
Minds\Interfaces
;
use
Minds\Core\Payments\Stripe
;
class
photoid
implements
Interfaces\Api
{
public
function
get
(
$pages
)
{
return
Factory
::
response
([]);
}
public
function
post
(
$pages
)
{
$user
=
Session
::
getLoggedInUser
();
$connectManager
=
new
Stripe\Connect\Manager
();
$account
=
$connectManager
->
getByUser
(
$user
);
$fp
=
fopen
(
$_FILES
[
'file'
][
'tmp_name'
],
'r'
);
$connectManager
->
addPhotoId
(
$account
,
$fp
);
return
Factory
::
response
([
'account_id'
=>
$account
->
getId
()
]);
}
public
function
put
(
$pages
)
{
return
Factory
::
response
([]);
}
public
function
delete
(
$pages
)
{
return
Factory
::
response
([]);
}
}
This diff is collapsed.
Click to expand it.
Controllers/api/v2/payments/stripe/connect/terms.php
0 → 100644
View file @
209a5da9
<?php
/**
*
*/
namespace
Minds\Controllers\api\v2\payments\stripe\connect
;
use
Minds\Api\Factory
;
use
Minds\Common\Cookie
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Config
;
use
Minds\Core\Session
;
use
Minds\Interfaces
;
use
Minds\Core\Payments\Stripe
;
class
terms
implements
Interfaces\Api
{
public
function
get
(
$pages
)
{
return
Factory
::
response
([]);
}
public
function
post
(
$pages
)
{
return
Factory
::
response
([]);
}
public
function
put
(
$pages
)
{
$user
=
Session
::
getLoggedInUser
();
$connectManager
=
new
Stripe\Connect\Manager
();
$account
=
$connectManager
->
getByUser
(
$user
);
$account
->
setIp
(
$_SERVER
[
'HTTP_X_FORWARDED_FOR'
]);
$connectManager
->
acceptTos
(
$account
);
return
Factory
::
response
([]);
}
public
function
delete
(
$pages
)
{
return
Factory
::
response
([]);
}
}
This diff is collapsed.
Click to expand it.
Controllers/api/v2/payments/stripe/transactions.php
0 → 100644
View file @
209a5da9
<?php
/**
*
*/
namespace
Minds\Controllers\api\v2\payments\stripe
;
use
Minds\Api\Factory
;
use
Minds\Common\Cookie
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Config
;
use
Minds\Core\Session
;
use
Minds\Interfaces
;
use
Minds\Core\Payments\Stripe
;
class
transactions
implements
Interfaces\Api
{
public
function
get
(
$pages
)
{
$user
=
Session
::
getLoggedInUser
();
$connectManager
=
new
Stripe\Connect\Manager
();
try
{
$account
=
$connectManager
->
getByUser
(
$user
);
}
catch
(
\Exception
$e
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'There was an error returning the usd account'
,
]);
}
$transactionsManger
=
new
Stripe\Transactions\Manager
();
$transactions
=
$transactionsManger
->
getByAccount
(
$account
);
return
Factory
::
response
([
'transactions'
=>
Factory
::
exportable
(
$transactions
),
]);
}
public
function
post
(
$pages
)
{
return
Factory
::
response
([]);
}
public
function
put
(
$pages
)
{
return
Factory
::
response
([]);
}
public
function
delete
(
$pages
)
{
return
Factory
::
response
([]);
}
}
This diff is collapsed.
Click to expand it.
Core/Boost/Network/Manager.php
View file @
209a5da9
...
...
@@ -175,7 +175,7 @@ class Manager
//filter to get todays offchain transactions
$offlineToday
=
array_filter
(
$offchain
->
toArray
(),
function
(
$result
)
{
return
$result
->
getCreatedTimestamp
()
>
time
()
-
(
60
*
60
*
24
)
;
return
$result
->
getCreatedTimestamp
()
>
(
time
()
-
(
60
*
60
*
24
))
*
1000
;
});
//reduce the impressions to count the days boosts.
...
...
This diff is collapsed.
Click to expand it.
Core/Email/Campaigns/Templates/wire-received.tpl
View file @
209a5da9
...
...
@@ -16,7 +16,7 @@
</a>
</td>
<td
style=
"width: 70%"
>
<h4
<?
php
echo
$
emailStyles-
>
getStyles('m-clear', 'm-fonts', 'm-header'); ?>>@
<?php echo $vars['sender']->get('name'); ?>
wired you
</h4>
<h4
<?
php
echo
$
emailStyles-
>
getStyles('m-clear', 'm-fonts', 'm-header'); ?>>@
<?php echo $vars['sender']->get('
user
name'); ?>
wired you
</h4>
<p
<?
php
echo
$
emailStyles-
>
getStyles('m-fonts', 'm-subtitle', 'm-clear'); ?>>Transfer Date and Amount:
</p>
<p
<?
php
echo
$
emailStyles-
>
getStyles('m-fonts', 'm-subtitle', 'm-clear'); ?>>
<?php echo $wireDate; ?>
; +
<?php echo $amount ?>
...
...
This diff is collapsed.
Click to expand it.
Core/Email/Campaigns/Templates/wire-sent.tpl
View file @
209a5da9
...
...
@@ -16,7 +16,7 @@
</a>
</td>
<td
style=
"width: 70%"
>
<h4
<?
php
echo
$
emailStyles-
>
getStyles('m-clear', 'm-fonts', 'm-header'); ?>>You wired @
<?php echo $vars['receiver']->get('name'); ?>
</h4>
<h4
<?
php
echo
$
emailStyles-
>
getStyles('m-clear', 'm-fonts', 'm-header'); ?>>You wired @
<?php echo $vars['receiver']->get('
user
name'); ?>
</h4>
<p
<?
php
echo
$
emailStyles-
>
getStyles('m-fonts', 'm-subtitle', 'm-clear'); ?>>Transfer Date and Amount:
</p>
<p
<?
php
echo
$
emailStyles-
>
getStyles('m-fonts', 'm-subtitle', 'm-clear'); ?>>
<?php echo $wireDate; ?>
; +
<?php echo $amount ?>
...
...
This diff is collapsed.
Click to expand it.
Core/Feeds/Top/Manager.php
View file @
209a5da9
...
...
@@ -95,6 +95,7 @@ class Manager
'filter_hashtags'
=>
false
,
'pinned_guids'
=>
null
,
'as_activities'
=>
false
,
'exclude'
=>
null
,
],
$opts
);
if
(
isset
(
$opts
[
'query'
])
&&
$opts
[
'query'
])
{
...
...
This diff is collapsed.
Click to expand it.
Core/Feeds/Top/Repository.php
View file @
209a5da9
...
...
@@ -53,6 +53,7 @@ class Repository
'exclude_moderated'
=>
false
,
'moderation_reservations'
=>
null
,
'pinned_guids'
=>
null
,
'exclude'
=>
null
,
],
$opts
);
if
(
!
$opts
[
'type'
])
{
...
...
@@ -67,6 +68,8 @@ class Repository
throw
new
\Exception
(
'Unsupported period'
);
}
$type
=
$opts
[
'type'
];
$body
=
[
'_source'
=>
array_unique
([
'guid'
,
...
...
@@ -75,7 +78,7 @@ class Repository
'time_created'
,
'access_id'
,
'moderator_guid'
,
$this
->
getSourceField
(
$
opts
[
'type'
]
),
$this
->
getSourceField
(
$
type
),
]),
'query'
=>
[
'function_score'
=>
[
...
...
@@ -98,7 +101,7 @@ class Repository
'sort'
=>
[],
];
/*if ($
opts['type']
=== 'group' && false) {
/*if ($
type
=== 'group' && false) {
if (!isset($body['query']['function_score']['query']['bool']['must_not'])) {
$body['query']['function_score']['query']['bool']['must_not'] = [];
}
...
...
@@ -107,7 +110,7 @@ class Repository
'access_id' => ['0', '1', '2'],
],
];
} elseif ($
opts['type']
=== 'user') {
} elseif ($
type
=== 'user') {
$body['query']['function_score']['query']['bool']['must'][] = [
'term' => [
'access_id' => '2',
...
...
@@ -236,7 +239,7 @@ class Repository
}
}
if
(
$
opts
[
'type'
]
!==
'group'
&&
$opts
[
'access_id'
]
!==
null
)
{
if
(
$
type
!==
'group'
&&
$opts
[
'access_id'
]
!==
null
)
{
$body
[
'query'
][
'function_score'
][
'query'
][
'bool'
][
'must'
][]
=
[
'terms'
=>
[
'access_id'
=>
Text
::
buildArray
(
$opts
[
'access_id'
]),
...
...
@@ -294,6 +297,14 @@ class Repository
}
}
if
(
$opts
[
'exclude'
])
{
$body
[
'query'
][
'function_score'
][
'query'
][
'bool'
][
'must_not'
][]
=
[
'terms'
=>
[
'guid'
=>
Text
::
buildArray
(
$opts
[
'exclude'
]),
],
];
}
// firehose options
...
...
@@ -338,9 +349,15 @@ class Repository
//
$esType
=
$opts
[
'type'
];
if
(
$esType
===
'all'
)
{
$esType
=
'object:image,object:video,object:blog'
;
}
$query
=
[
'index'
=>
$this
->
index
,
'type'
=>
$
opts
[
'type'
]
,
'type'
=>
$
esType
,
'body'
=>
$body
,
'size'
=>
$opts
[
'limit'
],
'from'
=>
$opts
[
'offset'
],
...
...
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Connect/Account.php
View file @
209a5da9
...
...
@@ -95,6 +95,24 @@ class Account
/** @var string $status */
private
$status
=
"processing"
;
/** @var Balance $totalBalance */
private
$totalBalance
;
/** @var Balance $pendingBalance */
private
$pendingBalance
;
/** @var string $payoutInterval */
private
$payoutInterval
;
/** @var int $payoutDelay */
private
$payoutDelay
;
/** @var int $payoutAnchor */
private
$payoutAnchor
;
/** @var string $requirement */
private
$requirement
;
/** @var array $exportable */
private
$exportable
=
[
'guid'
,
...
...
@@ -118,6 +136,10 @@ class Account
'status'
,
'verified'
,
'bankAccount'
,
'payoutInterval'
,
'payoutDelay'
,
'payoutAnchor'
,
'requirement'
,
];
/**
...
...
@@ -146,6 +168,14 @@ class Account
$export
[
$field
]
=
$this
->
$field
;
}
if
(
$this
->
totalBalance
)
{
$export
[
'totalBalance'
]
=
$this
->
totalBalance
->
export
();
}
if
(
$this
->
pendingBalance
)
{
$export
[
'pendingBalance'
]
=
$this
->
pendingBalance
->
export
();
}
return
$export
;
}
}
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Connect/Balance.php
0 → 100644
View file @
209a5da9
<?php
/**
* Stripe Connect Balance
*/
namespace
Minds\Core\Payments\Stripe\Connect
;
use
Minds\Traits\MagicAttributes
;
/**
* @method Balance getAmount(): int
* @method Balance getCurrency(): string
*/
class
Balance
{
use
MagicAttributes
;
/** @var int $amount */
private
$amount
;
/** @var string $currency */
private
$currency
;
/**
* Expose to public API
* @return array
*/
public
function
export
(
array
$extend
=
[])
:
array
{
return
[
'amount'
=>
(
int
)
$this
->
amount
,
'currency'
=>
$this
->
currency
,
];
}
}
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Connect/Manager.php
View file @
209a5da9
...
...
@@ -6,6 +6,8 @@ use Minds\Core\Entities\Actions\Save;
use
Minds\Core\Payments\Stripe\Connect\Delegates\NotificationDelegate
;
use
Minds\Core\Payments\Stripe\Currencies
;
use
Minds\Core\Payments\Stripe\Instances\AccountInstance
;
use
Minds\Core\Payments\Stripe\Instances\BalanceInstance
;
use
Minds\Core\Payments\Stripe\Instances\FileInstance
;
use
Stripe
;
use
Minds\Entities\User
;
...
...
@@ -20,14 +22,24 @@ class Manager
/** @var AccountInstance $accountInstance */
private
$accountInstance
;
/** @var BalanceInstance $balanceInstance */
private
$balanceInstance
;
/** @var FileInstance $fileInstance */
private
$fileInstance
;
public
function
__construct
(
Save
$save
=
null
,
NotificationDelegate
$notificationDelegate
=
null
,
AccountInstance
$accountInstance
=
null
AccountInstance
$accountInstance
=
null
,
BalanceInstance
$balanceInstance
=
null
,
FileInstance
$fileInstance
=
null
)
{
$this
->
save
=
$save
?:
new
Save
();
$this
->
notificationDelegate
=
$notificationDelegate
?:
new
NotificationDelegate
();
$this
->
accountInstance
=
$accountInstance
?:
new
AccountInstance
();
$this
->
balanceInstance
=
$balanceInstance
?:
new
BalanceInstance
();
$this
->
fileInstance
=
$fileInstance
?:
new
FileInstance
();
}
/**
...
...
@@ -167,6 +179,27 @@ class Manager
return
$stripeAccount
->
id
;
}
/**
* Updates a stripe connect account
* @param $account
* @return bool
* @throws \Exception
*/
public
function
acceptTos
(
Account
$account
)
:
bool
{
try
{
$this
->
accountInstance
->
update
(
$account
->
getId
(),
[
'tos_acceptance'
=>
[
'date'
=>
time
(),
'ip'
=>
$account
->
getIp
(),
],
]);
return
true
;
}
catch
(
\Exception
$e
)
{
return
false
;
}
}
/**
* Add a bank account to stripe account
* @param Account $account
...
...
@@ -195,12 +228,26 @@ class Manager
return
true
;
}
/**
* Add photo Id
* @param Account $account
* @param resource $file
* @return bool
*/
public
function
addPhotoId
(
Account
$account
,
$file
)
:
bool
{
return
(
bool
)
$this
->
fileInstance
->
create
([
'purpose'
=>
'identity_document'
,
'file'
=>
$file
,
],
[
'stripe_account'
=>
$account
->
getId
()
]);
}
/**
* Return a stripe account
* @param string $id
* @return Account
*/
public
function
getByAccountId
(
string
$id
)
:
Account
public
function
getByAccountId
(
string
$id
)
:
?
Account
{
try
{
$result
=
$this
->
accountInstance
->
retrieve
(
$id
);
...
...
@@ -223,20 +270,30 @@ class Manager
->
setBankAccount
(
$result
->
external_accounts
->
data
[
0
])
->
setAccountNumber
(
$result
->
external_accounts
->
data
[
0
][
'last4'
])
->
setRoutingNumber
(
$result
->
external_accounts
->
data
[
0
][
'routing_number'
])
->
setDestination
(
'bank'
);
->
setDestination
(
'bank'
)
->
setPayoutInterval
(
$result
->
settings
->
payouts
->
schedule
->
interval
)
->
setPayoutDelay
(
$result
->
settings
->
payouts
->
schedule
->
delay_days
)
->
setPayoutAnchor
(
$result
->
settings
->
payouts
->
schedule
->
monthly_anchor
);
//verifiction check
if
(
$result
->
legal_entity
->
verification
->
status
===
'verified'
)
{
$account
->
setVerified
(
true
);
}
if
(
$result
->
verification
->
disabled_reason
==
'fields_needed'
)
{
if
(
$result
->
verification
->
fields_needed
[
0
]
==
'legal_entity.verification.document'
)
{
$account
->
setStatus
(
'awaiting-document'
);
if
(
!
$account
->
getVerified
())
{
switch
(
$result
->
requirements
->
disabled_reason
)
{
case
'requirements.past_due'
:
$account
->
setRequirement
(
$result
->
requirements
->
currently_due
[
0
]);
break
;
}
}
$account
->
setTotalBalance
(
$this
->
getBalanceById
(
$result
->
id
,
'available'
));
$account
->
setPendingBalance
(
$this
->
getBalanceById
(
$result
->
id
,
'pending'
));
return
$account
;
}
catch
(
Stripe\Error\Permission
$e
)
{
throw
new
\Exception
(
$e
->
getMessage
());
}
catch
(
\Exception
$e
)
{
throw
new
\Exception
(
$e
->
getMessage
());
}
...
...
@@ -256,6 +313,20 @@ class Manager
return
$this
->
getByAccountId
(
$merchant
[
'id'
]);
}
/**
* Get balance by ID
* @param string $id
* @return Balance
*/
public
function
getBalanceById
(
string
$id
,
string
$type
)
:
Balance
{
$stripeBalance
=
$this
->
balanceInstance
->
retrieve
([
'stripe_account'
=>
$id
]);
$balance
=
new
Balance
();
$balance
->
setAmount
(
$stripeBalance
->
$type
[
0
]
->
amount
)
->
setCurrency
(
$stripeBalance
->
$type
[
0
]
->
currency
);
return
$balance
;
}
/**
* Delete a merchant accont
* @param Account $account
...
...
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Instances/BalanceInstance.php
0 → 100644
View file @
209a5da9
<?php
namespace
Minds\Core\Payments\Stripe\Instances
;
use
Minds\Common\StaticToInstance
;
use
Minds\Core\Config\Config
;
use
Minds\Core\Di\Di
;
/**
* @method BalanceInstance create()
* @method BalanceInstance retrieve()
*/
class
BalanceInstance
extends
StaticToInstance
{
public
function
__construct
(
Config
$config
=
null
)
{
$config
=
$config
??
Di
::
_
()
->
get
(
'Config'
);
\Stripe\Stripe
::
setApiKey
(
$config
->
get
(
'payments'
)[
'stripe'
][
'api_key'
]);
$this
->
setClass
(
new
\Stripe\Balance
);
}
}
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Instances/ChargeInstance.php
0 → 100644
View file @
209a5da9
<?php
namespace
Minds\Core\Payments\Stripe\Instances
;
use
Minds\Common\StaticToInstance
;
use
Minds\Core\Config\Config
;
use
Minds\Core\Di\Di
;
/**
* @method ChargeInstance retrieve()
*/
class
ChargeInstance
extends
StaticToInstance
{
public
function
__construct
(
Config
$config
=
null
)
{
$config
=
$config
??
Di
::
_
()
->
get
(
'Config'
);
\Stripe\Stripe
::
setApiKey
(
$config
->
get
(
'payments'
)[
'stripe'
][
'api_key'
]);
$this
->
setClass
(
new
\Stripe\Charge
);
}
}
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Instances/FileInstance.php
0 → 100644
View file @
209a5da9
<?php
namespace
Minds\Core\Payments\Stripe\Instances
;
use
Minds\Common\StaticToInstance
;
use
Minds\Core\Config\Config
;
use
Minds\Core\Di\Di
;
/**
* @method FileInstance create()
*/
class
FileInstance
extends
StaticToInstance
{
public
function
__construct
(
Config
$config
=
null
)
{
$config
=
$config
??
Di
::
_
()
->
get
(
'Config'
);
\Stripe\Stripe
::
setApiKey
(
$config
->
get
(
'payments'
)[
'stripe'
][
'api_key'
]);
$this
->
setClass
(
new
\Stripe\File
);
}
}
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Instances/TransferInstance.php
0 → 100644
View file @
209a5da9
<?php
namespace
Minds\Core\Payments\Stripe\Instances
;
use
Minds\Common\StaticToInstance
;
use
Minds\Core\Config\Config
;
use
Minds\Core\Di\Di
;
/**
* @method TransferInstance all()
*/
class
TransferInstance
extends
StaticToInstance
{
public
function
__construct
(
Config
$config
=
null
)
{
$config
=
$config
??
Di
::
_
()
->
get
(
'Config'
);
\Stripe\Stripe
::
setApiKey
(
$config
->
get
(
'payments'
)[
'stripe'
][
'api_key'
]);
$this
->
setClass
(
new
\Stripe\Transfer
);
}
}
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Intents/Manager.php
View file @
209a5da9
...
...
@@ -63,6 +63,9 @@ class Manager
'transfer_data'
=>
[
'destination'
=>
$intent
->
getStripeAccountId
(),
],
'metadata'
=>
[
'user_guid'
=>
$intent
->
getUserGuid
(),
],
];
if
(
$intent
->
getServiceFee
())
{
...
...
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Transactions/Manager.php
0 → 100644
View file @
209a5da9
<?php
namespace
Minds\Core\Payments\Stripe\Transactions
;
use
Minds\Core\Payments\Stripe\Connect\Account
;
use
Minds\Core\Payments\Stripe\Instances\TransferInstance
;
use
Minds\Core\Payments\Stripe\Instances\ChargeInstance
;
use
Minds\Core\Di\Di
;
use
Minds\Common\Repository\Response
;
class
Manager
{
/** @var EntitiesBuilder $entitiesBuilder */
private
$entitiesBuilder
;
/** @var TransferInstance $transferInstance */
private
$transferInstance
;
/** @var ChargeInstance $chargeInstance */
private
$chargeInstance
;
public
function
__construct
(
$entitiesBuilder
=
null
,
$transferInstance
=
null
,
$chargeInstance
=
null
)
{
$this
->
entitiesBuilder
=
$entitiesBuilder
??
Di
::
_
()
->
get
(
'EntitiesBuilder'
);
$this
->
transferInstance
=
$transferInstance
??
new
TransferInstance
();
$this
->
chargeInstance
=
$chargeInstance
??
new
ChargeInstance
();
}
/**
* Return transactions from an account object
* @param Account $account
* @return Response[Transaction]
*/
public
function
getByAccount
(
Account
$account
)
:
Response
{
$transfers
=
$this
->
transferInstance
->
all
([
'destination'
=>
$account
->
getId
()
]);
$response
=
new
Response
();
foreach
(
$transfers
->
autoPagingIterator
()
as
$transfer
)
{
try
{
$payment
=
$this
->
chargeInstance
->
retrieve
(
$transfer
->
source_transaction
);
}
catch
(
\Exception
$e
)
{
continue
;
}
$transaction
=
new
Transaction
();
$transaction
->
setId
(
$transfer
->
id
)
->
setTimestamp
(
$transfer
->
created
)
->
setGross
(
$payment
->
amount
)
->
setFees
(
0
)
->
setNet
(
$transfer
->
amount
)
->
setCurrency
(
$transfer
->
currency
)
->
setCustomerUserGuid
(
$payment
->
metadata
[
'user_guid'
])
->
setCustomerUser
(
$this
->
entitiesBuilder
->
single
(
$payment
->
metadata
[
'user_guid'
]));
$response
[]
=
$transaction
;
}
return
$response
;
}
}
This diff is collapsed.
Click to expand it.
Core/Payments/Stripe/Transactions/Transaction.php
0 → 100644
View file @
209a5da9
<?php
namespace
Minds\Core\Payments\Stripe\Transactions
;
use
Minds\Entities\User
;
use
Minds\Traits\MagicAttributes
;
class
Transaction
{
use
MagicAttributes
;
/** @var string $id */
private
$id
;
/** @var int $timestamp */
private
$timestamp
;
/** @var int $gross */
private
$gross
;
/** @var string $currency */
private
$currency
;
/** @var int $fees */
private
$fees
;
/** @var int $net */
private
$net
;
/** @var string $customerGuid */
private
$customerUserGuid
;
/** @var User $customerUser */
private
$customerUser
;
/**
* Expose to the public apis
* @param array $extend
* @return array
*/
public
function
export
(
array
$extend
=
[])
:
array
{
return
[
'id'
=>
$this
->
id
,
'timestamp'
=>
$this
->
timestamp
,
'gross'
=>
$this
->
gross
,
'currency'
=>
$this
->
currency
,
'fees'
=>
$this
->
fees
,
'net'
=>
$this
->
net
,
'customer_user_guid'
=>
$this
->
userGuid
,
'customer_user'
=>
$this
->
customerUser
?
$this
->
customerUser
->
export
()
:
null
,
];
}
}
This diff is collapsed.
Click to expand it.
Core/Permissions/Delegates/ChannelRoleCalculator.php
View file @
209a5da9
...
...
@@ -4,6 +4,7 @@ namespace Minds\Core\Permissions\Delegates;
use
Minds\Traits\MagicAttributes
;
use
Minds\Core\Permissions\Roles\Roles
;
use
Minds\Core\Permissions\Roles\Role
;
class
ChannelRoleCalculator
extends
BaseRoleCalculator
{
...
...
@@ -20,7 +21,7 @@ class ChannelRoleCalculator extends BaseRoleCalculator
*
* @return Role
*/
public
function
calculate
(
$entity
)
public
function
calculate
(
$entity
)
:
Role
{
if
(
isset
(
$this
->
channels
[
$entity
->
getOwnerGuid
()]))
{
return
$this
->
channels
[
$entity
->
getOwnerGuid
()];
...
...
This diff is collapsed.
Click to expand it.
Core/Permissions/Delegates/GroupRoleCalculator.php
View file @
209a5da9
...
...
@@ -4,9 +4,10 @@ namespace Minds\Core\Permissions\Delegates;
use
Minds\Traits\MagicAttributes
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Permissions\Roles\Role
s
;
use
Minds\Core\Permissions\Roles\Role
;
use
Minds\Core\EntitiesBuilder
;
use
Minds\Entities\User
;
use
Minds\Core\Permissions\Roles\Roles
;
class
GroupRoleCalculator
extends
BaseRoleCalculator
{
...
...
@@ -32,7 +33,7 @@ class GroupRoleCalculator extends BaseRoleCalculator
*
* @return Role
*/
public
function
calculate
(
$entity
)
public
function
calculate
(
$entity
)
:
Role
{
if
(
isset
(
$this
->
groups
[
$entity
->
getAccessId
()]))
{
return
$this
->
groups
[
$entity
->
getAccessId
()];
...
...
This diff is collapsed.
Click to expand it.
Core/Permissions/Entities/Manager.php
View file @
209a5da9
...
...
@@ -31,11 +31,12 @@ class Manager
}
/**
* Save permissions for an entity and propegate it to linked objects
* @param mixed $entity a minds entity that implements the save function
* @param Permissions $permissions the flag to apply to the entity
*/
public
function
save
(
$entity
,
EntityPermissions
$permissions
)
* Save permissions for an entity and propegate it to linked objects.
*
* @param mixed $entity a minds entity that implements the save function
* @param Permissions $permissions the flag to apply to the entity
*/
public
function
save
(
$entity
,
EntityPermissions
$permissions
)
:
void
{
$entity
->
setAllowComments
(
$permissions
->
getAllowComments
());
...
...
This diff is collapsed.
Click to expand it.
Core/Permissions/Manager.php
View file @
209a5da9
...
...
@@ -5,6 +5,7 @@ namespace Minds\Core\Permissions;
use
Minds\Core\Di\Di
;
use
Minds\Core\Permissions\Permissions
;
use
Minds\Core\EntitiesBuilder
;
use
Minds\Core\Permissions\Roles\Roles
;
/*
* Manager for managing role based permissions
...
...
@@ -23,13 +24,14 @@ class Manager
* Takes a user_guid and list of entity guids
* Builds up a permissions object
* Permissions contains the user's role per entity, channel and group
*
* @param array $opts
* - user_guid: long, the user's guid for calculating permissions
* - guids: array long, the list of entities to permit
*
- entities: fetched objects to permit
*
- user_guid: long, the user's guid for calculating permissions
*
- guids: array long, the list of entities to permit
*
* @return Permissions A map of channels, groups and entities with the user's role for each
*/
public
function
getList
(
array
$opts
=
[])
public
function
getList
(
array
$opts
=
[])
:
Permissions
{
$opts
=
array_merge
([
'user_guid'
=>
null
,
...
...
@@ -49,8 +51,10 @@ class Manager
$entities
=
$this
->
entitiesBuilder
->
get
(
$opts
);
$entities
=
array_merge
(
$entities
,
$opts
[
'entities'
]);
$roles
=
new
Roles
();
/** @var Permissions */
$permissions
=
new
Permissions
(
$user
,
null
,
$entitiesBuilder
);
$permissions
=
new
Permissions
(
$user
,
$roles
,
$entitiesBuilder
);
if
(
is_array
(
$entities
))
{
$permissions
->
calculate
(
$entities
);
}
...
...
This diff is collapsed.
Click to expand it.
Core/Permissions/Permissions.php
View file @
209a5da9
...
...
@@ -6,6 +6,7 @@ use Minds\Traits\MagicAttributes;
use
Minds\Entities\User
;
use
Minds\Core\EntitiesBuilder
;
use
Minds\Core\Permissions\Roles\Roles
;
use
Minds\Core\Permissions\Roles\Role
;
use
Minds\Core\Permissions\Delegates\ChannelRoleCalculator
;
use
Minds\Core\Permissions\Delegates\GroupRoleCalculator
;
use
Minds\Common\Access
;
...
...
@@ -33,11 +34,6 @@ class Permissions implements \JsonSerializable
/** @var EntitiesBuilder */
private
$entitiesBuilder
;
public
function
setUser
(
User
$user
=
null
)
{
throw
new
ImmutableException
(
'User can only be set in the constructor'
);
}
public
function
__construct
(
User
$user
=
null
,
Roles
$roles
=
null
,
EntitiesBuilder
$entitiesBuilder
=
null
)
{
$this
->
groups
=
[];
...
...
@@ -51,10 +47,22 @@ class Permissions implements \JsonSerializable
$this
->
channels
[
$user
->
getGuid
()]
=
$user
;
}
$this
->
entitiesBuilder
=
$entitiesBuilder
?:
Di
::
_
()
->
get
(
'EntitiesBuilder'
);
$this
->
channels
[
$user
->
getGUID
()]
=
$user
;
$this
->
channelRoleCalculator
=
new
ChannelRoleCalculator
(
$this
->
user
,
$this
->
roles
);
$this
->
groupRoleCalculator
=
new
GroupRoleCalculator
(
$this
->
user
,
$this
->
roles
,
$entitiesBuilder
);
}
/**
* Permissions are user aware. This bomb function is to keep the user from being changed after instantiation.
*
* @throws ImmutableException
*/
public
function
setUser
(
User
$user
)
:
void
{
throw
new
ImmutableException
(
'User can only be set in the constructor'
);
}
/**
* Takes an array of entities and checks their permissions
* Builds up collections of permissions based on the user's relationships to the entity
...
...
@@ -64,14 +72,14 @@ class Permissions implements \JsonSerializable
*
* @param array entities an array of entities for calculating permissions
*/
public
function
calculate
(
array
$entities
=
[])
public
function
calculate
(
array
$entities
=
[])
:
void
{
foreach
(
$entities
as
$entity
)
{
$this
->
entities
[
$entity
->
getGuid
()]
=
$this
->
getRoleForEntity
(
$entity
);
}
}
private
function
getRoleForEntity
(
$entity
)
private
function
getRoleForEntity
(
$entity
)
:
Role
{
$role
=
null
;
...
...
@@ -104,7 +112,7 @@ class Permissions implements \JsonSerializable
*
* @return array serialized objects
*/
public
function
export
()
public
function
export
()
:
array
{
$export
=
[];
if
(
$this
->
user
)
{
...
...
@@ -120,7 +128,7 @@ class Permissions implements \JsonSerializable
/**
* @return array channel guids with the user's role
*/
public
function
getChannels
()
public
function
getChannels
()
:
array
{
return
$this
->
channelRoleCalculator
->
getChannels
();
}
...
...
@@ -128,7 +136,7 @@ class Permissions implements \JsonSerializable
/**
* @return array group guids with the user's role
*/
public
function
getGroups
()
public
function
getGroups
()
:
array
{
return
$this
->
groupRoleCalculator
->
getGroups
();
}
...
...
@@ -136,7 +144,7 @@ class Permissions implements \JsonSerializable
/**
* @return array serialized objects
*/
public
function
jsonSerialize
()
public
function
jsonSerialize
()
:
array
{
return
$this
->
export
();
}
...
...
This diff is collapsed.
Click to expand it.
Core/Permissions/Roles/BaseRole.php
View file @
209a5da9
...
...
@@ -3,10 +3,11 @@
namespace
Minds\Core\Permissions\Roles
;
use
Zend\Permissions\Rbac
;
use
Minds\Core\Permissions\Roles\Role
;
abstract
class
BaseRole
extends
Rbac\Role
implements
\JsonSerializable
abstract
class
BaseRole
extends
Rbac\Role
implements
\JsonSerializable
,
Role
{
public
function
export
()
public
function
export
()
:
array
{
$export
=
[];
$export
[
'name'
]
=
$this
->
getName
();
...
...
@@ -15,7 +16,7 @@ abstract class BaseRole extends Rbac\Role implements \JsonSerializable
return
$export
;
}
public
function
jsonSerialize
()
public
function
jsonSerialize
()
:
array
{
return
$this
->
export
();
}
...
...
This diff is collapsed.
Click to expand it.
Core/Permissions/Roles/Role.php
0 → 100644
View file @
209a5da9
<?php
namespace
Minds\Core\Permissions\Roles
;
interface
Role
{
public
function
export
();
}
This diff is collapsed.
Click to expand it.
Core/Security/Events.php
View file @
209a5da9
...
...
@@ -170,6 +170,7 @@ class Events
'xn--90aizihgi.xn--p1ai'
,
'tinyurl.com'
,
'bit.ly'
,
'bit.do'
,
'123football.space'
,
'bitly.com'
,
'j.mp'
,
...
...
This diff is collapsed.
Click to expand it.
Core/Security/Spam.php
View file @
209a5da9
...
...
@@ -187,6 +187,7 @@ class Spam
'xn--90aizihgi.xn--p1ai'
,
'tinyurl.com'
,
'bit.ly'
,
'bit.do'
,
'123football.space'
,
'bitly.com'
,
'j.mp'
,
...
...
This diff is collapsed.
Click to expand it.
Core/Wire/Manager.php
View file @
209a5da9
...
...
@@ -266,6 +266,9 @@ class Manager
throw
new
\Exception
(
"Not implemented ETH yet"
);
break
;
case
'usd'
:
if
(
!
$this
->
receiver
->
getMerchant
()
||
!
$this
->
receiver
->
getMerchant
()[
'id'
])
{
throw
new
\Exception
(
"This channel is not able to receive USD at the moment"
);
}
$intent
=
new
PaymentIntent
();
$intent
->
setUserGuid
(
$this
->
sender
->
getGuid
())
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Feeds/Top/ManagerSpec.php
View file @
209a5da9
...
...
@@ -12,6 +12,7 @@ use Minds\Entities\Entity;
use
PhpSpec\Exception\Example\FailureException
;
use
PhpSpec\ObjectBehavior
;
use
Prophecy\Argument
;
use
Minds\Common\Access
;
class
ManagerSpec
extends
ObjectBehavior
{
...
...
@@ -50,6 +51,10 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
5000
);
$scoredGuid1
->
getAccessId
()
->
shouldBeCalled
()
->
willReturn
(
Access
::
PUBLIC
);
$scoredGuid1
->
getScore
()
->
shouldBeCalled
()
->
willReturn
(
500
);
...
...
@@ -70,6 +75,10 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
5000
);
$entity1
->
getAccessId
()
->
shouldBeCalled
()
->
willReturn
(
Access
::
PUBLIC
);
$entity1
->
getOwnerGUID
()
->
shouldBeCalled
()
->
willReturn
(
1000
);
...
...
@@ -82,6 +91,10 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
5001
);
$scoredGuid2
->
getAccessId
()
->
shouldBeCalled
()
->
willReturn
(
Access
::
PUBLIC
);
$scoredGuid2
->
getScore
()
->
shouldBeCalled
()
->
willReturn
(
800
);
...
...
@@ -102,6 +115,10 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
5001
);
$entity2
->
getAccessId
()
->
shouldBeCalled
()
->
willReturn
(
Access
::
PUBLIC
);
$entity2
->
getOwnerGUID
()
->
shouldBeCalled
()
->
willReturn
(
1001
);
...
...
@@ -138,6 +155,10 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
5000
);
$scoredGuid1
->
getAccessId
()
->
shouldBeCalled
()
->
willReturn
(
Access
::
PUBLIC
);
$scoredGuid1
->
getScore
()
->
shouldBeCalled
()
->
willReturn
(
500
);
...
...
@@ -158,6 +179,10 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
5000
);
$entity1
->
getAccessId
()
->
shouldBeCalled
()
->
willReturn
(
Access
::
PUBLIC
);
$entity1
->
getOwnerGUID
()
->
shouldBeCalled
()
->
willReturn
(
1000
);
...
...
@@ -170,6 +195,11 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
5001
);
$scoredGuid2
->
getAccessId
()
->
shouldBeCalled
()
->
willReturn
(
Access
::
PUBLIC
);
$scoredGuid2
->
getScore
()
->
shouldBeCalled
()
->
willReturn
(
800
);
...
...
@@ -190,6 +220,11 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
5001
);
$entity2
->
getAccessId
()
->
shouldBeCalled
()
->
willReturn
(
Access
::
PUBLIC
);
$entity2
->
getOwnerGUID
()
->
shouldBeCalled
()
->
willReturn
(
1001
);
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Feeds/Top/RepositorySpec.php
View file @
209a5da9
...
...
@@ -9,6 +9,7 @@ use Minds\Core\Feeds\Top\MetricsSync;
use
Minds\Core\Feeds\Top\Repository
;
use
PhpSpec\ObjectBehavior
;
use
Prophecy\Argument
;
use
Minds\Common\Access
;
class
RepositorySpec
extends
ObjectBehavior
{
...
...
@@ -52,6 +53,7 @@ class RepositorySpec extends ObjectBehavior
[
'_source'
=>
[
'guid'
=>
'1'
,
'access_id'
=>
Access
::
PUBLIC
,
'owner_guid'
=>
'1000'
,
'time_created'
=>
1
,
'@timestamp'
=>
1000
,
...
...
@@ -62,6 +64,7 @@ class RepositorySpec extends ObjectBehavior
[
'_source'
=>
[
'guid'
=>
'2'
,
'access_id'
=>
Access
::
PUBLIC
,
'owner_guid'
=>
'1000'
,
'time_created'
=>
1
,
'@timestamp'
=>
1000
,
...
...
@@ -102,6 +105,7 @@ class RepositorySpec extends ObjectBehavior
[
'_source'
=>
[
'guid'
=>
'1'
,
'access_id'
=>
Access
::
PUBLIC
,
'owner_guid'
=>
'1'
,
'time_created'
=>
1
,
'@timestamp'
=>
1000
,
...
...
@@ -112,6 +116,7 @@ class RepositorySpec extends ObjectBehavior
[
'_source'
=>
[
'guid'
=>
'2'
,
'access_id'
=>
Access
::
PUBLIC
,
'owner_guid'
=>
'2'
,
'time_created'
=>
2
,
'@timestamp'
=>
2000
,
...
...
@@ -152,6 +157,7 @@ class RepositorySpec extends ObjectBehavior
[
'_source'
=>
[
'guid'
=>
'1'
,
'access_id'
=>
Access
::
PUBLIC
,
'owner_guid'
=>
'1000'
,
'time_created'
=>
1
,
'@timestamp'
=>
1000
,
...
...
@@ -163,6 +169,7 @@ class RepositorySpec extends ObjectBehavior
[
'_source'
=>
[
'guid'
=>
'2'
,
'access_id'
=>
Access
::
PUBLIC
,
'owner_guid'
=>
'1001'
,
'time_created'
=>
2
,
'@timestamp'
=>
2000
,
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Payments/Stripe/Connect/ManagerSpec.php
View file @
209a5da9
...
...
@@ -7,6 +7,8 @@ use Minds\Core\Payments\Stripe\Connect\Account;
use
Minds\Core\Entities\Actions\Save
;
use
Minds\Core\Payments\Stripe\Connect\Delegates\NotificationDelegate
;
use
Minds\Core\Payments\Stripe\Instances\AccountInstance
;
use
Minds\Core\Payments\Stripe\Instances\BalanceInstance
;
use
Minds\Core\Payments\Stripe\Instances\FileInstance
;
use
Minds\Entities\User
;
use
PhpSpec\ObjectBehavior
;
use
Prophecy\Argument
;
...
...
@@ -16,13 +18,17 @@ class ManagerSpec extends ObjectBehavior
private
$save
;
private
$notificationDelegate
;
private
$accountInstance
;
private
$balanceInstance
;
private
$fileInstance
;
public
function
let
(
Save
$save
,
NotificationDelegate
$notificationDelegate
,
AccountInstance
$accountInstance
)
public
function
let
(
Save
$save
,
NotificationDelegate
$notificationDelegate
,
AccountInstance
$accountInstance
,
BalanceInstance
$balanceInstance
,
FileInstance
$fileInstance
)
{
$this
->
beConstructedWith
(
$save
,
$notificationDelegate
,
$accountInstance
);
$this
->
beConstructedWith
(
$save
,
$notificationDelegate
,
$accountInstance
,
$balanceInstance
,
$fileInstance
);
$this
->
save
=
$save
;
$this
->
notificationDelegate
=
$notificationDelegate
;
$this
->
accountInstance
=
$accountInstance
;
$this
->
balanceInstance
=
$balanceInstance
;
$this
->
fileInstance
=
$fileInstance
;
}
public
function
it_is_initializable
()
...
...
@@ -126,6 +132,31 @@ class ManagerSpec extends ObjectBehavior
'verification'
=>
(
object
)
[
'disabled_reason'
=>
null
,
],
'settings'
=>
(
object
)
[
'payouts'
=>
(
object
)
[
'schedule'
=>
(
object
)
[
'interval'
=>
1
,
'delay_days'
=>
2
,
'monthly_anchor'
=>
31
,
],
],
],
]);
$this
->
balanceInstance
->
retrieve
([
'stripe_account'
=>
'acc_123'
])
->
willReturn
((
object
)
[
'pending'
=>
[
(
object
)
[
'amount'
=>
100
,
'currency'
=>
'GBP'
,
],
],
'available'
=>
[
(
object
)
[
'amount'
=>
100
,
'currency'
=>
'GBP'
,
],
],
]);
$account
=
$this
->
getByAccountId
(
'acc_123'
);
...
...
@@ -181,6 +212,31 @@ class ManagerSpec extends ObjectBehavior
'verification'
=>
(
object
)
[
'disabled_reason'
=>
null
,
],
'settings'
=>
(
object
)
[
'payouts'
=>
(
object
)
[
'schedule'
=>
(
object
)
[
'interval'
=>
1
,
'delay_days'
=>
2
,
'monthly_anchor'
=>
31
,
]
]
]
]);
$this
->
balanceInstance
->
retrieve
([
'stripe_account'
=>
'acc_123'
])
->
willReturn
((
object
)
[
'pending'
=>
[
(
object
)
[
'amount'
=>
100
,
'currency'
=>
'GBP'
,
],
],
'available'
=>
[
(
object
)
[
'amount'
=>
100
,
'currency'
=>
'GBP'
,
],
],
]);
$user
=
new
User
();
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Permissions/ManagerSpec.php
0 → 100644
View file @
209a5da9
<?php
namespace
Spec\Minds\Core\Permissions
;
use
Minds\Core\Permissions\Permissions
;
use
Minds\Core\Permissions\Roles\Roles
;
use
Minds\Entities\User
;
use
Minds\Entities\Activity
;
use
Minds\Entities\Group
;
use
Minds\Core\EntitiesBuilder
;
use
PhpSpec\ObjectBehavior
;
use
Prophecy\Prophet
;
use
Minds\Common\Access
;
use
Minds\Exceptions\ImmutableException
;
class
PermissionsSpec
extends
ObjectBehavior
{
/** @var EntitiesBuilder */
private
$entitiesBuilder
;
public
function
let
(
EntitiesBuilder
$entitiesBuilder
)
{
$this
->
entitiesBuilder
=
$entitiesBuilder
;
$this
->
beConstructedWith
(
$this
->
user
,
null
,
$this
->
entitiesBuilder
);
}
public
function
it_should_except_with_no_user
()
{
$this
->
shouldThrow
(
new
InvalidArgumentException
(
'Entity is not a user'
))
->
duringGetList
();
}
}
This diff is collapsed.
Click to expand it.
Spec/Core/Permissions/PermissionsSpec.php
View file @
209a5da9
...
...
@@ -299,28 +299,28 @@ class PermissionsSpec extends ObjectBehavior
$activity
=
$prophet
->
prophesize
(
Activity
::
class
);
$activity
->
getGUID
()
->
willReturn
(
10
);
$activity
->
getOwnerGUID
()
->
willReturn
(
1
);
$activity
->
getAccessI
D
()
->
willReturn
(
Access
::
PUBLIC
);
$activity
->
getAccessI
d
()
->
willReturn
(
Access
::
PUBLIC
);
$entities
[]
=
$activity
;
//Mock subscriber channel activity
$activity
=
$prophet
->
prophesize
(
Activity
::
class
);
$activity
->
getGUID
()
->
willReturn
(
11
);
$activity
->
getOwnerGUID
()
->
willReturn
(
2
);
$activity
->
getAccessI
D
()
->
willReturn
(
Access
::
PUBLIC
);
$activity
->
getAccessI
d
()
->
willReturn
(
Access
::
PUBLIC
);
$entities
[]
=
$activity
;
//Mock non-subscriber channel activity
$activity
=
$prophet
->
prophesize
(
Activity
::
class
);
$activity
->
getGUID
()
->
willReturn
(
12
);
$activity
->
getOwnerGUID
()
->
willReturn
(
3
);
$activity
->
getAccessI
D
()
->
willReturn
(
Access
::
PUBLIC
);
$activity
->
getAccessI
d
()
->
willReturn
(
Access
::
PUBLIC
);
$entities
[]
=
$activity
;
//Mock group activity
$activity
=
$prophet
->
prophesize
(
Activity
::
class
);
$activity
->
getGUID
()
->
willReturn
(
13
);
$activity
->
getOwnerGUID
()
->
willReturn
(
1
);
$activity
->
getAccessI
D
()
->
willReturn
(
100
);
$activity
->
getAccessI
d
()
->
willReturn
(
100
);
$entities
[]
=
$activity
;
return
$entities
;
...
...
This diff is collapsed.
Click to expand it.
classes/ElggEntity.php
View file @
209a5da9
This diff is collapsed.
Click to expand it.
tools/setup.sh
View file @
209a5da9
...
...
@@ -5,7 +5,7 @@ rm -rf ../vendor
# Setup composer
php
-r
"copy('https://getcomposer.org/installer', 'composer-setup.php');"
php
-r
"if (hash_file('SHA384', 'composer-setup.php') === '
48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5
') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php
-r
"if (hash_file('SHA384', 'composer-setup.php') === '
a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1
') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php
-r
"unlink('composer-setup.php');"
...
...
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