Check that input content is non-empty inside corresponding functions.

This commit is contained in:
levlam 2023-05-25 21:25:16 +03:00
parent 2684df5f01
commit 936c27577e
4 changed files with 7 additions and 8 deletions

View File

@ -2259,6 +2259,9 @@ static Result<InputMessageContent> create_input_message_content(
Result<InputMessageContent> get_input_message_content(
DialogId dialog_id, tl_object_ptr<td_api::InputMessageContent> &&input_message_content, Td *td, bool is_premium) {
LOG(INFO) << "Get input message content from " << to_string(input_message_content);
if (input_message_content == nullptr) {
return Status::Error(400, "Input message content must be non-empty");
}
td_api::object_ptr<td_api::InputFile> input_file;
auto file_type = FileType::None;

View File

@ -24958,11 +24958,7 @@ Result<td_api::object_ptr<td_api::message>> MessagesManager::send_message(
Result<InputMessageContent> MessagesManager::process_input_message_content(
DialogId dialog_id, tl_object_ptr<td_api::InputMessageContent> &&input_message_content) {
if (input_message_content == nullptr) {
return Status::Error(400, "Can't send message without content");
}
if (input_message_content->get_id() == td_api::inputMessageForwarded::ID) {
if (input_message_content != nullptr && input_message_content->get_id() == td_api::inputMessageForwarded::ID) {
// for sendMessageAlbum/editMessageMedia/addLocalMessage
auto input_message = td_api::move_object_as<td_api::inputMessageForwarded>(input_message_content);
TRY_RESULT(copy_options, process_message_copy_options(dialog_id, std::move(input_message->copy_options_)));

View File

@ -136,6 +136,9 @@ unique_ptr<StoryContent> get_story_content(Td *td, tl_object_ptr<telegram_api::M
Result<unique_ptr<StoryContent>> get_input_story_content(
Td *td, td_api::object_ptr<td_api::InputStoryContent> &&input_story_content, DialogId owner_dialog_id) {
LOG(INFO) << "Get input story content from " << to_string(input_story_content);
if (input_story_content == nullptr) {
return Status::Error(400, "Input story content must be non-empty");
}
switch (input_story_content->get_id()) {
case td_api::inputStoryContentPhoto::ID: {

View File

@ -565,9 +565,6 @@ void StoryManager::send_story(td_api::object_ptr<td_api::InputStoryContent> &&in
td_api::object_ptr<td_api::formattedText> &&input_caption,
td_api::object_ptr<td_api::userPrivacySettingRules> &&rules, bool is_pinned,
Promise<td_api::object_ptr<td_api::story>> &&promise) {
if (input_story_content == nullptr) {
return promise.set_error(Status::Error(400, "Can't send story without content"));
}
bool is_bot = td_->auth_manager_->is_bot();
DialogId dialog_id(td_->contacts_manager_->get_my_id());
TRY_RESULT_PROMISE(promise, content, get_input_story_content(td_, std::move(input_story_content), dialog_id));