Support updateDeleteScheduledMessages.
GitOrigin-RevId: 9f2d0cf00a3e6ffe20c1b0834cad69fbb0861ad7
This commit is contained in:
parent
c7252bc11a
commit
bfd3d653a7
@ -5729,6 +5729,40 @@ void MessagesManager::on_update_dialog_online_member_count(DialogId dialog_id, i
|
|||||||
"on_update_channel_online_member_count");
|
"on_update_channel_online_member_count");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessagesManager::on_update_delete_scheduled_messages(DialogId dialog_id,
|
||||||
|
vector<ScheduledServerMessageId> &&server_message_ids) {
|
||||||
|
if (td_->auth_manager_->is_bot()) {
|
||||||
|
// just in case
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dialog_id.is_valid()) {
|
||||||
|
LOG(ERROR) << "Receive deleted scheduled messages in invalid " << dialog_id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dialog *d = get_dialog_force(dialog_id);
|
||||||
|
if (d == nullptr) {
|
||||||
|
LOG(INFO) << "Skip updateDeleteScheduledMessages in unknown " << dialog_id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<int64> deleted_message_ids;
|
||||||
|
for (auto server_message_id : server_message_ids) {
|
||||||
|
if (!server_message_id.is_valid()) {
|
||||||
|
LOG(ERROR) << "Incoming update tries to delete scheduled message " << server_message_id.get();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto message = do_delete_scheduled_message(d, MessageId(server_message_id, std::numeric_limits<int32>::max()), true,
|
||||||
|
"on_update_delete_scheduled_messages");
|
||||||
|
if (message != nullptr) {
|
||||||
|
deleted_message_ids.push_back(message->message_id.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
send_update_delete_messages(dialog_id, std::move(deleted_message_ids), true, false);
|
||||||
|
}
|
||||||
|
|
||||||
void MessagesManager::on_update_include_sponsored_dialog_to_unread_count() {
|
void MessagesManager::on_update_include_sponsored_dialog_to_unread_count() {
|
||||||
if (td_->auth_manager_->is_bot()) {
|
if (td_->auth_manager_->is_bot()) {
|
||||||
// just in case
|
// just in case
|
||||||
@ -25411,6 +25445,8 @@ MessagesManager::Message *MessagesManager::add_scheduled_message_to_dialog(Dialo
|
|||||||
}
|
}
|
||||||
if (old_message_id != message_id) {
|
if (old_message_id != message_id) {
|
||||||
message = do_delete_scheduled_message(d, old_message_id, false, "add_scheduled_message_to_dialog");
|
message = do_delete_scheduled_message(d, old_message_id, false, "add_scheduled_message_to_dialog");
|
||||||
|
CHECK(message != nullptr);
|
||||||
|
send_update_delete_messages(dialog_id, {old_message_id.get()}, false, false);
|
||||||
message->message_id = message_id;
|
message->message_id = message_id;
|
||||||
message->random_y = get_random_y(message->message_id);
|
message->random_y = get_random_y(message->message_id);
|
||||||
} else {
|
} else {
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "td/telegram/NotificationSettings.h"
|
#include "td/telegram/NotificationSettings.h"
|
||||||
#include "td/telegram/ReplyMarkup.h"
|
#include "td/telegram/ReplyMarkup.h"
|
||||||
#include "td/telegram/RestrictionReason.h"
|
#include "td/telegram/RestrictionReason.h"
|
||||||
|
#include "td/telegram/ScheduledServerMessageId.h"
|
||||||
#include "td/telegram/SecretChatId.h"
|
#include "td/telegram/SecretChatId.h"
|
||||||
#include "td/telegram/SecretInputMedia.h"
|
#include "td/telegram/SecretInputMedia.h"
|
||||||
#include "td/telegram/ServerMessageId.h"
|
#include "td/telegram/ServerMessageId.h"
|
||||||
@ -319,6 +320,8 @@ class MessagesManager : public Actor {
|
|||||||
|
|
||||||
void on_update_dialog_online_member_count(DialogId dialog_id, int32 online_member_count, bool is_from_server);
|
void on_update_dialog_online_member_count(DialogId dialog_id, int32 online_member_count, bool is_from_server);
|
||||||
|
|
||||||
|
void on_update_delete_scheduled_messages(DialogId dialog_id, vector<ScheduledServerMessageId> &&server_message_ids);
|
||||||
|
|
||||||
void on_update_include_sponsored_dialog_to_unread_count();
|
void on_update_include_sponsored_dialog_to_unread_count();
|
||||||
|
|
||||||
void on_user_dialog_action(DialogId dialog_id, UserId user_id, tl_object_ptr<td_api::ChatAction> &&action, int32 date,
|
void on_user_dialog_action(DialogId dialog_id, UserId user_id, tl_object_ptr<td_api::ChatAction> &&action, int32 date,
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "td/telegram/PollId.h"
|
#include "td/telegram/PollId.h"
|
||||||
#include "td/telegram/PollManager.h"
|
#include "td/telegram/PollManager.h"
|
||||||
#include "td/telegram/PrivacyManager.h"
|
#include "td/telegram/PrivacyManager.h"
|
||||||
|
#include "td/telegram/ScheduledServerMessageId.h"
|
||||||
#include "td/telegram/SecretChatId.h"
|
#include "td/telegram/SecretChatId.h"
|
||||||
#include "td/telegram/SecretChatsManager.h"
|
#include "td/telegram/SecretChatsManager.h"
|
||||||
#include "td/telegram/ServerMessageId.h"
|
#include "td/telegram/ServerMessageId.h"
|
||||||
@ -1911,15 +1912,20 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateMessagePoll> up
|
|||||||
td_->poll_manager_->on_get_poll(PollId(update->poll_id_), std::move(update->poll_), std::move(update->results_));
|
td_->poll_manager_->on_get_poll(PollId(update->poll_id_), std::move(update->poll_), std::move(update->results_));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateDeleteScheduledMessages> update,
|
||||||
|
bool /*force_apply*/) {
|
||||||
|
vector<ScheduledServerMessageId> message_ids = transform(update->messages_, [](int32 scheduled_server_message_id) {
|
||||||
|
return ScheduledServerMessageId(scheduled_server_message_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
td_->messages_manager_->on_update_delete_scheduled_messages(DialogId(update->peer_), std::move(message_ids));
|
||||||
|
}
|
||||||
|
|
||||||
// unsupported updates
|
// unsupported updates
|
||||||
|
|
||||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateNewScheduledMessage> update, bool /*force_apply*/) {
|
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateNewScheduledMessage> update, bool /*force_apply*/) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateDeleteScheduledMessages> update,
|
|
||||||
bool /*force_apply*/) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateTheme> update, bool /*force_apply*/) {
|
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateTheme> update, bool /*force_apply*/) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,10 +280,11 @@ class UpdatesManager : public Actor {
|
|||||||
|
|
||||||
void on_update(tl_object_ptr<telegram_api::updateMessagePoll> update, bool /*force_apply*/);
|
void on_update(tl_object_ptr<telegram_api::updateMessagePoll> update, bool /*force_apply*/);
|
||||||
|
|
||||||
|
void on_update(tl_object_ptr<telegram_api::updateDeleteScheduledMessages> update, bool /*force_apply*/);
|
||||||
|
|
||||||
// unsupported updates
|
// unsupported updates
|
||||||
|
|
||||||
void on_update(tl_object_ptr<telegram_api::updateNewScheduledMessage> update, bool /*force_apply*/);
|
void on_update(tl_object_ptr<telegram_api::updateNewScheduledMessage> update, bool /*force_apply*/);
|
||||||
void on_update(tl_object_ptr<telegram_api::updateDeleteScheduledMessages> update, bool /*force_apply*/);
|
|
||||||
|
|
||||||
void on_update(tl_object_ptr<telegram_api::updateTheme> update, bool /*force_apply*/);
|
void on_update(tl_object_ptr<telegram_api::updateTheme> update, bool /*force_apply*/);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user