Skip to content

Commit f0cd296

Browse files
committed
issue #3: JsonObject not needed in getFile()
1 parent 81377db commit f0cd296

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/UniversalTelegramBot.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -795,13 +795,12 @@ bool UniversalTelegramBot::getFile(String *file_path, long *file_size, String fi
795795
String response = sendGetToTelegram(command); // receive reply from telegram.org
796796
DynamicJsonDocument doc(maxMessageLength);
797797
DeserializationError error = deserializeJson(doc, ZERO_COPY(response));
798-
JsonObject obj = doc.as<JsonObject>(); //there is nothing better right now to use obj.containsKey("result")
799798
closeClient();
800799

801800
if (!error) {
802-
if (obj.containsKey("result")) {
803-
*file_path = "https://api.telegram.org/file/bot" + _token + "/" + obj["result"]["file_path"].as<String>();
804-
*file_size = obj["result"]["file_size"].as<long>();
801+
if (doc.containsKey("result")) {
802+
*file_path = "https://api.telegram.org/file/bot" + _token + "/" + doc["result"]["file_path"].as<String>();
803+
*file_size = doc["result"]["file_size"].as<long>();
805804
return true;
806805
}
807806
}

0 commit comments

Comments
 (0)