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
33
Merge Requests
33
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
d85a52eb
Commit
d85a52eb
authored
1 hour ago
by
Olivia Madrid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat): wire emails support multiple currencies
parent
5e2b6fb5
feat/wire-email-currency-574
1 merge request
!287
WIP: (feat): Wire email templates support multiple currencies
Pipeline
#73398506
failed with stages
in 4 minutes and 59 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
97 additions
and
19 deletions
+97
-19
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
+2
-5
WireNotification.php
Core/Queue/Runners/WireNotification.php
+1
-1
WireReceivedSpec.php
Spec/Core/Email/Campaigns/WireReceivedSpec.php
+70
-5
No files found.
Core/Email/Campaigns/Templates/wire-received.tpl
View file @
d85a52eb
<
?
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 @
d85a52eb
<
?
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 @
d85a52eb
...
...
@@ -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 @
d85a52eb
...
...
@@ -40,8 +40,6 @@ 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();
$amount
=
$this
->
getAmountString
(
$this
->
wire
);
$contract
=
$this
->
wire
->
getMethod
()
===
'onchain'
?
'wire'
:
'offchain:wire'
;
$this
->
template
->
setTemplate
(
'default.tpl'
);
...
...
@@ -51,7 +49,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
);
...
...
@@ -76,13 +74,12 @@ class WireSent extends EmailCampaign
}
}
private
function
getAmountString
(
$wire
)
{
$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.
Core/Queue/Runners/WireNotification.php
View file @
d85a52eb
...
...
@@ -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.
Spec/Core/Email/Campaigns/WireReceivedSpec.php
View file @
d85a52eb
...
...
@@ -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.
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