Skip to content

Commit

Permalink
Secret chat fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Sep 6, 2023
1 parent 4d99875 commit 3abf8b5
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 30 deletions.
2 changes: 1 addition & 1 deletion schemas
Submodule schemas updated 2 files
+0 −19 TL_botAPI.tl
+1 −1 TL_secret.tl
2 changes: 1 addition & 1 deletion src/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __toString(): string
{
return $this->file === 'MadelineProto' ? $this->message : '\\danog\\MadelineProto\\Exception'.($this->message !== '' ? ': ' : '').$this->message.' in '.$this->file.':'.$this->line.PHP_EOL.Magic::$revision.PHP_EOL.'TL Trace:'.PHP_EOL.$this->getTLTrace();
}
public function __construct($message = null, $code = 0, ?self $previous = null, $file = null, $line = null)
public function __construct($message = null, $code = 0, ?\Throwable $previous = null, $file = null, $line = null)
{
$this->prettifyTL();
if ($file !== null) {
Expand Down
4 changes: 2 additions & 2 deletions src/GarbageCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ public static function start(): void
return;
}
$client = HttpClientBuilder::buildDefault();
$request = new Request(MADELINE_RELEASE_URL);

$id = null;
$cb = function () use ($client, $request, &$id): void {
$cb = function () use ($client, &$id): void {
try {
$request = new Request(MADELINE_RELEASE_URL);
$latest = $client->request($request);
Magic::$latest_release = \trim($latest->getBody()->buffer());
if (API::RELEASE !== Magic::$latest_release) {
Expand Down
17 changes: 12 additions & 5 deletions src/Ipc/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace danog\MadelineProto\Ipc;

use Amp\CompositeException;
use Amp\DeferredFuture;
use Amp\Future;
use Amp\Ipc\IpcServer;
Expand Down Expand Up @@ -101,6 +102,7 @@ public static function startMe(SessionPaths $session): Future
{
$id = Tools::randomInt(2000000000);
$started = false;
$e = null;
try {
Logger::log("Starting IPC server $session (process)");
ProcessRunner::start((string) $session, $id);
Expand All @@ -115,15 +117,20 @@ public static function startMe(SessionPaths $session): Future
if (WebRunner::start((string) $session, $id)) {
$started = true;
}
} catch (Throwable $e) {
Logger::log($e);
} catch (Throwable $e2) {
Logger::log($e2);
if ($e) {
$e = new CompositeException([$e, $e2]);
} else {
$e = $e2;
}
}
return async(self::monitor(...), $session, $id, $started);
return async(self::monitor(...), $session, $id, $started, $e);
}
/**
* Monitor session.
*/
private static function monitor(SessionPaths $session, int $id, bool $started): bool|Throwable
private static function monitor(SessionPaths $session, int $id, bool $started, ?\Throwable $e): bool|Throwable
{
if (!$started) {
Logger::log("It looks like the server couldn't be started, trying to connect anyway...");
Expand All @@ -139,7 +146,7 @@ private static function monitor(SessionPaths $session, int $id, bool $started):
Logger::log('IPC server started successfully!');
return true;
} elseif (!$started && $count > 0 && $count > 2*($state ? 3 : 1)) {
return new Exception("We couldn't start the IPC server, please check the logs!");
return new Exception("We couldn't start the IPC server, please check the logs!", previous: $e);
}
delay(0.5);
$count++;
Expand Down
19 changes: 0 additions & 19 deletions src/TL_botAPI.tl

This file was deleted.

2 changes: 1 addition & 1 deletion src/TL_secret.tl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ messageEntityStrike#bf0693d4 offset:int length:int = MessageEntity;
messageEntityBlockquote#20df5d0 offset:int length:int = MessageEntity;

===143===
decryptedMessageMediaDocument#8e4c064c thumb:bytes thumb_w:int thumb_h:int mime_type:string size:long key:bytes iv:bytes attributes:Vector<DocumentAttribute> caption:string = DecryptedMessageMedia;
decryptedMessageMediaDocument#6abd9782 thumb:bytes thumb_w:int thumb_h:int mime_type:string size:long key:bytes iv:bytes attributes:Vector<DocumentAttribute> caption:string = DecryptedMessageMedia;

===144===
messageEntitySpoiler#32ca960f offset:int length:int = MessageEntity;
Expand Down
2 changes: 1 addition & 1 deletion tools/build_docs/layerUpgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function layerUpgrade(int $layer): void
file_put_contents('docs/docs/docs/USING_METHODS.md', $doc);

array_map(unlink::class, glob('src/*.tl'));
foreach (['TL_mtproto_v1', "TL_telegram_v$layer", 'TL_secret', 'TL_botAPI'] as $schema) {
foreach (['TL_mtproto_v1', "TL_telegram_v$layer", 'TL_secret'] as $schema) {
copy("schemas/$schema.tl", "src/$schema.tl");
}

Expand Down

0 comments on commit 3abf8b5

Please sign in to comment.