Improve slow mode.

GitOrigin-RevId: 068774033f5c84165e4833dafa29789d307ab97b
This commit is contained in:
levlam 2019-11-21 16:58:00 +03:00
parent 97cdacff7b
commit 0f353009f8
2 changed files with 11 additions and 3 deletions

View File

@ -1395,7 +1395,15 @@ class ToggleSlowModeQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
td->contacts_manager_->on_get_channel_error(channel_id_, status, "ToggleSlowModeQuery");
if (status.message() == "CHAT_NOT_MODIFIED") {
td->contacts_manager_->on_update_channel_slow_mode_delay(channel_id_, slow_mode_delay_);
if (!td->auth_manager_->is_bot()) {
promise_.set_value(Unit());
return;
}
} else {
td->contacts_manager_->on_get_channel_error(channel_id_, status, "ToggleSlowModeQuery");
}
promise_.set_error(std::move(status));
}
};
@ -9760,7 +9768,7 @@ void ContactsManager::on_update_channel_full_slow_mode_delay(ChannelFull *channe
Channel *c = get_channel(channel_id);
CHECK(c != nullptr);
bool is_slow_mode_enabled = slow_mode_delay != 0;
if (is_slow_mode_enabled == c->is_slow_mode_enabled) {
if (is_slow_mode_enabled != c->is_slow_mode_enabled) {
c->is_slow_mode_enabled = is_slow_mode_enabled;
c->is_changed = true;
update_channel(c, channel_id);

View File

@ -24764,7 +24764,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
add_message_to_database(d, m, "add_message_to_dialog");
}
if (*need_update && dialog_id.get_type() == DialogType::Channel) {
if (from_update && dialog_id.get_type() == DialogType::Channel) {
auto now = max(G()->unix_time_cached(), m->date);
if (m->date < now - 2 * 86400 && Slice(source) == Slice("updateNewChannelMessage")) {
// if the message is pretty old, we might have missed the update that the message has already been read