From 34bea7d5d76d08f844cfa50033b2bdafe36f3b85 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 29 Dec 2019 23:39:54 +0300 Subject: [PATCH] Fix CHECK. GitOrigin-RevId: 96fb8c20d2622534cb3ff884ecb007ae49305d34 --- td/telegram/MessagesManager.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 9ce8da5bf..e9e57a221 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -15131,7 +15131,8 @@ void MessagesManager::close_dialog(Dialog *d) { for (auto &it : d->pending_viewed_live_locations) { auto live_location_task_id = it.second; - CHECK(viewed_live_location_tasks_.erase(live_location_task_id) > 0); + auto erased_count = viewed_live_location_tasks_.erase(live_location_task_id); + CHECK(erased_count > 0); } d->pending_viewed_live_locations.clear(); @@ -16393,19 +16394,16 @@ void MessagesManager::view_message_live_location_on_server(int64 task_id) { } auto full_message_id = it->second; - const Message *m = get_message_force(full_message_id, "view_message_live_location_on_server"); - if (m == nullptr) { - // the message was deleted + Dialog *d = get_dialog(full_message_id.get_dialog_id()); + const Message *m = get_message_force(d, full_message_id.get_message_id(), "view_message_live_location_on_server"); + if (m == nullptr || get_message_content_live_location_period(m->content.get()) <= G()->unix_time() - m->date + 1) { + // the message was deleted or live location is expired viewed_live_location_tasks_.erase(it); + auto erased_count = d->pending_viewed_live_locations.erase(full_message_id.get_message_id()); + CHECK(erased_count > 0); return; } - auto live_period = get_message_content_live_location_period(m->content.get()); - if (live_period <= G()->unix_time() - m->date + 1) { - // live location is expired - viewed_live_location_tasks_.erase(it); - return; - } view_message_live_location_on_server_impl(task_id, full_message_id); }