aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2026-07-10 23:14:59 +0300
committerlevlam <levlam@telegram.org>2026-07-10 23:14:59 +0300
commit226cfcb59865fb06e5824335f70c6c3f9d9e73a3 (patch)
tree1a68497d8f07cf8c44a9831f709e9c450d0f61ae
parenta1794007166b175f221a7504e0a191e53361fbcf (diff)
Use uint64 for allowed update types.
-rw-r--r--telegram-bot-api/Client.cpp16
-rw-r--r--telegram-bot-api/Client.h13
2 files changed, 15 insertions, 14 deletions
diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp
index 444c43d..c0d3bd5 100644
--- a/telegram-bot-api/Client.cpp
+++ b/telegram-bot-api/Client.cpp
@@ -6557,7 +6557,7 @@ class Client::JsonStarTransactions final : public td::Jsonable {
class Client::JsonUpdateTypes final : public td::Jsonable {
public:
- explicit JsonUpdateTypes(td::uint32 update_types) : update_types_(update_types) {
+ explicit JsonUpdateTypes(td::uint64 update_types) : update_types_(update_types) {
}
void store(td::JsonValueScope *scope) const {
auto array = scope->enter_array();
@@ -6572,7 +6572,7 @@ class Client::JsonUpdateTypes final : public td::Jsonable {
}
private:
- td::uint32 update_types_;
+ td::uint64 update_types_;
};
class Client::JsonWebhookInfo final : public td::Jsonable {
@@ -9775,7 +9775,7 @@ void Client::on_update(object_ptr<td_api::Object> result) {
} else {
CHECK(update->value_->get_id() == td_api::optionValueInteger::ID);
allowed_update_types_ =
- static_cast<td::uint32>(move_object_as<td_api::optionValueInteger>(update->value_)->value_);
+ static_cast<td::uint64>(move_object_as<td_api::optionValueInteger>(update->value_)->value_);
}
}
if (name == "unix_time" && update->value_->get_id() != td_api::optionValueEmpty::ID) {
@@ -17951,7 +17951,7 @@ td::Slice Client::get_update_type_name(UpdateType update_type) {
}
}
-td::uint32 Client::get_allowed_update_types(td::MutableSlice allowed_updates, bool is_internal) {
+td::uint64 Client::get_allowed_update_types(td::MutableSlice allowed_updates, bool is_internal) {
if (allowed_updates.empty()) {
return 0;
}
@@ -17963,11 +17963,11 @@ td::uint32 Client::get_allowed_update_types(td::MutableSlice allowed_updates, bo
return 0;
}
- td::uint32 result = 0;
+ td::uint64 result = 0;
auto value = r_value.move_as_ok();
if (value.type() != td::JsonValue::Type::Array) {
if (value.type() == td::JsonValue::Type::Number && is_internal) {
- auto r_number = td::to_integer_safe<td::uint32>(value.get_number());
+ auto r_number = td::to_integer_safe<td::uint64>(value.get_number());
if (r_number.is_ok() && r_number.ok() > 0) {
return r_number.ok();
}
@@ -17982,7 +17982,7 @@ td::uint32 Client::get_allowed_update_types(td::MutableSlice allowed_updates, bo
to_lower_inplace(type_name);
for (int32 i = 0; i < static_cast<int32>(UpdateType::Size); i++) {
if (get_update_type_name(static_cast<UpdateType>(i)) == type_name) {
- result |= (1 << i);
+ result |= (static_cast<td::uint64>(1) << i);
}
}
}
@@ -18001,7 +18001,7 @@ bool Client::update_allowed_update_types(const Query *query) {
if (allowed_update_types == DEFAULT_ALLOWED_UPDATE_TYPES) {
value = make_object<td_api::optionValueEmpty>();
} else {
- value = make_object<td_api::optionValueInteger>(allowed_update_types);
+ value = make_object<td_api::optionValueInteger>(static_cast<int64>(allowed_update_types));
}
send_request(make_object<td_api::setOption>("xallowed_update_types", std::move(value)),
td::make_unique<TdOnOkCallback>());
diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h
index 593f1fd..50630f2 100644
--- a/telegram-bot-api/Client.h
+++ b/telegram-bot-api/Client.h
@@ -1503,7 +1503,7 @@ class Client final : public WebhookActor::Callback {
static td::Slice get_update_type_name(UpdateType update_type);
- static td::uint32 get_allowed_update_types(td::MutableSlice allowed_updates, bool is_internal);
+ static td::uint64 get_allowed_update_types(td::MutableSlice allowed_updates, bool is_internal);
bool update_allowed_update_types(const Query *query);
@@ -1534,10 +1534,11 @@ class Client final : public WebhookActor::Callback {
bool have_message_access(int64 chat_id) const;
// by default ChatMember, MessageReaction, and MessageReactionCount updates are disabled
- static constexpr td::uint32 DEFAULT_ALLOWED_UPDATE_TYPES =
- (1 << static_cast<int32>(UpdateType::Size)) - 1 - (1 << static_cast<int32>(UpdateType::ChatMember)) -
- (1 << static_cast<int32>(UpdateType::MessageReaction)) -
- (1 << static_cast<int32>(UpdateType::MessageReactionCount));
+ static constexpr td::uint64 DEFAULT_ALLOWED_UPDATE_TYPES =
+ (static_cast<td::uint64>(1) << static_cast<int32>(UpdateType::Size)) - 1 -
+ (static_cast<td::uint64>(1) << static_cast<int32>(UpdateType::ChatMember)) -
+ (static_cast<td::uint64>(1) << static_cast<int32>(UpdateType::MessageReaction)) -
+ (static_cast<td::uint64>(1) << static_cast<int32>(UpdateType::MessageReactionCount));
object_ptr<td_api::AuthorizationState> authorization_state_;
bool was_authorized_ = false;
@@ -1703,7 +1704,7 @@ class Client final : public WebhookActor::Callback {
double next_bot_updates_warning_time_ = 0;
bool was_bot_updates_warning_ = false;
- td::uint32 allowed_update_types_ = DEFAULT_ALLOWED_UPDATE_TYPES;
+ td::uint64 allowed_update_types_ = DEFAULT_ALLOWED_UPDATE_TYPES;
bool has_webhook_certificate_ = false;
enum class WebhookQueryType { Cancel, Verify };