Fix quiz copying.
GitOrigin-RevId: f92b11f5327b7f6f67cb7e67ea7ee282a5f5cb23
This commit is contained in:
parent
695782fa84
commit
fb215a0287
@ -4170,6 +4170,14 @@ unique_ptr<MessageContent> dup_message_content(Td *td, DialogId dialog_id, const
|
||||
}
|
||||
return std::move(result);
|
||||
}
|
||||
case MessageContentType::Poll: {
|
||||
auto result = make_unique<MessagePoll>(*static_cast<const MessagePoll *>(content));
|
||||
if (type != MessageContentDupType::Forward && type != MessageContentDupType::SendViaBot &&
|
||||
!td->poll_manager_->has_input_media(result->poll_id)) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::move(result);
|
||||
}
|
||||
case MessageContentType::Sticker: {
|
||||
auto result = make_unique<MessageSticker>(*static_cast<const MessageSticker *>(content));
|
||||
if (td->stickers_manager_->has_input_media(result->file_id, to_secret)) {
|
||||
@ -4218,8 +4226,6 @@ unique_ptr<MessageContent> dup_message_content(Td *td, DialogId dialog_id, const
|
||||
CHECK(result->file_id.is_valid());
|
||||
return std::move(result);
|
||||
}
|
||||
case MessageContentType::Poll:
|
||||
return make_unique<MessagePoll>(*static_cast<const MessagePoll *>(content));
|
||||
case MessageContentType::Unsupported:
|
||||
case MessageContentType::ChatCreate:
|
||||
case MessageContentType::ChatChangeTitle:
|
||||
|
@ -1111,6 +1111,12 @@ void PollManager::on_online() {
|
||||
}
|
||||
}
|
||||
|
||||
bool PollManager::has_input_media(PollId poll_id) const {
|
||||
auto poll = get_poll(poll_id);
|
||||
CHECK(poll != nullptr);
|
||||
return !poll->is_quiz || poll->correct_option_id >= 0;
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> PollManager::get_input_media(PollId poll_id) const {
|
||||
auto poll = get_poll(poll_id);
|
||||
CHECK(poll != nullptr);
|
||||
@ -1130,6 +1136,8 @@ tl_object_ptr<telegram_api::InputMedia> PollManager::get_input_media(PollId poll
|
||||
vector<BufferSlice> correct_answers;
|
||||
if (poll->is_quiz) {
|
||||
flags |= telegram_api::inputMediaPoll::CORRECT_ANSWERS_MASK;
|
||||
CHECK(poll->correct_option_id >= 0);
|
||||
CHECK(static_cast<size_t>(poll->correct_option_id) < poll->options.size());
|
||||
correct_answers.push_back(BufferSlice(poll->options[poll->correct_option_id].data));
|
||||
}
|
||||
return telegram_api::make_object<telegram_api::inputMediaPoll>(
|
||||
|
@ -66,6 +66,8 @@ class PollManager : public Actor {
|
||||
|
||||
void stop_local_poll(PollId poll_id);
|
||||
|
||||
bool has_input_media(PollId poll_id) const;
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> get_input_media(PollId poll_id) const;
|
||||
|
||||
PollId on_get_poll(PollId poll_id, tl_object_ptr<telegram_api::poll> &&poll_server,
|
||||
|
Reference in New Issue
Block a user