Return message ttl for ordinary self-destructing messages.
This commit is contained in:
parent
cc50f3b143
commit
54b7b0f6e3
@ -11943,7 +11943,7 @@ void MessagesManager::ttl_register_message(DialogId dialog_id, const Message *m,
|
|||||||
ttl_update_timeout(now);
|
ttl_update_timeout(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::ttl_period_register_message(DialogId dialog_id, const Message *m, int32 unix_time) {
|
void MessagesManager::ttl_period_register_message(DialogId dialog_id, const Message *m, double server_time) {
|
||||||
CHECK(m != nullptr);
|
CHECK(m != nullptr);
|
||||||
CHECK(m->ttl_period != 0);
|
CHECK(m->ttl_period != 0);
|
||||||
CHECK(!m->message_id.is_scheduled());
|
CHECK(!m->message_id.is_scheduled());
|
||||||
@ -11953,7 +11953,7 @@ void MessagesManager::ttl_period_register_message(DialogId dialog_id, const Mess
|
|||||||
auto it = it_flag.first;
|
auto it = it_flag.first;
|
||||||
|
|
||||||
auto now = Time::now();
|
auto now = Time::now();
|
||||||
ttl_heap_.insert(now + (m->date + m->ttl_period - unix_time), it->as_heap_node());
|
ttl_heap_.insert(now + (m->date + m->ttl_period - server_time), it->as_heap_node());
|
||||||
ttl_update_timeout(now);
|
ttl_update_timeout(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22613,6 +22613,10 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
|
|||||||
} else {
|
} else {
|
||||||
ttl_expires_in = m->ttl;
|
ttl_expires_in = m->ttl;
|
||||||
}
|
}
|
||||||
|
if (ttl == 0 && m->ttl_period != 0) {
|
||||||
|
ttl = m->ttl_period;
|
||||||
|
ttl_expires_in = max(m->date + m->ttl_period - G()->server_time(), 1e-3);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ttl = 0;
|
ttl = 0;
|
||||||
}
|
}
|
||||||
@ -31996,15 +32000,15 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
|
|||||||
}
|
}
|
||||||
if (message->ttl_period > 0) {
|
if (message->ttl_period > 0) {
|
||||||
CHECK(dialog_id.get_type() != DialogType::SecretChat);
|
CHECK(dialog_id.get_type() != DialogType::SecretChat);
|
||||||
auto unix_time = G()->unix_time();
|
auto server_time = G()->server_time();
|
||||||
if (message->date + message->ttl_period <= unix_time) {
|
if (message->date + message->ttl_period <= server_time) {
|
||||||
LOG(INFO) << "Can't add " << message_id << " with expired TTL period to " << dialog_id << " from " << source;
|
LOG(INFO) << "Can't add " << message_id << " with expired TTL period to " << dialog_id << " from " << source;
|
||||||
delete_message_from_database(d, message_id, message.get(), true);
|
delete_message_from_database(d, message_id, message.get(), true);
|
||||||
debug_add_message_to_dialog_fail_reason_ = "delete expired by TTL period message";
|
debug_add_message_to_dialog_fail_reason_ = "delete expired by TTL period message";
|
||||||
d->being_added_message_id = MessageId();
|
d->being_added_message_id = MessageId();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
ttl_period_register_message(dialog_id, message.get(), unix_time);
|
ttl_period_register_message(dialog_id, message.get(), server_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2600,7 +2600,7 @@ class MessagesManager : public Actor {
|
|||||||
bool ttl_on_open(Dialog *d, Message *m, double now, bool is_local_read);
|
bool ttl_on_open(Dialog *d, Message *m, double now, bool is_local_read);
|
||||||
void ttl_register_message(DialogId dialog_id, const Message *m, double now);
|
void ttl_register_message(DialogId dialog_id, const Message *m, double now);
|
||||||
void ttl_unregister_message(DialogId dialog_id, const Message *m, const char *source);
|
void ttl_unregister_message(DialogId dialog_id, const Message *m, const char *source);
|
||||||
void ttl_period_register_message(DialogId dialog_id, const Message *m, int32 unix_time);
|
void ttl_period_register_message(DialogId dialog_id, const Message *m, double server_time);
|
||||||
void ttl_period_unregister_message(DialogId dialog_id, const Message *m);
|
void ttl_period_unregister_message(DialogId dialog_id, const Message *m);
|
||||||
void ttl_loop(double now);
|
void ttl_loop(double now);
|
||||||
void ttl_update_timeout(double now);
|
void ttl_update_timeout(double now);
|
||||||
|
Loading…
Reference in New Issue
Block a user