Return error 404 from addApplicationChangelog if nothing was added.
This commit is contained in:
parent
cb27d4bd07
commit
23c8ef2f63
@ -8215,7 +8215,7 @@ 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
|
||||
//@description Adds server-provided application changelog as messages to the chat 777000 (Telegram); for official applications only. Returns a 404 error if nothing changed @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
|
||||
|
@ -95,7 +95,11 @@ class GetAppChangelogQuery final : public Td::ResultHandler {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
td_->updates_manager_->on_get_updates(result_ptr.move_as_ok(), std::move(promise_));
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
if (td_->updates_manager_->are_empty_updates(ptr.get())) {
|
||||
return promise_.set_error(Status::Error(404, "Changelog not found"));
|
||||
}
|
||||
td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
|
@ -1174,6 +1174,25 @@ vector<tl_object_ptr<telegram_api::Update>> *UpdatesManager::get_updates(telegra
|
||||
get_updates(static_cast<const telegram_api::Updates *>(updates_ptr)));
|
||||
}
|
||||
|
||||
bool UpdatesManager::are_empty_updates(const telegram_api::Updates *updates_ptr) {
|
||||
switch (updates_ptr->get_id()) {
|
||||
case telegram_api::updatesTooLong::ID:
|
||||
case telegram_api::updateShortSentMessage::ID:
|
||||
return true;
|
||||
case telegram_api::updateShortMessage::ID:
|
||||
case telegram_api::updateShortChatMessage::ID:
|
||||
case telegram_api::updateShort::ID:
|
||||
return false;
|
||||
case telegram_api::updatesCombined::ID:
|
||||
return static_cast<const telegram_api::updatesCombined *>(updates_ptr)->updates_.empty();
|
||||
case telegram_api::updates::ID:
|
||||
return static_cast<const telegram_api::updates *>(updates_ptr)->updates_.empty();
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
vector<UserId> UpdatesManager::extract_group_invite_privacy_forbidden_updates(
|
||||
tl_object_ptr<telegram_api::Updates> &updates_ptr) {
|
||||
auto updates = get_updates(updates_ptr.get());
|
||||
|
@ -103,7 +103,10 @@ class UpdatesManager final : public Actor {
|
||||
void add_pending_pts_update(tl_object_ptr<telegram_api::Update> &&update, int32 new_pts, int32 pts_count,
|
||||
double receive_time, Promise<Unit> &&promise, const char *source);
|
||||
|
||||
vector<UserId> extract_group_invite_privacy_forbidden_updates(tl_object_ptr<telegram_api::Updates> &updates_ptr);
|
||||
static bool are_empty_updates(const telegram_api::Updates *updates_ptr);
|
||||
|
||||
static vector<UserId> extract_group_invite_privacy_forbidden_updates(
|
||||
tl_object_ptr<telegram_api::Updates> &updates_ptr);
|
||||
|
||||
static FlatHashSet<int64> get_sent_messages_random_ids(const telegram_api::Updates *updates_ptr);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user