Add addApplicationChangelog.

This commit is contained in:
levlam 2023-02-21 12:08:55 +03:00
parent 862abd1e84
commit acec58e7ef
6 changed files with 49 additions and 2 deletions

View File

@ -8111,8 +8111,6 @@ getPhoneNumberInfo phone_number_prefix:string = PhoneNumberInfo;
//@phone_number_prefix The phone number prefix
getPhoneNumberInfoSync language_code:string phone_number_prefix:string = PhoneNumberInfo;
//@description Returns the link for downloading official Telegram application to be used when the current user invites friends to Telegram
getApplicationDownloadLink = HttpUrl;
//@description Returns information about a tg:// deep link. Use "tg://need_update_for_some_feature" or "tg:some_unsupported_feature" for testing. Returns a 404 error for unknown links. Can be called before authorization @link The link
getDeepLinkInfo link:string = DeepLinkInfo;
@ -8121,9 +8119,15 @@ getDeepLinkInfo link:string = DeepLinkInfo;
//@description Returns application config, provided by the server. Can be called before authorization
getApplicationConfig = JsonValue;
//@description Adds server-provided application changelog as messages to the chat 777000 (Telegram); for official applications only @previous_application_version The previous application version
addApplicationChangelog previous_application_version:string = Ok;
//@description Saves application log event on the server. Can be called before authorization @type Event type @chat_id Optional chat identifier, associated with the event @data The log event data
saveApplicationLogEvent type:string chat_id:int53 data:JsonValue = Ok;
//@description Returns the link for downloading official Telegram application to be used when the current user invites friends to Telegram
getApplicationDownloadLink = HttpUrl;
//@description Adds a proxy server for network requests. Can be called before authorization
//@server Proxy server IP address

View File

@ -11,6 +11,7 @@
#include "td/telegram/logevent/LogEventHelper.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/UpdatesManager.h"
#include "td/db/binlog/BinlogEvent.h"
#include "td/db/binlog/BinlogHelper.h"
@ -77,6 +78,31 @@ class SaveAppLogQuery final : public Td::ResultHandler {
}
};
class GetAppChangelogQuery final : public Td::ResultHandler {
Promise<Unit> promise_;
public:
explicit GetAppChangelogQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(const string &prev_app_version) {
send_query(G()->net_query_creator().create(telegram_api::help_getAppChangelog(prev_app_version)));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::help_getAppChangelog>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
td_->updates_manager_->on_get_updates(result_ptr.move_as_ok(), std::move(promise_));
}
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
void get_invite_text(Td *td, Promise<string> &&promise) {
td->create_handler<GetInviteTextQuery>(std::move(promise))->send();
}
@ -132,4 +158,8 @@ void on_save_app_log_binlog_event(Td *td, BinlogEvent &&event) {
save_app_log_impl(td, std::move(log_event.input_app_event_out_), event.id_, Promise<Unit>());
}
void add_app_changelog(Td *td, const string &previous_application_version, Promise<Unit> &&promise) {
td->create_handler<GetAppChangelogQuery>(std::move(promise))->send(previous_application_version);
}
} // namespace td

View File

@ -25,4 +25,6 @@ void save_app_log(Td *td, const string &type, DialogId dialog_id, tl_object_ptr<
void on_save_app_log_binlog_event(Td *td, BinlogEvent &&event);
void add_app_changelog(Td *td, const string &previous_application_version, Promise<Unit> &&promise);
} // namespace td

View File

@ -8320,6 +8320,13 @@ void Td::on_request(uint64 id, const td_api::getApplicationConfig &request) {
send_closure(G()->config_manager(), &ConfigManager::get_app_config, std::move(promise));
}
void Td::on_request(uint64 id, td_api::addApplicationChangelog &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.previous_application_version_);
CREATE_OK_REQUEST_PROMISE();
add_app_changelog(this, request.previous_application_version_, std::move(promise));
}
void Td::on_request(uint64 id, td_api::saveApplicationLogEvent &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.type_);

View File

@ -1462,6 +1462,8 @@ class Td final : public Actor {
void on_request(uint64 id, const td_api::getApplicationConfig &request);
void on_request(uint64 id, td_api::addApplicationChangelog &request);
void on_request(uint64 id, td_api::saveApplicationLogEvent &request);
void on_request(uint64 id, td_api::addProxy &request);

View File

@ -3647,6 +3647,8 @@ class CliClient final : public Actor {
execute(td_api::make_object<td_api::getThemeParametersJsonString>(as_theme_parameters()));
} else if (op == "gac") {
send_request(td_api::make_object<td_api::getApplicationConfig>());
} else if (op == "aac") {
send_request(td_api::make_object<td_api::addApplicationChangelog>(args));
} else if (op == "sale") {
string type;
ChatId chat_id;