Fix registering polls in a just sent message.
GitOrigin-RevId: cea331e39437aa6376048fb78a569f3d908f7022
This commit is contained in:
parent
6af95d721d
commit
812398ae7b
@ -15629,7 +15629,7 @@ void MessagesManager::on_upload_message_media_success(DialogId dialog_id, Messag
|
||||
auto content = get_message_content(td_, caption == nullptr ? FormattedText() : *caption, std::move(media), dialog_id,
|
||||
false, UserId(), nullptr);
|
||||
|
||||
update_message_content(dialog_id, m, std::move(content), true, true);
|
||||
update_message_content(dialog_id, m, std::move(content), true, true, true);
|
||||
|
||||
auto input_media = get_input_media(m->content.get(), td_, m->ttl);
|
||||
Status result;
|
||||
@ -16466,7 +16466,7 @@ void MessagesManager::on_message_media_edited(DialogId dialog_id, MessageId mess
|
||||
std::swap(m->content, m->edited_content);
|
||||
bool need_send_update_message_content = m->edited_content->get_type() == MessageContentType::Photo &&
|
||||
m->content->get_type() == MessageContentType::Photo;
|
||||
update_message_content(dialog_id, m, std::move(m->edited_content), need_send_update_message_content, true);
|
||||
update_message_content(dialog_id, m, std::move(m->edited_content), need_send_update_message_content, true, true);
|
||||
} else {
|
||||
if (was_uploaded) {
|
||||
if (was_thumbnail_uploaded) {
|
||||
@ -22446,7 +22446,8 @@ bool MessagesManager::update_message(Dialog *d, unique_ptr<Message> &old_message
|
||||
}
|
||||
|
||||
if (update_message_content(dialog_id, old_message.get(), std::move(new_message->content), true,
|
||||
message_id.is_yet_unsent() && new_message->edit_date == 0)) {
|
||||
message_id.is_yet_unsent() && new_message->edit_date == 0,
|
||||
get_message(d, message_id) != nullptr)) {
|
||||
is_changed = true;
|
||||
}
|
||||
// TODO update can be send only if the message has already been returned to the user
|
||||
@ -22472,7 +22473,8 @@ bool MessagesManager::need_message_changed_warning(const Message *old_message) {
|
||||
|
||||
bool MessagesManager::update_message_content(DialogId dialog_id, Message *old_message,
|
||||
unique_ptr<MessageContent> new_content,
|
||||
bool need_send_update_message_content, bool need_merge_files) {
|
||||
bool need_send_update_message_content, bool need_merge_files,
|
||||
bool is_message_in_dialog) {
|
||||
bool is_content_changed = false;
|
||||
bool need_update = false;
|
||||
unique_ptr<MessageContent> &old_content = old_message->content;
|
||||
@ -22536,9 +22538,13 @@ bool MessagesManager::update_message_content(DialogId dialog_id, Message *old_me
|
||||
}
|
||||
|
||||
if (is_content_changed || need_update) {
|
||||
unregister_message_content(td_, old_content.get(), {dialog_id, old_message->message_id});
|
||||
if (is_message_in_dialog) {
|
||||
unregister_message_content(td_, old_content.get(), {dialog_id, old_message->message_id});
|
||||
}
|
||||
old_content = std::move(new_content);
|
||||
register_message_content(td_, old_content.get(), {dialog_id, old_message->message_id});
|
||||
if (is_message_in_dialog) {
|
||||
register_message_content(td_, old_content.get(), {dialog_id, old_message->message_id});
|
||||
}
|
||||
update_message_content_file_id_remote(old_content.get(), old_file_id);
|
||||
} else {
|
||||
update_message_content_file_id_remote(old_content.get(), get_message_content_file_id(new_content.get()));
|
||||
|
@ -1552,7 +1552,7 @@ class MessagesManager : public Actor {
|
||||
static bool need_message_changed_warning(const Message *old_message);
|
||||
|
||||
bool update_message_content(DialogId dialog_id, Message *old_message, unique_ptr<MessageContent> new_content,
|
||||
bool need_send_update_message_content, bool need_merge_files);
|
||||
bool need_send_update_message_content, bool need_merge_files, bool is_message_in_dialog);
|
||||
|
||||
void send_update_new_message(const Dialog *d, const Message *m);
|
||||
|
||||
|
@ -359,11 +359,13 @@ PollId PollManager::create_poll(string &&question, vector<string> &&options) {
|
||||
CHECK(is_local_poll_id(poll_id));
|
||||
bool is_inserted = polls_.emplace(poll_id, std::move(poll)).second;
|
||||
CHECK(is_inserted);
|
||||
LOG(INFO) << "Created " << poll_id << " with question \"" << oneline(question) << '"';
|
||||
return poll_id;
|
||||
}
|
||||
|
||||
void PollManager::register_poll(PollId poll_id, FullMessageId full_message_id) {
|
||||
CHECK(have_poll(poll_id));
|
||||
LOG(INFO) << "Register " << poll_id << " from " << full_message_id;
|
||||
poll_messages_[poll_id].insert(full_message_id);
|
||||
if (!td_->auth_manager_->is_bot() && !is_local_poll_id(poll_id) && !get_poll_is_closed(poll_id)) {
|
||||
update_poll_timeout_.add_timeout_in(poll_id.get(), 0);
|
||||
@ -372,6 +374,7 @@ void PollManager::register_poll(PollId poll_id, FullMessageId full_message_id) {
|
||||
|
||||
void PollManager::unregister_poll(PollId poll_id, FullMessageId full_message_id) {
|
||||
CHECK(have_poll(poll_id));
|
||||
LOG(INFO) << "Unregister " << poll_id << " from " << full_message_id;
|
||||
auto &message_ids = poll_messages_[poll_id];
|
||||
message_ids.erase(full_message_id);
|
||||
if (message_ids.empty()) {
|
||||
@ -435,6 +438,7 @@ class PollManager::SetPollAnswerLogEvent {
|
||||
|
||||
void PollManager::do_set_poll_answer(PollId poll_id, FullMessageId full_message_id, vector<string> &&options,
|
||||
uint64 logevent_id, Promise<Unit> &&promise) {
|
||||
LOG(INFO) << "Set answer in " << poll_id << " from " << full_message_id;
|
||||
auto &pending_answer = pending_answers_[poll_id];
|
||||
if (!pending_answer.promises_.empty() && pending_answer.options_ == options) {
|
||||
pending_answer.promises_.push_back(std::move(promise));
|
||||
@ -570,6 +574,7 @@ class PollManager::StopPollLogEvent {
|
||||
|
||||
void PollManager::do_stop_poll(PollId poll_id, FullMessageId full_message_id, uint64 logevent_id,
|
||||
Promise<Unit> &&promise) {
|
||||
LOG(INFO) << "Stop " << poll_id << " from " << full_message_id;
|
||||
if (logevent_id == 0 && G()->parameters().use_message_db) {
|
||||
StopPollLogEvent logevent{poll_id, full_message_id};
|
||||
auto storer = LogEventStorerImpl<StopPollLogEvent>(logevent);
|
||||
|
Loading…
Reference in New Issue
Block a user