Fix inline query type detection.

GitOrigin-RevId: 09dda10c23f587efb790237d5e50009c1a10a599
This commit is contained in:
levlam 2018-03-13 02:12:51 +03:00
parent d9e76824ab
commit 62e1f418e2

View File

@ -1253,6 +1253,9 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6
case telegram_api::botInlineMediaResult::ID: { case telegram_api::botInlineMediaResult::ID: {
auto result = move_tl_object_as<telegram_api::botInlineMediaResult>(result_ptr); auto result = move_tl_object_as<telegram_api::botInlineMediaResult>(result_ptr);
auto flags = result->flags_; auto flags = result->flags_;
bool has_document = (flags & BOT_INLINE_MEDIA_RESULT_FLAG_HAS_DOCUMENT) != 0;
bool has_photo = (flags & BOT_INLINE_MEDIA_RESULT_FLAG_HAS_PHOTO) != 0;
bool is_photo = result->type_ == "photo";
if (result->type_ == "game") { if (result->type_ == "game") {
auto game = make_tl_object<td_api::inlineQueryResultGame>(); auto game = make_tl_object<td_api::inlineQueryResultGame>();
Game inline_game(td_, std::move(result->title_), std::move(result->description_), std::move(result->photo_), Game inline_game(td_, std::move(result->title_), std::move(result->description_), std::move(result->photo_),
@ -1267,7 +1270,7 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6
continue; continue;
} }
output_result = std::move(game); output_result = std::move(game);
} else if (flags & BOT_INLINE_MEDIA_RESULT_FLAG_HAS_DOCUMENT) { } else if (has_document && !(has_photo && is_photo)) {
auto document_ptr = std::move(result->document_); auto document_ptr = std::move(result->document_);
int32 document_id = document_ptr->get_id(); int32 document_id = document_ptr->get_id();
if (document_id == telegram_api::documentEmpty::ID) { if (document_id == telegram_api::documentEmpty::ID) {
@ -1383,7 +1386,8 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6
UNREACHABLE(); UNREACHABLE();
break; break;
} }
} else if (flags & BOT_INLINE_MEDIA_RESULT_FLAG_HAS_PHOTO) { } else if (has_photo) {
LOG_IF(ERROR, !is_photo) << "Wrong result type " << result->type_;
auto photo = make_tl_object<td_api::inlineQueryResultPhoto>(); auto photo = make_tl_object<td_api::inlineQueryResultPhoto>();
photo->id_ = std::move(result->id_); photo->id_ = std::move(result->id_);
auto photo_ptr = std::move(result->photo_); auto photo_ptr = std::move(result->photo_);