Close failed to send polls.

GitOrigin-RevId: 6f9dcde4bbfcbc1fa63ed94641775007e3091706
This commit is contained in:
levlam 2019-02-19 17:06:48 +03:00
parent 5ef99afec7
commit 9de3304ec4
5 changed files with 38 additions and 0 deletions

View File

@ -4756,6 +4756,24 @@ void update_expired_message_content(unique_ptr<MessageContent> &content) {
}
}
void update_failed_to_send_message_content(Td *td, unique_ptr<MessageContent> &content) {
switch (content->get_type()) {
case MessageContentType::LiveLocation: {
MessageLiveLocation *message_live_location = static_cast<MessageLiveLocation *>(content.get());
message_live_location->period = 1;
break;
}
case MessageContentType::Poll: {
const MessagePoll *message_poll = static_cast<const MessagePoll *>(content.get());
td->poll_manager_->close_poll(message_poll->poll_id);
break;
}
default:
// nothing to do
break;
}
}
void add_message_content_dependencies(Dependencies &dependencies, const MessageContent *message_content) {
switch (message_content->get_type()) {
case MessageContentType::Text: {

View File

@ -227,6 +227,8 @@ bool need_delay_message_content_notification(const MessageContent *content, User
void update_expired_message_content(unique_ptr<MessageContent> &content);
void update_failed_to_send_message_content(Td *td, unique_ptr<MessageContent> &content);
void add_message_content_dependencies(Dependencies &dependencies, const MessageContent *message_content);
void on_sent_message_content(Td *td, const MessageContent *content);

View File

@ -19382,6 +19382,8 @@ void MessagesManager::fail_send_message(FullMessageId full_message_id, int error
message->random_y = get_random_y(message->message_id);
message->is_failed_to_send = true;
update_failed_to_send_message_content(td_, message->content);
message->have_previous = true;
message->have_next = true;

View File

@ -143,6 +143,20 @@ PollId PollManager::create_poll(string &&question, vector<string> &&answers) {
return poll_id;
}
void PollManager::close_poll(PollId poll_id) {
auto poll = get_poll_editable(poll_id);
CHECK(poll != nullptr);
if (poll->is_closed) {
return;
}
poll->is_closed = true;
if (!is_local_poll_id(poll_id)) {
// TODO send poll close request to the server + LogEvent
save_poll(poll, poll_id);
}
}
tl_object_ptr<telegram_api::InputMedia> PollManager::get_input_media(PollId poll_id) const {
auto poll = get_poll(poll_id);
CHECK(poll != nullptr);

View File

@ -34,6 +34,8 @@ class PollManager : public Actor {
PollId create_poll(string &&question, vector<string> &&answers);
void close_poll(PollId poll_id);
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,