Add poll search text.

GitOrigin-RevId: a7da84edd364361186db1cf0807759b94b601f95
This commit is contained in:
levlam 2019-03-03 06:36:30 +03:00
parent dd7af98c8e
commit 0b689bdc23
3 changed files with 18 additions and 1 deletions

View File

@ -4700,6 +4700,10 @@ string get_message_content_search_text(const Td *td, const MessageContent *conte
auto video = static_cast<const MessageVideo *>(content);
return PSTRING() << td->videos_manager_->get_video_search_text(video->file_id) << " " << video->caption.text;
}
case MessageContentType::Poll: {
auto poll = static_cast<const MessagePoll *>(content);
return td->poll_manager_->get_poll_search_text(poll->poll_id);
}
case MessageContentType::Contact:
case MessageContentType::Game:
case MessageContentType::Invoice:
@ -4733,7 +4737,6 @@ string get_message_content_search_text(const Td *td, const MessageContent *conte
case MessageContentType::WebsiteConnected:
case MessageContentType::PassportDataSent:
case MessageContentType::PassportDataReceived:
case MessageContentType::Poll:
return string();
default:
UNREACHABLE();

View File

@ -391,6 +391,18 @@ bool PollManager::get_poll_is_closed(PollId poll_id) const {
return poll->is_closed;
}
string PollManager::get_poll_search_text(PollId poll_id) const {
auto poll = get_poll(poll_id);
CHECK(poll != nullptr);
string result = poll->question;
for (auto &option : poll->options) {
result += ' ';
result += option.text;
}
return result;
}
void PollManager::set_poll_answer(PollId poll_id, FullMessageId full_message_id, vector<int32> &&option_ids,
Promise<Unit> &&promise) {
if (option_ids.size() > 1) {

View File

@ -48,6 +48,8 @@ class PollManager : public Actor {
bool get_poll_is_closed(PollId poll_id) const;
string get_poll_search_text(PollId poll_id) const;
void set_poll_answer(PollId poll_id, FullMessageId full_message_id, vector<int32> &&option_ids,
Promise<Unit> &&promise);