Remove unallowed custom emoji when copying poll.

This commit is contained in:
levlam 2024-04-23 22:10:48 +03:00
parent e812370dc5
commit 9fa1656557
3 changed files with 8 additions and 3 deletions

View File

@ -6359,7 +6359,7 @@ unique_ptr<MessageContent> dup_message_content(Td *td, DialogId dialog_id, const
case MessageContentType::Poll:
if (type == MessageContentDupType::Copy || type == MessageContentDupType::ServerCopy) {
return make_unique<MessagePoll>(
td->poll_manager_->dup_poll(static_cast<const MessagePoll *>(content)->poll_id));
td->poll_manager_->dup_poll(dialog_id, static_cast<const MessagePoll *>(content)->poll_id));
} else {
return make_unique<MessagePoll>(*static_cast<const MessagePoll *>(content));
}

View File

@ -1501,13 +1501,18 @@ void PollManager::on_online() {
});
}
PollId PollManager::dup_poll(PollId poll_id) {
PollId PollManager::dup_poll(DialogId dialog_id, PollId poll_id) {
auto poll = get_poll(poll_id);
CHECK(poll != nullptr);
auto question = poll->question_;
::td::remove_unallowed_entities(td_, question, dialog_id);
auto options = transform(poll->options_, [](auto &option) { return option.text_; });
for (auto &option : options) {
::td::remove_unallowed_entities(td_, option, dialog_id);
}
auto explanation = poll->explanation_;
::td::remove_unallowed_entities(td_, explanation, dialog_id);
return create_poll(std::move(question), std::move(options), poll->is_anonymous_, poll->allow_multiple_answers_,
poll->is_quiz_, poll->correct_option_id_, std::move(explanation), poll->open_period_,
poll->open_period_ == 0 ? 0 : G()->unix_time(), false);

View File

@ -78,7 +78,7 @@ class PollManager final : public Actor {
void stop_local_poll(PollId poll_id);
PollId dup_poll(PollId poll_id);
PollId dup_poll(DialogId dialog_id, PollId poll_id);
bool has_input_media(PollId poll_id) const;