From ba3216b9a343548621f4f037a080ef353f637e46 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 10 Sep 2023 22:21:48 +0200 Subject: [PATCH] Multiple file-related fixes --- langs/en.json | 2 +- src/API.php | 2 +- src/MTProtoTools/Files.php | 2 +- src/MTProtoTools/FilesLogic.php | 2 +- src/TL/TLInterface.php | 5 +++++ src/VoIP/DiscardReason.php | 3 +++ 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/langs/en.json b/langs/en.json index 20beb9981..3904b21c5 100644 --- a/langs/en.json +++ b/langs/en.json @@ -162,5 +162,5 @@ "plugin_path_does_not_exist": "Plugin path %s does not exist!", "windows_warning": "For Windows users: please switch to Linux if this fails. You can also try modifying the firewall settings to allow all PHP processes to create sockets (it's 100% easier to just switch to Linux, on Linux MadelineProto just works out of the box, no changes needed)", - "could_not_connect_to_MadelineProto": "Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix! If you already did that, make sure the CLI version of PHP is exactly the same as the web version (same version, extensions, et cetera) and check out the MadelineProto.log file for more info about the error that prevented the IPC server from starting." + "could_not_connect_to_MadelineProto": "Could not connect to MadelineProto, please enable proc_open and remove open_basedir restrictions or disable webserver path rewrites to fix! If you already did that, make sure the CLI version of PHP is exactly the same as the web version (same version, extensions, et cetera) and check out the MadelineProto.log file for more info about the error that prevented the IPC server from starting." } diff --git a/src/API.php b/src/API.php index a63315863..2a37387d6 100644 --- a/src/API.php +++ b/src/API.php @@ -51,7 +51,7 @@ final class API extends AbstractAPI * * @var string */ - public const RELEASE = '8.0.0-beta149'; + public const RELEASE = '8.0.0-beta150'; /** * Secret chat was not found. * diff --git a/src/MTProtoTools/Files.php b/src/MTProtoTools/Files.php index fae3e7ffe..8115a0657 100644 --- a/src/MTProtoTools/Files.php +++ b/src/MTProtoTools/Files.php @@ -139,7 +139,7 @@ trait Files } if ($has_animated) { if ($has_video === null) { - throw new AssertionError("has_video === null: ".\json_encode($media['document'])); + return new Document($this, $media, $protected); } return new Gif($this, $media, $has_video, $protected); } diff --git a/src/MTProtoTools/FilesLogic.php b/src/MTProtoTools/FilesLogic.php index ca8e44480..82f6001f9 100644 --- a/src/MTProtoTools/FilesLogic.php +++ b/src/MTProtoTools/FilesLogic.php @@ -290,7 +290,7 @@ trait FilesLogic 'application/octet-stream' ); } - if ($upload && !\is_array($media['file'])) { + if ($upload && isset($media['file']) && !\is_array($media['file'])) { $media['file'] = $this->upload($media['file']); } } diff --git a/src/TL/TLInterface.php b/src/TL/TLInterface.php index e9c1881bc..c07490e95 100644 --- a/src/TL/TLInterface.php +++ b/src/TL/TLInterface.php @@ -73,4 +73,9 @@ interface TLInterface * @param array $type Type identifier */ public function deserialize($stream, array $type); + + /** + * Get secret chat layer version. + */ + public function getSecretLayer(): int; } diff --git a/src/VoIP/DiscardReason.php b/src/VoIP/DiscardReason.php index d1c7a6c43..7186b634d 100644 --- a/src/VoIP/DiscardReason.php +++ b/src/VoIP/DiscardReason.php @@ -47,6 +47,9 @@ enum DiscardReason implements JsonSerializable return null; } $newName = \strtoupper(\substr($name, 22)); + if ($newName === 'DISCONNECT') { + return self::DISCONNECTED; + } foreach (DiscardReason::cases() as $case) { if ($case->name === $newName) { return $case;