Always use "must be non-empty".

This commit is contained in:
levlam 2022-09-10 22:48:34 +03:00
parent 345c930aa7
commit ce9175a00b
9 changed files with 17 additions and 17 deletions

View File

@ -133,7 +133,7 @@ void set_menu_button(Td *td, UserId user_id, td_api::object_ptr<td_api::botMenuB
input_bot_menu_button = telegram_api::make_object<telegram_api::botMenuButtonCommands>(); input_bot_menu_button = telegram_api::make_object<telegram_api::botMenuButtonCommands>();
} else if (menu_button->text_.empty()) { } else if (menu_button->text_.empty()) {
if (menu_button->url_ != "default") { if (menu_button->url_ != "default") {
return promise.set_error(Status::Error(400, "Menu button text can't be empty")); return promise.set_error(Status::Error(400, "Menu button text must be non-empty"));
} }
input_bot_menu_button = telegram_api::make_object<telegram_api::botMenuButtonDefault>(); input_bot_menu_button = telegram_api::make_object<telegram_api::botMenuButtonDefault>();
} else { } else {

View File

@ -346,7 +346,7 @@ Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager:
tl_object_ptr<td_api::InputMessageContent> &&input_message_content, tl_object_ptr<td_api::InputMessageContent> &&input_message_content,
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup_ptr, int32 allowed_media_content_id) const { tl_object_ptr<td_api::ReplyMarkup> &&reply_markup_ptr, int32 allowed_media_content_id) const {
if (input_message_content == nullptr) { if (input_message_content == nullptr) {
return Status::Error(400, "Inline message can't be empty"); return Status::Error(400, "Inline message must be non-empty");
} }
TRY_RESULT(reply_markup, get_reply_markup(std::move(reply_markup_ptr), true, true, false, true)); TRY_RESULT(reply_markup, get_reply_markup(std::move(reply_markup_ptr), true, true, false, true));
auto input_reply_markup = get_input_reply_markup(td_->contacts_manager_.get(), reply_markup); auto input_reply_markup = get_input_reply_markup(td_->contacts_manager_.get(), reply_markup);

View File

@ -2794,7 +2794,7 @@ bool can_forward_message_content(const MessageContent *content) {
auto content_type = content->get_type(); auto content_type = content->get_type();
if (content_type == MessageContentType::Text) { if (content_type == MessageContentType::Text) {
auto *text = static_cast<const MessageText *>(content); auto *text = static_cast<const MessageText *>(content);
return !is_empty_string(text->text.text); // text can't be empty in the new message return !is_empty_string(text->text.text); // text must be non-empty in the new message
} }
if (content_type == MessageContentType::Poll) { if (content_type == MessageContentType::Poll) {
auto *poll = static_cast<const MessagePoll *>(content); auto *poll = static_cast<const MessagePoll *>(content);

View File

@ -20696,7 +20696,7 @@ DialogId MessagesManager::create_new_group_chat(const vector<UserId> &user_ids,
auto new_title = clean_name(title, MAX_TITLE_LENGTH); auto new_title = clean_name(title, MAX_TITLE_LENGTH);
if (new_title.empty()) { if (new_title.empty()) {
promise.set_error(Status::Error(400, "Title can't be empty")); promise.set_error(Status::Error(400, "Title must be non-empty"));
return DialogId(); return DialogId();
} }
@ -20744,7 +20744,7 @@ DialogId MessagesManager::create_new_channel_chat(const string &title, bool is_m
auto new_title = clean_name(title, MAX_TITLE_LENGTH); auto new_title = clean_name(title, MAX_TITLE_LENGTH);
if (new_title.empty()) { if (new_title.empty()) {
promise.set_error(Status::Error(400, "Title can't be empty")); promise.set_error(Status::Error(400, "Title must be non-empty"));
return DialogId(); return DialogId();
} }
@ -33748,7 +33748,7 @@ void MessagesManager::set_dialog_title(DialogId dialog_id, const string &title,
auto new_title = clean_name(title, MAX_TITLE_LENGTH); auto new_title = clean_name(title, MAX_TITLE_LENGTH);
if (new_title.empty()) { if (new_title.empty()) {
return promise.set_error(Status::Error(400, "Title can't be empty")); return promise.set_error(Status::Error(400, "Title must be non-empty"));
} }
switch (dialog_id.get_type()) { switch (dialog_id.get_type()) {

View File

@ -45,7 +45,7 @@ void PhoneNumberManager::send_new_send_code_query(uint64 query_id, const telegra
void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number, Settings settings) { void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number, Settings settings) {
if (phone_number.empty()) { if (phone_number.empty()) {
return on_query_error(query_id, Status::Error(400, "Phone number can't be empty")); return on_query_error(query_id, Status::Error(400, "Phone number must be non-empty"));
} }
switch (type_) { switch (type_) {
@ -64,10 +64,10 @@ void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number,
void PhoneNumberManager::set_phone_number_and_hash(uint64 query_id, string hash, string phone_number, void PhoneNumberManager::set_phone_number_and_hash(uint64 query_id, string hash, string phone_number,
Settings settings) { Settings settings) {
if (phone_number.empty()) { if (phone_number.empty()) {
return on_query_error(query_id, Status::Error(400, "Phone number can't be empty")); return on_query_error(query_id, Status::Error(400, "Phone number must be non-empty"));
} }
if (hash.empty()) { if (hash.empty()) {
return on_query_error(query_id, Status::Error(400, "Hash can't be empty")); return on_query_error(query_id, Status::Error(400, "Hash must be non-empty"));
} }
switch (type_) { switch (type_) {

View File

@ -500,7 +500,7 @@ static Result<InlineKeyboardButton> get_inline_keyboard_button(tl_object_ptr<td_
current_button.text = std::move(button->text_); current_button.text = std::move(button->text_);
if (button->type_ == nullptr) { if (button->type_ == nullptr) {
return Status::Error(400, "Inline keyboard button type can't be empty"); return Status::Error(400, "Inline keyboard button type must be non-empty");
} }
int32 button_type_id = button->type_->get_id(); int32 button_type_id = button->type_->get_id();

View File

@ -6995,7 +6995,7 @@ tl_object_ptr<telegram_api::inputStickerSetItem> StickersManager::get_input_stic
void StickersManager::get_suggested_sticker_set_name(string title, Promise<string> &&promise) { void StickersManager::get_suggested_sticker_set_name(string title, Promise<string> &&promise) {
title = strip_empty_characters(title, MAX_STICKER_SET_TITLE_LENGTH); title = strip_empty_characters(title, MAX_STICKER_SET_TITLE_LENGTH);
if (title.empty()) { if (title.empty()) {
return promise.set_error(Status::Error(400, "Sticker set title can't be empty")); return promise.set_error(Status::Error(400, "Sticker set title must be non-empty"));
} }
td_->create_handler<SuggestStickerSetShortNameQuery>(std::move(promise))->send(title); td_->create_handler<SuggestStickerSetShortNameQuery>(std::move(promise))->send(title);
@ -7052,12 +7052,12 @@ void StickersManager::create_new_sticker_set(UserId user_id, string title, strin
title = strip_empty_characters(title, MAX_STICKER_SET_TITLE_LENGTH); title = strip_empty_characters(title, MAX_STICKER_SET_TITLE_LENGTH);
if (title.empty()) { if (title.empty()) {
return promise.set_error(Status::Error(400, "Sticker set title can't be empty")); return promise.set_error(Status::Error(400, "Sticker set title must be non-empty"));
} }
short_name = strip_empty_characters(short_name, MAX_STICKER_SET_SHORT_NAME_LENGTH); short_name = strip_empty_characters(short_name, MAX_STICKER_SET_SHORT_NAME_LENGTH);
if (short_name.empty()) { if (short_name.empty()) {
return promise.set_error(Status::Error(400, "Sticker set name can't be empty")); return promise.set_error(Status::Error(400, "Sticker set name must be non-empty"));
} }
if (stickers.empty()) { if (stickers.empty()) {
@ -7292,7 +7292,7 @@ void StickersManager::add_sticker_to_set(UserId user_id, string short_name,
short_name = clean_username(strip_empty_characters(short_name, MAX_STICKER_SET_SHORT_NAME_LENGTH)); short_name = clean_username(strip_empty_characters(short_name, MAX_STICKER_SET_SHORT_NAME_LENGTH));
if (short_name.empty()) { if (short_name.empty()) {
return promise.set_error(Status::Error(400, "Sticker set name can't be empty")); return promise.set_error(Status::Error(400, "Sticker set name must be non-empty"));
} }
const StickerSet *sticker_set = get_sticker_set(short_name_to_sticker_set_id_.get(short_name)); const StickerSet *sticker_set = get_sticker_set(short_name_to_sticker_set_id_.get(short_name));
@ -7386,7 +7386,7 @@ void StickersManager::set_sticker_set_thumbnail(UserId user_id, string short_nam
short_name = clean_username(strip_empty_characters(short_name, MAX_STICKER_SET_SHORT_NAME_LENGTH)); short_name = clean_username(strip_empty_characters(short_name, MAX_STICKER_SET_SHORT_NAME_LENGTH));
if (short_name.empty()) { if (short_name.empty()) {
return promise.set_error(Status::Error(400, "Sticker set name can't be empty")); return promise.set_error(Status::Error(400, "Sticker set name must be non-empty"));
} }
const StickerSet *sticker_set = get_sticker_set(short_name_to_sticker_set_id_.get(short_name)); const StickerSet *sticker_set = get_sticker_set(short_name_to_sticker_set_id_.get(short_name));

View File

@ -2913,7 +2913,7 @@ Result<FileId> FileManager::from_persistent_id(CSlice persistent_id, FileType fi
} }
auto binary = r_binary.move_as_ok(); auto binary = r_binary.move_as_ok();
if (binary.empty()) { if (binary.empty()) {
return Status::Error(400, "Remote file identifier can't be empty"); return Status::Error(400, "Remote file identifier must be non-empty");
} }
if (binary.back() == FileNode::PERSISTENT_ID_VERSION_OLD) { if (binary.back() == FileNode::PERSISTENT_ID_VERSION_OLD) {
return from_persistent_id_v2(binary, file_type); return from_persistent_id_v2(binary, file_type);

View File

@ -18,7 +18,7 @@ namespace td {
Status FileLog::init(string path, int64 rotate_threshold, bool redirect_stderr) { Status FileLog::init(string path, int64 rotate_threshold, bool redirect_stderr) {
if (path.empty()) { if (path.empty()) {
return Status::Error("Log file path can't be empty"); return Status::Error("Log file path must be non-empty");
} }
if (path == path_) { if (path == path_) {
set_rotate_threshold(rotate_threshold); set_rotate_threshold(rotate_threshold);