Notify server about viewed live locations once a minute.
GitOrigin-RevId: 4658a8807f9acc8820c73fa64a348c86e83dadd2
This commit is contained in:
parent
10c1b8c6ea
commit
2b94d84a2f
@ -4707,6 +4707,9 @@ MessagesManager::MessagesManager(Td *td, ActorShared<> parent) : td_(td), parent
|
|||||||
pending_message_views_timeout_.set_callback(on_pending_message_views_timeout_callback);
|
pending_message_views_timeout_.set_callback(on_pending_message_views_timeout_callback);
|
||||||
pending_message_views_timeout_.set_callback_data(static_cast<void *>(this));
|
pending_message_views_timeout_.set_callback_data(static_cast<void *>(this));
|
||||||
|
|
||||||
|
pending_message_live_location_view_timeout_.set_callback(on_pending_message_live_location_view_timeout_callback);
|
||||||
|
pending_message_live_location_view_timeout_.set_callback_data(static_cast<void *>(this));
|
||||||
|
|
||||||
pending_draft_message_timeout_.set_callback(on_pending_draft_message_timeout_callback);
|
pending_draft_message_timeout_.set_callback(on_pending_draft_message_timeout_callback);
|
||||||
pending_draft_message_timeout_.set_callback_data(static_cast<void *>(this));
|
pending_draft_message_timeout_.set_callback_data(static_cast<void *>(this));
|
||||||
|
|
||||||
@ -4759,6 +4762,17 @@ void MessagesManager::on_pending_message_views_timeout_callback(void *messages_m
|
|||||||
DialogId(dialog_id_int));
|
DialogId(dialog_id_int));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessagesManager::on_pending_message_live_location_view_timeout_callback(void *messages_manager_ptr,
|
||||||
|
int64 task_id) {
|
||||||
|
if (G()->close_flag()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto messages_manager = static_cast<MessagesManager *>(messages_manager_ptr);
|
||||||
|
send_closure_later(messages_manager->actor_id(messages_manager),
|
||||||
|
&MessagesManager::view_message_live_location_on_server, task_id);
|
||||||
|
}
|
||||||
|
|
||||||
void MessagesManager::on_pending_draft_message_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int) {
|
void MessagesManager::on_pending_draft_message_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int) {
|
||||||
if (G()->close_flag()) {
|
if (G()->close_flag()) {
|
||||||
return;
|
return;
|
||||||
@ -16175,9 +16189,9 @@ void MessagesManager::on_message_live_location_viewed(Dialog *d, const Message *
|
|||||||
switch (d->dialog_id.get_type()) {
|
switch (d->dialog_id.get_type()) {
|
||||||
case DialogType::User:
|
case DialogType::User:
|
||||||
case DialogType::Chat:
|
case DialogType::Chat:
|
||||||
|
case DialogType::Channel:
|
||||||
// ok
|
// ok
|
||||||
break;
|
break;
|
||||||
case DialogType::Channel:
|
|
||||||
case DialogType::SecretChat:
|
case DialogType::SecretChat:
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
@ -16205,8 +16219,9 @@ void MessagesManager::on_message_live_location_viewed(Dialog *d, const Message *
|
|||||||
}
|
}
|
||||||
|
|
||||||
live_location_task_id = ++viewed_live_location_task_id_;
|
live_location_task_id = ++viewed_live_location_task_id_;
|
||||||
viewed_live_location_tasks_[live_location_task_id] = FullMessageId(d->dialog_id, m->message_id);
|
auto &full_message_id = viewed_live_location_tasks_[live_location_task_id];
|
||||||
view_message_live_location_on_server(live_location_task_id);
|
full_message_id = FullMessageId(d->dialog_id, m->message_id);
|
||||||
|
view_message_live_location_on_server_impl(live_location_task_id, full_message_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::view_message_live_location_on_server(int64 task_id) {
|
void MessagesManager::view_message_live_location_on_server(int64 task_id) {
|
||||||
@ -16233,11 +16248,15 @@ void MessagesManager::view_message_live_location_on_server(int64 task_id) {
|
|||||||
viewed_live_location_tasks_.erase(it);
|
viewed_live_location_tasks_.erase(it);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
view_message_live_location_on_server_impl(task_id, full_message_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessagesManager::view_message_live_location_on_server_impl(int64 task_id, FullMessageId full_message_id) {
|
||||||
auto promise = PromiseCreator::lambda([actor_id = actor_id(this), task_id](Unit result) {
|
auto promise = PromiseCreator::lambda([actor_id = actor_id(this), task_id](Unit result) {
|
||||||
send_closure(actor_id, &MessagesManager::on_message_live_location_viewed_on_server, task_id);
|
send_closure(actor_id, &MessagesManager::on_message_live_location_viewed_on_server, task_id);
|
||||||
});
|
});
|
||||||
read_message_contents_on_server(full_message_id.get_dialog_id(), {m->message_id}, 0, std::move(promise), true);
|
read_message_contents_on_server(full_message_id.get_dialog_id(), {full_message_id.get_message_id()}, 0,
|
||||||
|
std::move(promise), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::on_message_live_location_viewed_on_server(int64 task_id) {
|
void MessagesManager::on_message_live_location_viewed_on_server(int64 task_id) {
|
||||||
@ -16250,7 +16269,7 @@ void MessagesManager::on_message_live_location_viewed_on_server(int64 task_id) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO schedule new server request in 60 seconds
|
pending_message_live_location_view_timeout_.add_timeout_in(task_id, LIVE_LOCATION_VIEW_PERIOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSourceId MessagesManager::get_message_file_source_id(FullMessageId full_message_id) {
|
FileSourceId MessagesManager::get_message_file_source_id(FullMessageId full_message_id) {
|
||||||
|
@ -1440,6 +1440,8 @@ class MessagesManager : public Actor {
|
|||||||
static constexpr int32 MIN_READ_HISTORY_DELAY = 3; // seconds
|
static constexpr int32 MIN_READ_HISTORY_DELAY = 3; // seconds
|
||||||
static constexpr int32 MAX_SAVE_DIALOG_DELAY = 0; // seconds
|
static constexpr int32 MAX_SAVE_DIALOG_DELAY = 0; // seconds
|
||||||
|
|
||||||
|
static constexpr int32 LIVE_LOCATION_VIEW_PERIOD = 60; // seconds, server-side limit
|
||||||
|
|
||||||
static constexpr int32 USERNAME_CACHE_EXPIRE_TIME = 3 * 86400;
|
static constexpr int32 USERNAME_CACHE_EXPIRE_TIME = 3 * 86400;
|
||||||
static constexpr int32 USERNAME_CACHE_EXPIRE_TIME_SHORT = 900;
|
static constexpr int32 USERNAME_CACHE_EXPIRE_TIME_SHORT = 900;
|
||||||
|
|
||||||
@ -2203,6 +2205,8 @@ class MessagesManager : public Actor {
|
|||||||
|
|
||||||
void view_message_live_location_on_server(int64 task_id);
|
void view_message_live_location_on_server(int64 task_id);
|
||||||
|
|
||||||
|
void view_message_live_location_on_server_impl(int64 task_id, FullMessageId full_message_id);
|
||||||
|
|
||||||
void on_message_live_location_viewed_on_server(int64 task_id);
|
void on_message_live_location_viewed_on_server(int64 task_id);
|
||||||
|
|
||||||
void add_message_file_sources(DialogId dialog_id, const Message *m);
|
void add_message_file_sources(DialogId dialog_id, const Message *m);
|
||||||
@ -2301,6 +2305,8 @@ class MessagesManager : public Actor {
|
|||||||
|
|
||||||
static void on_pending_message_views_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
static void on_pending_message_views_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
||||||
|
|
||||||
|
static void on_pending_message_live_location_view_timeout_callback(void *messages_manager_ptr, int64 task_id);
|
||||||
|
|
||||||
static void on_pending_draft_message_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
static void on_pending_draft_message_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
||||||
|
|
||||||
static void on_pending_read_history_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
static void on_pending_read_history_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
||||||
@ -2637,6 +2643,7 @@ class MessagesManager : public Actor {
|
|||||||
MultiTimeout channel_get_difference_timeout_{"ChannelGetDifferenceTimeout"};
|
MultiTimeout channel_get_difference_timeout_{"ChannelGetDifferenceTimeout"};
|
||||||
MultiTimeout channel_get_difference_retry_timeout_{"ChannelGetDifferenceRetryTimeout"};
|
MultiTimeout channel_get_difference_retry_timeout_{"ChannelGetDifferenceRetryTimeout"};
|
||||||
MultiTimeout pending_message_views_timeout_{"PendingMessageViewsTimeout"};
|
MultiTimeout pending_message_views_timeout_{"PendingMessageViewsTimeout"};
|
||||||
|
MultiTimeout pending_message_live_location_view_timeout_{"PendingMessageLiveLocationViewTimeout"};
|
||||||
MultiTimeout pending_draft_message_timeout_{"PendingDraftMessageTimeout"};
|
MultiTimeout pending_draft_message_timeout_{"PendingDraftMessageTimeout"};
|
||||||
MultiTimeout pending_read_history_timeout_{"PendingReadHistoryTimeout"};
|
MultiTimeout pending_read_history_timeout_{"PendingReadHistoryTimeout"};
|
||||||
MultiTimeout pending_updated_dialog_timeout_{"PendingUpdatedDialogTimeout"};
|
MultiTimeout pending_updated_dialog_timeout_{"PendingUpdatedDialogTimeout"};
|
||||||
|
Reference in New Issue
Block a user