Browse Source

apply account balance on available

main
ghost 9 months ago
parent
commit
250c1dc137
  1. 184
      src/Controller/RoomController.php

184
src/Controller/RoomController.php

@ -626,85 +626,141 @@ 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'))
{ {
$time = time(); // 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'
]
);
}
}
$pool = new Pool(); // Send message to pending payment pool
else
{
$time = time();
$pool->setTime( $pool = new Pool();
$time
);
$pool->setSent( $pool->setTime(
0 $time
); );
$pool->setExpired( $pool->setSent(
0 0
); );
$pool->setCost( $pool->setExpired(
$this->getParameter('app.add.post.cost.kva') 0
); );
$pool->setAddress( $pool->setCost(
$address = $client->getNewAddress( $this->getParameter('app.add.post.cost.kva')
$this->getParameter('app.kevacoin.pool.account') );
)
);
$pool->setNamespace( $pool->setAddress(
$request->get('namespace') $address = $client->getNewAddress(
); $this->getParameter('app.kevacoin.pool.account')
)
);
$pool->setKey( $pool->setNamespace(
sprintf( $request->get('namespace')
'%s@%s', );
$time,
$username
)
);
$pool->setValue( $pool->setKey(
$request->get('message') sprintf(
); '%s@%s',
$time,
$username
)
);
$entity->persist( $pool->setValue(
$pool $request->get('message')
); );
$entity->flush(); $entity->persist(
$pool
);
// Register event time $entity->flush();
$memcached->set(
$memory,
time(),
(int) $this->getParameter('app.add.post.remote.ip.delay') // auto remove on cache expire
);
// Redirect back to room // Register event time
return $this->redirectToRoute( $memcached->set(
'room_namespace', $memory,
[ time(),
'mode' => $request->get('mode'), (int) $this->getParameter('app.add.post.remote.ip.delay') // auto remove on cache expire
'namespace' => $request->get('namespace'), );
'sign' => $request->get('sign'),
'message' => null, // Redirect back to room
'error' => null, return $this->redirectToRoute(
'warning' => sprintf( 'room_namespace',
$translator->trans('Pending %s KVA to %s (expires at %s)'), [
$this->getParameter('app.add.post.cost.kva'), 'mode' => $request->get('mode'),
$address, 'namespace' => $request->get('namespace'),
date( 'sign' => $request->get('sign'),
'c', 'message' => null,
$this->getParameter('app.pool.timeout') + $time 'error' => null,
) 'warning' => sprintf(
), $translator->trans('Pending %s KVA to %s (expires at %s)'),
'_fragment' => 'latest' $this->getParameter('app.add.post.cost.kva'),
] $address,
); date(
'c',
$this->getParameter('app.pool.timeout') + $time
)
),
'_fragment' => 'latest'
]
);
}
} }
// Post has zero cost, send message to DHT // Post has zero cost, send message to DHT

Loading…
Cancel
Save