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
215
Issues
215
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
Compare Revisions
78cfd1bc2e22c65e743f41f71970a57d5e145271...5b753d1c3f24f054fb97858cfe83500c2247e14b
Source
5b753d1c3f24f054fb97858cfe83500c2247e14b
Select Git revision
...
Target
78cfd1bc2e22c65e743f41f71970a57d5e145271
Select Git revision
Compare
Commits (2)
(feat): wire emails support multiple currencies
· aaa7ba14
Olivia Madrid
authored
3 weeks ago
Conflicts: Core/Email/Campaigns/WireSent.php
aaa7ba14
(feat): btc support
· 5b753d1c
Mark Harding
authored
2 hours ago
5b753d1c
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
211 additions
and
16 deletions
+211
-16
btc.php
Controllers/api/v2/wallet/btc.php
+71
-0
wire-received.tpl
Core/Email/Campaigns/Templates/wire-received.tpl
+3
-3
wire-sent.tpl
Core/Email/Campaigns/Templates/wire-sent.tpl
+3
-3
WireReceived.php
Core/Email/Campaigns/WireReceived.php
+18
-2
WireSent.php
Core/Email/Campaigns/WireSent.php
+22
-1
WireNotification.php
Core/Queue/Runners/WireNotification.php
+1
-1
User.php
Entities/User.php
+23
-1
WireReceivedSpec.php
Spec/Core/Email/Campaigns/WireReceivedSpec.php
+70
-5
No files found.
Controllers/api/v2/wallet/btc.php
0 → 100644
View file @
5b753d1c
<?php
/**
* BTC Wallet Controller
*
* @version 1
* @author Mark Harding
*/
namespace
Minds\Controllers\api\v2\wallet
;
use
Minds\Core
;
use
Minds\Core\Entities\Actions
;
use
Minds\Helpers
;
use
Minds\Interfaces
;
use
Minds\Api\Factory
;
use
Minds\Core\Payments
;
use
Minds\Entities
;
class
btc
implements
Interfaces\Api
{
/**
* Returns merchant information
* @param array $pages
*
* API:: /v1/merchant/:slug
*/
public
function
get
(
$pages
)
{
Factory
::
isLoggedIn
();
$response
=
[];
switch
(
$pages
[
0
])
{
case
"address"
:
$response
[
'address'
]
=
Core\Session
::
getLoggedInUser
()
->
getBtcAddress
();
break
;
}
return
Factory
::
response
(
$response
);
}
public
function
post
(
$pages
)
{
Factory
::
isLoggedIn
();
$response
=
[];
$user
=
Core\Session
::
getLoggedInUser
();
$save
=
new
Actions\Save
();
switch
(
$pages
[
0
])
{
case
"address"
:
$user
->
setBtcAddress
(
$_POST
[
'address'
]);
$save
->
setEntity
(
$user
)
->
save
();
break
;
}
return
Factory
::
response
(
$response
);
}
public
function
put
(
$pages
)
{
return
Factory
::
response
(
array
());
}
public
function
delete
(
$pages
)
{
return
Factory
::
response
(
array
());
}
}
This diff is collapsed.
Click to expand it.
Core/Email/Campaigns/Templates/wire-received.tpl
View file @
5b753d1c
<
?
php
$
wireUrl =
"
{
$vars
[
'site_url'
]
}
wallet/tokens/transactions/
{
$vars
[
'contract'
]
}
?
{
$vars
[
'tracking'
]
}
"
;
$
avatarUrl =
"
{
$vars
[
'sender'
]->
getIconUrl
()
}
"
;
$
wireDate =
date('M
d
,
Y
',
($
vars
['
timestamp
']));
$
wireDate =
date('M
d
,
Y
',
($
vars
['
timestamp
']));
$
amount =
number_format($vars['amount'],
2
);
?
>
<table
cellspacing=
"8"
cellpadding=
"8"
border=
"0"
width=
"600"
align=
"center"
>
...
...
@@ -19,7 +19,7 @@
<h4
<?
php
echo
$
emailStyles-
>
getStyles('m-clear', 'm-fonts', 'm-header'); ?>>@
<?php echo $vars['sender']->get('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 ?>
tokens
<?php echo $wireDate; ?>
; +
<?php echo $amount ?>
</p>
</td>
</tr>
...
...
@@ -36,7 +36,7 @@
<tr>
<td>
<p
<?
php
echo
$
emailStyles-
>
getStyles('m-clear', 'm-fonts'); ?>>
For any issues, including the recipient not receiving t
okens
, please contact us at
<a
href=
"mailto:info@minds.com"
>
info@minds.com
</a>
.
For any issues, including the recipient not receiving t
heir wire
, please contact us at
<a
href=
"mailto:info@minds.com"
>
info@minds.com
</a>
.
</p>
</td>
</tr>
...
...
This diff is collapsed.
Click to expand it.
Core/Email/Campaigns/Templates/wire-sent.tpl
View file @
5b753d1c
<
?
php
$
wireUrl =
"
{
$vars
[
'site_url'
]
}
wallet/tokens/transactions/
{
$vars
[
'contract'
]
}
?
{
$vars
[
'tracking'
]
}
"
;
$
avatarUrl =
"
{
$vars
[
'receiver'
]->
getIconUrl
()
}
"
;
$
wireDate =
date('M
d
,
Y
',
($
vars
['
timestamp
']));
$
wireDate =
date('M
d
,
Y
',
($
vars
['
timestamp
']));
$
amount =
number_format($vars['amount'],
2
);
?
>
<table
cellspacing=
"8"
cellpadding=
"8"
border=
"0"
width=
"600"
align=
"center"
>
...
...
@@ -19,7 +19,7 @@
<h4
<?
php
echo
$
emailStyles-
>
getStyles('m-clear', 'm-fonts', 'm-header'); ?>>You wired @
<?php echo $vars['receiver']->get('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 ?>
tokens
<?php echo $wireDate; ?>
; +
<?php echo $amount ?>
</p>
</td>
</tr>
...
...
@@ -36,7 +36,7 @@
<tr>
<td>
<p
<?
php
echo
$
emailStyles-
>
getStyles('m-clear', 'm-fonts'); ?>>
For any issues, including the recipient not receiving t
okens
, please contact us at
<a
href=
"mailto:info@minds.com"
>
info@minds.com
</a>
.
For any issues, including the recipient not receiving t
heir wire
, please contact us at
<a
href=
"mailto:info@minds.com"
>
info@minds.com
</a>
.
</p>
</td>
</tr>
...
...
This diff is collapsed.
Click to expand it.
Core/Email/Campaigns/WireReceived.php
View file @
5b753d1c
...
...
@@ -40,7 +40,6 @@ class WireReceived extends EmailCampaign
];
$timestamp
=
gettype
(
$this
->
wire
->
getTimestamp
())
===
'object'
?
$this
->
wire
->
getTimestamp
()
->
time
()
:
$this
->
wire
->
getTimestamp
();
$amount
=
$this
->
wire
->
getMethod
()
===
'tokens'
?
BigNumber
::
fromPlain
(
$this
->
wire
->
getAmount
(),
18
)
->
toDouble
()
:
$this
->
wire
->
getAmount
();
$contract
=
$this
->
wire
->
getMethod
()
===
'onchain'
?
'wire'
:
'offchain:wire'
;
$this
->
template
->
setTemplate
(
'default.tpl'
);
...
...
@@ -50,7 +49,7 @@ class WireReceived extends EmailCampaign
$this
->
template
->
set
(
'email'
,
$this
->
user
->
getEmail
());
$this
->
template
->
set
(
'guid'
,
$this
->
user
->
getGUID
());
$this
->
template
->
set
(
'timestamp'
,
$timestamp
);
$this
->
template
->
set
(
'amount'
,
$
amount
);
$this
->
template
->
set
(
'amount'
,
$
this
->
getAmountString
(
$this
->
wire
)
);
$this
->
template
->
set
(
'sender'
,
$this
->
wire
->
getSender
());
$this
->
template
->
set
(
'contract'
,
$contract
);
$this
->
template
->
set
(
'campaign'
,
$this
->
campaign
);
...
...
@@ -73,4 +72,21 @@ class WireReceived extends EmailCampaign
$this
->
mailer
->
queue
(
$this
->
build
());
}
}
private
function
getAmountString
(
$wire
)
{
$amount
=
$wire
->
getAmount
();
if
(
$wire
->
getMethod
()
===
'tokens'
)
{
$amount
=
BigNumber
::
fromPlain
(
$wire
->
getAmount
(),
18
)
->
toDouble
();
$currency
=
$amount
===
1
?
'token'
:
'tokens'
;
}
else
{
$currency
=
strtoupper
(
$wire
->
getMethod
());
}
if
(
$wire
->
getMethod
()
===
'usd'
)
{
$amount
=
$amount
/
100
;
}
return
"
$amount
$currency
"
;
}
}
This diff is collapsed.
Click to expand it.
Core/Email/Campaigns/WireSent.php
View file @
5b753d1c
...
...
@@ -41,6 +41,7 @@ class WireSent extends EmailCampaign
$timestamp
=
gettype
(
$this
->
wire
->
getTimestamp
())
===
'object'
?
$this
->
wire
->
getTimestamp
()
->
time
()
:
$this
->
wire
->
getTimestamp
();
$amount
=
$this
->
wire
->
getMethod
()
===
'tokens'
?
BigNumber
::
fromPlain
(
$this
->
wire
->
getAmount
(),
18
)
->
toDouble
()
:
$this
->
wire
->
getAmount
();
$contract
=
$this
->
wire
->
getMethod
()
===
'onchain'
?
'wire'
:
'offchain:wire'
;
$this
->
template
->
setTemplate
(
'default.tpl'
);
...
...
@@ -50,7 +51,7 @@ class WireSent extends EmailCampaign
$this
->
template
->
set
(
'email'
,
$this
->
user
->
getEmail
());
$this
->
template
->
set
(
'guid'
,
$this
->
user
->
getGUID
());
$this
->
template
->
set
(
'timestamp'
,
$timestamp
);
$this
->
template
->
set
(
'amount'
,
$
amount
);
$this
->
template
->
set
(
'amount'
,
$
this
->
getAmountString
(
$this
->
wire
)
);
$this
->
template
->
set
(
'receiver'
,
$this
->
wire
->
getReceiver
());
$this
->
template
->
set
(
'sender'
,
$this
->
wire
->
getSender
());
$this
->
template
->
set
(
'contract'
,
$contract
);
...
...
@@ -74,4 +75,24 @@ class WireSent extends EmailCampaign
$this
->
mailer
->
queue
(
$this
->
build
());
}
}
<<<<<<<
HEAD
=======
private
function
getAmountString
(
$wire
)
{
$amount
=
$wire
->
getAmount
();
if
(
$wire
->
getMethod
()
===
'tokens'
)
{
$amount
=
BigNumber
::
fromPlain
(
$wire
->
getAmount
(),
18
)
->
toDouble
();
$currency
=
$amount
===
1
?
'token'
:
'tokens'
;
}
else
{
$currency
=
strtoupper
(
$wire
->
getMethod
());
}
if
(
$wire
->
getMethod
()
===
'usd'
)
{
$amount
=
$amount
/
100
;
}
return
"
$amount
$currency
"
;
}
>>>>>>>
d85a52e
...
(
feat
)
:
wire
emails
support
multiple
currencies
}
This diff is collapsed.
Click to expand it.
Core/Queue/Runners/WireNotification.php
View file @
5b753d1c
...
...
@@ -101,7 +101,7 @@ class WireNotification implements Interfaces\QueueRunner
$amount
=
$wire
->
getAmount
();
if
(
$wire
->
getMethod
()
===
'tokens'
)
{
$amount
=
BigNumber
::
fromPlain
(
$wire
->
getAmount
(),
18
)
->
toDouble
();
$currency
=
$amount
>
1
?
'tokens'
:
'token
'
;
$currency
=
$amount
===
1
?
'token'
:
'tokens
'
;
}
else
{
$currency
=
strtoupper
(
$wire
->
getMethod
());
}
...
...
This diff is collapsed.
Click to expand it.
Entities/User.php
View file @
5b753d1c
...
...
@@ -37,6 +37,7 @@ class User extends \ElggUser
$this
->
attributes
[
'pinned_posts'
]
=
[];
$this
->
attributes
[
'eth_wallet'
]
=
''
;
$this
->
attributes
[
'eth_incentive'
]
=
''
;
$this
->
attributes
[
'btc_address'
]
=
''
;
$this
->
attributes
[
'phone_number'
]
=
null
;
$this
->
attributes
[
'phone_number_hash'
]
=
null
;
$this
->
attributes
[
'icontime'
]
=
time
();
...
...
@@ -990,7 +991,8 @@ class User extends \ElggUser
'canary'
,
'theme'
,
'onchain_booster'
,
'toaster_notifications'
'toaster_notifications'
,
'btc_address'
,
));
}
...
...
@@ -1095,4 +1097,24 @@ class User extends \ElggUser
{
$this
->
toaster_notifications
=
$enabled
?
1
:
0
;
}
/**
* Returns btc_address
* @return string
*/
public
function
getBtcAddress
()
{
return
(
string
)
$this
->
btc_address
;
}
/**
* Set btc_address
* @param string $btc_address
*/
public
function
setBtcAddress
(
$btc_address
)
{
$this
->
btc_address
=
(
string
)
$btc_address
;
return
$this
;
}
}
This diff is collapsed.
Click to expand it.
Spec/Core/Email/Campaigns/WireReceivedSpec.php
View file @
5b753d1c
...
...
@@ -67,6 +67,8 @@ class WireReceivedSpec extends ObjectBehavior
public
function
it_should_send_a_wire_received_email_tokens
()
{
$this
->
wire
->
setMethod
(
'tokens'
);
$this
->
wire
->
setAmount
(
2000000000000000
);
$this
->
getCampaign
()
->
shouldEqual
(
'when'
);
$this
->
getTopic
()
->
shouldEqual
(
'wire_received'
);
$this
->
setUser
(
$this
->
receiver
);
...
...
@@ -79,7 +81,39 @@ class WireReceivedSpec extends ObjectBehavior
$data
[
'guid'
]
->
shouldEqual
(
$this
->
receiverGUID
);
$data
[
'email'
]
->
shouldEqual
(
$this
->
receiverEmail
);
$data
[
'username'
]
->
shouldEqual
(
$this
->
receiverUsername
);
$data
[
'amount'
]
->
shouldEqual
(
BigNumber
::
fromPlain
(
10
,
18
)
->
toDouble
());
$data
[
'amount'
]
->
shouldEqual
(
'0.002 tokens'
);
$this
->
mailer
->
queue
(
Argument
::
any
())
->
shouldBeCalled
();
$testEmailSubscription
=
(
new
EmailSubscription
())
->
setUserGuid
(
$this
->
receiverGUID
)
->
setCampaign
(
'when'
)
->
setTopic
(
'wire_received'
)
->
setValue
(
true
);
$this
->
manager
->
isSubscribed
(
$testEmailSubscription
)
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
send
();
}
public
function
it_should_send_a_wire_received_email_eth
()
{
$this
->
wire
->
setMethod
(
'eth'
);
$this
->
wire
->
setAmount
(
7
);
$this
->
getCampaign
()
->
shouldEqual
(
'when'
);
$this
->
getTopic
()
->
shouldEqual
(
'wire_received'
);
$this
->
setUser
(
$this
->
receiver
);
$this
->
setWire
(
$this
->
wire
);
$this
->
setSuggestions
(
$this
->
mockSuggestions
());
$message
=
$this
->
build
();
$message
->
getSubject
()
->
shouldEqual
(
'You received a wire'
);
$to
=
$message
->
getTo
()[
0
][
'name'
]
->
shouldEqual
(
$this
->
receiverName
);
$to
=
$message
->
getTo
()[
0
][
'email'
]
->
shouldEqual
(
$this
->
receiverEmail
);
$data
=
$this
->
getTemplate
()
->
getData
();
$data
[
'guid'
]
->
shouldEqual
(
$this
->
receiverGUID
);
$data
[
'email'
]
->
shouldEqual
(
$this
->
receiverEmail
);
$data
[
'username'
]
->
shouldEqual
(
$this
->
receiverUsername
);
$data
[
'amount'
]
->
shouldEqual
(
'7 ETH'
);
$this
->
mailer
->
queue
(
Argument
::
any
())
->
shouldBeCalled
();
$testEmailSubscription
=
(
new
EmailSubscription
())
...
...
@@ -92,9 +126,10 @@ class WireReceivedSpec extends ObjectBehavior
$this
->
send
();
}
public
function
it_should_send_a_wire_received_email_
onchain
()
public
function
it_should_send_a_wire_received_email_
usd
()
{
$this
->
wire
->
setMethod
(
'onchain'
);
$this
->
wire
->
setMethod
(
'usd'
);
$this
->
wire
->
setAmount
(
500
);
$this
->
getCampaign
()
->
shouldEqual
(
'when'
);
$this
->
getTopic
()
->
shouldEqual
(
'wire_received'
);
$this
->
setUser
(
$this
->
receiver
);
...
...
@@ -108,8 +143,8 @@ class WireReceivedSpec extends ObjectBehavior
$data
[
'guid'
]
->
shouldEqual
(
$this
->
receiverGUID
);
$data
[
'email'
]
->
shouldEqual
(
$this
->
receiverEmail
);
$data
[
'username'
]
->
shouldEqual
(
$this
->
receiverUsername
);
$data
[
'
contract'
]
->
shouldEqual
(
'wire
'
);
$data
[
'amount'
]
->
shouldEqual
(
10
);
$data
[
'
amount'
]
->
shouldEqual
(
'5 USD
'
);
$this
->
mailer
->
queue
(
Argument
::
any
())
->
shouldBeCalled
();
$testEmailSubscription
=
(
new
EmailSubscription
())
...
...
@@ -122,6 +157,36 @@ class WireReceivedSpec extends ObjectBehavior
$this
->
send
();
}
// public function it_should_send_a_wire_received_email_onchain()
// {
// $this->wire->setMethod('onchain');
// $this->getCampaign()->shouldEqual('when');
// $this->getTopic()->shouldEqual('wire_received');
// $this->setUser($this->receiver);
// $this->setWire($this->wire);
// $this->setSuggestions($this->mockSuggestions());
// $message = $this->build();
// $message->getSubject()->shouldEqual('You received a wire');
// $to = $message->getTo()[0]['name']->shouldEqual($this->receiverName);
// $to = $message->getTo()[0]['email']->shouldEqual($this->receiverEmail);
// $data = $this->getTemplate()->getData();
// $data['guid']->shouldEqual($this->receiverGUID);
// $data['email']->shouldEqual($this->receiverEmail);
// $data['username']->shouldEqual($this->receiverUsername);
// $data['contract']->shouldEqual('wire');
// $data['amount']->shouldEqual('2000000000000000 ONCHAIN');
// $this->mailer->queue(Argument::any())->shouldBeCalled();
// $testEmailSubscription = (new EmailSubscription())
// ->setUserGuid($this->receiverGUID)
// ->setCampaign('when')
// ->setTopic('wire_received')
// ->setValue(true);
// $this->manager->isSubscribed($testEmailSubscription)->shouldBeCalled()->willReturn(true);
// $this->send();
// }
public
function
it_should_not_send_unsubscribed
()
{
$this
->
getCampaign
()
->
shouldEqual
(
'when'
);
...
...
This diff is collapsed.
Click to expand it.