Browse Source

apply account balance on available

main
ghost 10 months ago
parent
commit
250c1dc137
  1. 58
      src/Controller/RoomController.php

58
src/Controller/RoomController.php

@ -626,8 +626,63 @@ class RoomController extends AbstractController
); );
} }
// Post has commission cost, send message to pending payment pool // Post has commission cost
if ($this->getParameter('app.add.post.cost.kva')) if ($this->getParameter('app.add.post.cost.kva'))
{
// Send message by account balance on available
if (
$username != 'anon'
&&
$client->getBalance(
$username,
$this->getParameter('app.pool.confirmations')
) >= $this->getParameter('app.add.post.cost.kva')
) {
if (
$txid = $client->kevaPut(
$request->get('namespace'),
sprintf(
'%s@%s',
time(), // @TODO save timestamp as part of key to keep timing actual for the chat feature
$username
),
$request->get('message')
)
)
{
// Send amount to profit address
$client->sendToAddress(
$this->getParameter('app.kevacoin.profit.address'),
$this->getParameter('app.add.post.cost.kva'),
$txid,
null,
true // subtract from amount
);
// Register event time
$memcached->set(
$memory,
time(),
(int) $this->getParameter('app.add.post.remote.ip.delay') // auto remove on cache expire
);
// Redirect back to room
return $this->redirectToRoute(
'room_namespace',
[
'mode' => $request->get('mode'),
'namespace' => $request->get('namespace'),
'sign' => $request->get('sign'),
'error' => null,
'message' => null,
'_fragment' => 'latest'
]
);
}
}
// Send message to pending payment pool
else
{ {
$time = time(); $time = time();
@ -706,6 +761,7 @@ class RoomController extends AbstractController
] ]
); );
} }
}
// Post has zero cost, send message to DHT // Post has zero cost, send message to DHT
else else

Loading…
Cancel
Save