Coin: Code cleanup

This commit is contained in:
veselcraft 2022-05-23 16:13:02 +03:00
parent fb6c9d3963
commit 10040332ed
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E
3 changed files with 20 additions and 21 deletions

View file

@ -47,7 +47,7 @@ class FetchToncoinTransactions extends Command
} }
$testnetSubdomain = OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["testnet"] ? "testnet." : ""; $testnetSubdomain = OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["testnet"] ? "testnet." : "";
$url = "https://" . $testnetSubdomain . "toncenter.com/api/v2/getTransactions?"; $url = "https://" . $testnetSubdomain . "toncenter.com/api/v2/getTransactions?";
$opts = [ $opts = [
"http" => [ "http" => [
@ -57,14 +57,14 @@ class FetchToncoinTransactions extends Command
]; ];
$selection = $this->transactions->select('hash, lt')->order("id DESC")->limit(1)->fetch(); $selection = $this->transactions->select('hash, lt')->order("id DESC")->limit(1)->fetch();
$trHash = $selection->hash ?? NULL; $trHash = $selection->hash ?? NULL;
$trLt = $selection->lt ?? NULL; $trLt = $selection->lt ?? NULL;
$data = http_build_query([ $data = http_build_query([
"address" => OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["address"], "address" => OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["address"],
"limit" => 100, "limit" => 100,
"hash" => $trHash, "hash" => $trHash,
"to_lt" => $trLt "to_lt" => $trLt
]); ]);
$response = file_get_contents($url . $data, false, stream_context_create($opts)); $response = file_get_contents($url . $data, false, stream_context_create($opts));
@ -72,13 +72,13 @@ class FetchToncoinTransactions extends Command
$header->writeln("Gonna up the balance of users"); $header->writeln("Gonna up the balance of users");
foreach($response["result"] as $transfer) { foreach($response["result"] as $transfer) {
$output_array; $outputArray;
preg_match('/' . OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["regex"] . '/', $transfer["in_msg"]["message"], $output_array); preg_match('/' . OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["regex"] . '/', $transfer["in_msg"]["message"], $outputArray);
$userid = ctype_digit($output_array[1]) ? intval($output_array[1]) : NULL; $userId = ctype_digit($outputArray[1]) ? intval($outputArray[1]) : NULL;
if(is_null($userid)) { if(is_null($userId)) {
$header->writeln("Well, that's a donation. Thanks! XD"); $header->writeln("Well, that's a donation. Thanks! XD");
} else { } else {
$user = (new Users)->get($userid); $user = (new Users)->get($userId);
if(!$user) { if(!$user) {
$header->writeln("Well, that's a donation. Thanks! XD"); $header->writeln("Well, that's a donation. Thanks! XD");
} else { } else {

View file

@ -272,15 +272,14 @@ final class WallPresenter extends OpenVKPresenter
$this->flashFail("err", tr("failed_to_publish_post"), tr("post_is_empty_or_too_big")); $this->flashFail("err", tr("failed_to_publish_post"), tr("post_is_empty_or_too_big"));
try { try {
$post = new Post; $post = new Post;
$post->setOwner($this->user->id);
$post->setOwner($this->user->id); $post->setWall($wall);
$post->setWall($wall); $post->setCreated(time());
$post->setCreated(time()); $post->setContent($this->postParam("text"));
$post->setContent($this->postParam("text")); $post->setAnonymous($anon);
$post->setAnonymous($anon); $post->setFlags($flags);
$post->setFlags($flags); $post->setNsfw($this->postParam("nsfw") === "on");
$post->setNsfw($this->postParam("nsfw") === "on");
$post->save(); $post->save();
} catch (\LengthException $ex) { } catch (\LengthException $ex) {
$this->flashFail("err", tr("failed_to_publish_post"), tr("post_is_too_big")); $this->flashFail("err", tr("failed_to_publish_post"), tr("post_is_too_big"));