Fix inline results attributes.

GitOrigin-RevId: 42597e979cd851cdddb1f62f85453dee61f048ab
This commit is contained in:
levlam 2018-04-04 10:21:21 +03:00
parent 1035a5a6c0
commit 7626910c45

View File

@ -764,6 +764,10 @@ void InlineQueriesManager::answer_inline_query(int64 inline_query_id, bool is_pe
return promise.set_error(Status::Error(400, "Sent message content should be explicitly specified"));
}
if (duration < 0) {
duration = 0;
}
int32 flags = 0;
if (!title.empty()) {
flags |= telegram_api::inputBotInlineResult::TITLE_MASK;
@ -839,14 +843,13 @@ void InlineQueriesManager::answer_inline_query(int64 inline_query_id, bool is_pe
vector<tl_object_ptr<telegram_api::DocumentAttribute>> attributes;
if (width > 0 && height > 0) {
if (duration > 0 && !begins_with(content_type, "image/")) {
if ((duration > 0 || type == "video" || content_type == "video/mp4") && !begins_with(content_type, "image/")) {
attributes.push_back(make_tl_object<telegram_api::documentAttributeVideo>(
0, false /*ignored*/, false /*ignored*/, duration, width, height));
} else {
attributes.push_back(make_tl_object<telegram_api::documentAttributeImageSize>(width, height));
}
} else if (duration > 0) {
if (type == "audio") {
} else if (type == "audio") {
attributes.push_back(make_tl_object<telegram_api::documentAttributeAudio>(
telegram_api::documentAttributeAudio::TITLE_MASK | telegram_api::documentAttributeAudio::PERFORMER_MASK,
false /*ignored*/, duration, title, description, BufferSlice()));
@ -854,7 +857,6 @@ void InlineQueriesManager::answer_inline_query(int64 inline_query_id, bool is_pe
attributes.push_back(make_tl_object<telegram_api::documentAttributeAudio>(
telegram_api::documentAttributeAudio::VOICE_MASK, false /*ignored*/, duration, "", "", BufferSlice()));
}
}
attributes.push_back(make_tl_object<telegram_api::documentAttributeFilename>(get_url_file_name(content_url)));
content = make_tl_object<telegram_api::inputWebDocument>(content_url, 0, content_type, std::move(attributes));