1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-22 16:31:11 +01:00

Misc fixes

This commit is contained in:
Daniil Gentili 2023-03-05 19:22:21 +01:00
parent 2d6b275279
commit 904aaaaaad
2 changed files with 4 additions and 13 deletions

View File

@ -41,7 +41,6 @@ use danog\MadelineProto\UpdateHandlerType;
use danog\MadelineProto\VoIP;
use Generator;
use Revolt\EventLoop;
use Throwable;
use Webmozart\Assert\Assert;
/**
@ -134,16 +133,7 @@ trait UpdateHandler
$request = new Request($this->webhookUrl, 'POST');
$request->setHeader('content-type', 'application/json');
$request->setBody($payload);
$result = ($this->datacenter->getHTTPClient()->request($request))->getBody()->buffer();
$this->logger->logger('Result of webhook query is '.$result, Logger::NOTICE);
$result = \json_decode($result, true);
if (\is_array($result) && isset($result['method']) && $result['method'] != '' && \is_string($result['method'])) {
try {
$this->logger->logger('Reverse webhook command returned', $this->methodCallAsyncRead($result['method'], $result));
} catch (Throwable $e) {
$this->logger->logger("Reverse webhook command returned: {$e}");
}
}
$this->datacenter->getHTTPClient()->request($request);
}
private ?DeferredFuture $update_deferred = null;

View File

@ -144,7 +144,8 @@ trait Loop
*/
public function restart(): void
{
$this->stopDeferred ??= new DeferredFuture;
$this->stopDeferred->complete();
$deferred = $this->stopDeferred ?? new DeferredFuture;
$this->stopDeferred = null;
$deferred->complete();
}
}