Support request_users.max_quantity.

This commit is contained in:
levlam 2023-12-22 23:26:43 +03:00
parent 047a3e9922
commit 0fbcfa7eba

View File

@ -6459,17 +6459,23 @@ td::Result<td_api::object_ptr<td_api::keyboardButton>> Client::get_keyboard_butt
return make_object<td_api::keyboardButton>(text, make_object<td_api::keyboardButtonTypeWebApp>(url)); return make_object<td_api::keyboardButton>(text, make_object<td_api::keyboardButtonTypeWebApp>(url));
} }
if (object.has_field("request_user")) { if (object.has_field("request_user") || object.has_field("request_users")) {
TRY_RESULT(request_user, object.extract_required_field("request_user", td::JsonValue::Type::Object)); td::JsonValue request_user;
if (object.has_field("request_users")) {
TRY_RESULT_ASSIGN(request_user, object.extract_required_field("request_users", td::JsonValue::Type::Object));
} else {
TRY_RESULT_ASSIGN(request_user, object.extract_required_field("request_user", td::JsonValue::Type::Object));
}
auto &request_user_object = request_user.get_object(); auto &request_user_object = request_user.get_object();
TRY_RESULT(id, request_user_object.get_required_int_field("request_id")); TRY_RESULT(id, request_user_object.get_required_int_field("request_id"));
auto restrict_user_is_bot = request_user_object.has_field("user_is_bot"); auto restrict_user_is_bot = request_user_object.has_field("user_is_bot");
TRY_RESULT(user_is_bot, request_user_object.get_optional_bool_field("user_is_bot")); TRY_RESULT(user_is_bot, request_user_object.get_optional_bool_field("user_is_bot"));
auto restrict_user_is_premium = request_user_object.has_field("user_is_premium"); auto restrict_user_is_premium = request_user_object.has_field("user_is_premium");
TRY_RESULT(user_is_premium, request_user_object.get_optional_bool_field("user_is_premium")); TRY_RESULT(user_is_premium, request_user_object.get_optional_bool_field("user_is_premium"));
TRY_RESULT(max_quantity, request_user_object.get_optional_int_field("max_quantity", 1));
return make_object<td_api::keyboardButton>( return make_object<td_api::keyboardButton>(
text, make_object<td_api::keyboardButtonTypeRequestUsers>(id, restrict_user_is_bot, user_is_bot, text, make_object<td_api::keyboardButtonTypeRequestUsers>(
restrict_user_is_premium, user_is_premium, 1)); id, restrict_user_is_bot, user_is_bot, restrict_user_is_premium, user_is_premium, max_quantity));
} }
if (object.has_field("request_chat")) { if (object.has_field("request_chat")) {