Close failed to send polls.
GitOrigin-RevId: 6f9dcde4bbfcbc1fa63ed94641775007e3091706
This commit is contained in:
parent
5ef99afec7
commit
9de3304ec4
@ -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: {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user