Commit 0abf1410 authored by Mark Harding's avatar Mark Harding

(fix): improve the notifications of wires

parent ca589525
No related merge requests found
Pipeline #72525294 running with stages
......@@ -49,7 +49,6 @@ class WireNotification implements Interfaces\QueueRunner
return;
}
$amount = $wire->getMethod() === 'tokens' ? BigNumber::fromPlain($wire->getAmount(), 18)->toDouble() : $wire->getAmount();
$senderUser = $wire->getSender();
//send notification to receiver
......@@ -58,7 +57,7 @@ class WireNotification implements Interfaces\QueueRunner
'from' => $senderUser->guid,
'notification_view' => 'wire_happened',
'params' => [
'amount' => $this->getAmountString($amount),
'amount' => $this->getAmountString($wire),
'from_guid' => $senderUser->guid,
'from_username' => $senderUser->username,
'to_guid' => $receiverUser->guid,
......@@ -83,7 +82,7 @@ class WireNotification implements Interfaces\QueueRunner
'from' => $receiverUser->guid,
'notification_view' => 'wire_happened',
'params' => [
'amount' => $amount,
'amount' => $this->getAmountString($wire),
'from_guid' => $senderUser->guid,
'from_username' => $senderUser->username,
'to_guid' => $receiverUser->guid,
......@@ -97,10 +96,20 @@ class WireNotification implements Interfaces\QueueRunner
});
}
private function getAmountString($amount)
private function getAmountString($wire)
{
$currency = $amount > 1 ? ' tokens' : ' token';
return $amount.$currency;
$amount = $wire->getAmount();
if ($wire->getMethod() === 'tokens') {
$amount = BigNumber::fromPlain($wire->getAmount(), 18)->toDouble();
$currency = $amount > 1 ? 'tokens' : 'token';
} else {
$currency = strtoupper($wire->getMethod());
}
if ($wire->getMethod() === 'usd') {
$amount = $amount / 100;
}
return "$amount $currency";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment