diff options
-rw-r--r-- | include/tgbot/Api.h | 3 | ||||
-rw-r--r-- | src/Api.cpp | 8 |
2 files changed, 7 insertions, 4 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 66f41b5..68b8462 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -230,8 +230,7 @@ public: * Ports currently supported for Webhooks: 443, 80, 88, 8443. * @param url Optional. HTTPS url to send updates to. Use an empty string to remove webhook integration. */ - // TODO Add support to self-signed certificate - void setWebhook(const std::string& url = "") const; + void setWebhook(const std::string& url = "", const InputFile::Ptr& certificate = nullptr) const; /** * Use this method to send answers to an inline query. diff --git a/src/Api.cpp b/src/Api.cpp index ed06d27..4070230 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -249,9 +249,13 @@ vector<Update::Ptr> Api::getUpdates(int32_t offset, int32_t limit, int32_t timeo return TgTypeParser::getInstance().parseJsonAndGetArray<Update>(&TgTypeParser::parseJsonAndGetUpdate, sendRequest("getUpdates", args)); } -void Api::setWebhook(const string& url) const { +void Api::setWebhook(const string& url, const InputFile::Ptr& certificate) const { vector<HttpReqArg> args; - args.push_back(HttpReqArg("url", url)); + if (!url.empty()) + args.push_back(HttpReqArg("url", url)); + if (certificate != nullptr) + args.push_back(HttpReqArg("certificate", certificate->data, true, certificate->mimeType, certificate->fileName)); + sendRequest("setWebhook", args); } |