Fail to forward old messages after restart.

GitOrigin-RevId: 948954d3f6b9e3c7c4a8479233c95115cc676620
This commit is contained in:
levlam 2018-09-19 19:43:01 +03:00
parent dccef30582
commit 91950e9452
2 changed files with 11 additions and 8 deletions

View File

@ -26179,7 +26179,7 @@ MessagesManager::Message *MessagesManager::continue_send_message(DialogId dialog
m->have_previous = true;
m->have_next = true;
LOG(WARNING) << "Continue to send " << m->message_id << " to " << dialog_id << " initially sent at " << m->send_date
LOG(INFO) << "Continue to send " << m->message_id << " to " << dialog_id << " initially sent at " << m->send_date
<< " from binlog";
if (!have_input_peer(dialog_id, AccessRights::Read)) {
@ -26202,9 +26202,7 @@ MessagesManager::Message *MessagesManager::continue_send_message(DialogId dialog
}
auto can_send_status = can_send_message(dialog_id);
const int32 MAX_RESEND_DELAY = 86400;
if (can_send_status.is_ok() && result_message->send_date < now - MAX_RESEND_DELAY) {
LOG(WARNING) << "Fail sending old message to " << dialog_id;
can_send_status = Status::Error(400, "Message is too old to be resent automatically");
}
if (can_send_status.is_error()) {
@ -26377,22 +26375,25 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&events) {
binlog_erase(G()->td_db()->get_binlog(), event.id_);
continue;
}
auto now = G()->unix_time();
for (auto &m : messages) {
m->message_id = get_next_yet_unsent_message_id(to_dialog);
m->random_y = get_random_y(m->message_id);
m->date = G()->unix_time();
m->date = now;
m->content = dup_message_content(to_dialog_id, m->content.get(), true);
m->have_previous = true;
m->have_next = true;
}
LOG(INFO) << "Continue to forward " << messages.size() << " messages to " << to_dialog_id << " from binlog";
if (!have_input_peer(from_dialog_id, AccessRights::Read) || can_send_message(to_dialog_id).is_error()) {
if (!have_input_peer(from_dialog_id, AccessRights::Read) || can_send_message(to_dialog_id).is_error() ||
messages.empty() || messages[0]->send_date < now - MAX_RESEND_DELAY) {
LOG(WARNING) << "Can't continue forwarding " << messages.size() << " message(s) to " << to_dialog_id;
binlog_erase(G()->td_db()->get_binlog(), event.id_);
break;
}
LOG(INFO) << "Continue to forward " << messages.size() << " message(s) to " << to_dialog_id << " from binlog";
bool need_update = false;
bool need_update_dialog_pos = false;
vector<Message *> forwarded_messages;

View File

@ -1938,6 +1938,8 @@ class MessagesManager : public Actor {
static constexpr int32 MIN_LIVE_LOCATION_PERIOD = 60; // seconds, server side limit
static constexpr int32 MAX_LIVE_LOCATION_PERIOD = 86400; // seconds, server side limit
static constexpr int32 MAX_RESEND_DELAY = 86400; // seconds, some resonable limit
static constexpr int32 MAX_PRELOADED_DIALOGS = 1000;
static constexpr double DIALOG_ACTION_TIMEOUT = 5.5;