Add td_api::updateMessageLiveLocationViewed.

GitOrigin-RevId: 2c9d6e1317e6604a23e30efab0dfa21a2e88f01d
This commit is contained in:
levlam 2019-12-13 21:05:10 +03:00
parent 60a95186f5
commit 1dd4e1a767
6 changed files with 54 additions and 9 deletions

View File

@ -2726,6 +2726,10 @@ updateMessageContentOpened chat_id:int53 message_id:int53 = Update;
//@description A message with an unread mention was read @chat_id Chat identifier @message_id Message identifier @unread_mention_count The new number of unread mention messages left in the chat
updateMessageMentionRead chat_id:int53 message_id:int53 unread_mention_count:int32 = Update;
//@description A message with a live location was viewed. When the update is received, the client is supposed to update the live location
//@chat_id Identifier of the chat with the live location message @message_id Identifier of the message with live location
updateMessageLiveLocationViewed chat_id:int53 message_id:int53 = Update;
//@description A new chat has been loaded/created. This update is guaranteed to come before the chat identifier is returned to the client. The chat field changes will be reported through separate updates @chat The chat
updateNewChat chat:chat = Update;
@ -2913,14 +2917,17 @@ updateTermsOfService terms_of_service_id:string terms_of_service:termsOfService
//@description List of users nearby has changed. The update is sent only 60 seconds after a successful searchChatsNearby request @users_nearby The new list of users nearby
updateUsersNearby users_nearby:vector<chatNearby> = Update;
//@description A new incoming inline query; for bots only @id Unique query identifier @sender_user_id Identifier of the user who sent the query @user_location User location, provided by the client; may be null @query Text of the query @offset Offset of the first entry to return
//@description A new incoming inline query; for bots only @id Unique query identifier @sender_user_id Identifier of the user who sent the query @user_location User location, provided by the client; may be null
//@query Text of the query @offset Offset of the first entry to return
updateNewInlineQuery id:int64 sender_user_id:int32 user_location:location query:string offset:string = Update;
//@description The user has chosen a result of an inline query; for bots only @sender_user_id Identifier of the user who sent the query @user_location User location, provided by the client; may be null @query Text of the query @result_id Identifier of the chosen result @inline_message_id Identifier of the sent inline message, if known
//@description The user has chosen a result of an inline query; for bots only @sender_user_id Identifier of the user who sent the query @user_location User location, provided by the client; may be null
//@query Text of the query @result_id Identifier of the chosen result @inline_message_id Identifier of the sent inline message, if known
updateNewChosenInlineResult sender_user_id:int32 user_location:location query:string result_id:string inline_message_id:string = Update;
//@description A new incoming callback query; for bots only @id Unique query identifier @sender_user_id Identifier of the user who sent the query @chat_id Identifier of the chat where the query was sent
//@message_id Identifier of the message, from which the query originated @chat_instance Identifier that uniquely corresponds to the chat to which the message was sent @payload Query payload
//@description A new incoming callback query; for bots only @id Unique query identifier @sender_user_id Identifier of the user who sent the query
//@chat_id Identifier of the chat where the query was sent @message_id Identifier of the message, from which the query originated
//@chat_instance Identifier that uniquely corresponds to the chat to which the message was sent @payload Query payload
updateNewCallbackQuery id:int64 sender_user_id:int32 chat_id:int53 message_id:int53 chat_instance:int64 payload:CallbackQueryPayload = Update;
//@description A new incoming callback query from a message sent via a bot; for bots only @id Unique query identifier @sender_user_id Identifier of the user who sent the query @inline_message_id Identifier of the inline message, from which the query originated

Binary file not shown.

View File

@ -5692,6 +5692,24 @@ bool MessagesManager::update_message_views(DialogId dialog_id, Message *m, int32
return false;
}
void MessagesManager::on_update_live_location_viewed(FullMessageId full_message_id) {
LOG(DEBUG) << "Live location was viewed in " << full_message_id;
if (!are_active_live_location_messages_loaded_) {
get_active_live_location_messages(PromiseCreator::lambda([actor_id = actor_id(this), full_message_id](Unit result) {
send_closure(actor_id, &MessagesManager::on_update_live_location_viewed, full_message_id);
}));
return;
}
auto active_live_locations = get_active_live_location_messages(Auto());
if (!td::contains(active_live_locations, full_message_id)) {
LOG(DEBUG) << "Can't find " << full_message_id << " in " << active_live_locations;
return;
}
send_update_message_live_location_viewed(full_message_id);
}
void MessagesManager::on_update_message_content(FullMessageId full_message_id) {
const Dialog *d = get_dialog(full_message_id.get_dialog_id());
CHECK(d != nullptr);
@ -16011,6 +16029,10 @@ void MessagesManager::on_load_active_live_location_full_message_ids_from_databas
if (value.empty()) {
LOG(INFO) << "Active live location messages aren't found in the database";
on_load_active_live_location_messages_finished();
if (!active_live_location_full_message_ids_.empty()) {
save_active_live_locations();
}
return;
}
@ -16074,6 +16096,9 @@ void MessagesManager::add_active_live_location(FullMessageId full_message_id) {
if (are_active_live_location_messages_loaded_) {
save_active_live_locations();
} else {
// load active live locations and save after that
get_active_live_location_messages(Auto());
}
}
@ -22146,6 +22171,13 @@ void MessagesManager::send_update_message_edited(DialogId dialog_id, const Messa
get_reply_markup_object(m->reply_markup)));
}
void MessagesManager::send_update_message_live_location_viewed(FullMessageId full_message_id) {
CHECK(get_message(full_message_id) != nullptr);
send_closure(G()->td(), &Td::send_update,
td_api::make_object<td_api::updateMessageLiveLocationViewed>(full_message_id.get_dialog_id().get(),
full_message_id.get_message_id().get()));
}
void MessagesManager::send_update_delete_messages(DialogId dialog_id, vector<int64> &&message_ids, bool is_permanent,
bool from_cache) const {
if (message_ids.empty()) {

View File

@ -311,6 +311,8 @@ class MessagesManager : public Actor {
void on_update_message_views(FullMessageId full_message_id, int32 views);
void on_update_live_location_viewed(FullMessageId full_message_id);
void on_update_message_content(FullMessageId full_message_id);
void on_read_channel_inbox(ChannelId channel_id, MessageId max_message_id, int32 server_unread_count, int32 pts,
@ -1874,6 +1876,8 @@ class MessagesManager : public Actor {
void send_update_message_edited(DialogId dialog_id, const Message *m);
void send_update_message_live_location_viewed(FullMessageId full_message_id);
void send_update_delete_messages(DialogId dialog_id, vector<int64> &&message_ids, bool is_permanent,
bool from_cache) const;

View File

@ -1952,6 +1952,11 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateLangPack> updat
std::move(update->difference_));
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateGeoLiveViewed> update, bool /*force_apply*/) {
td_->messages_manager_->on_update_live_location_viewed(
{DialogId(update->peer_), MessageId(ServerMessageId(update->msg_id_))});
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateMessagePoll> update, bool /*force_apply*/) {
td_->poll_manager_->on_get_poll(PollId(update->poll_id_), std::move(update->poll_), std::move(update->results_));
}
@ -1975,9 +1980,6 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateDeleteScheduled
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateTheme> update, bool /*force_apply*/) {
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateGeoLiveViewed> update, bool /*force_apply*/) {
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateLoginToken> update, bool /*force_apply*/) {
}

View File

@ -278,6 +278,8 @@ class UpdatesManager : public Actor {
void on_update(tl_object_ptr<telegram_api::updateLangPackTooLong> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateLangPack> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateGeoLiveViewed> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateMessagePoll> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateNewScheduledMessage> update, bool /*force_apply*/);
@ -287,8 +289,6 @@ class UpdatesManager : public Actor {
void on_update(tl_object_ptr<telegram_api::updateTheme> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateGeoLiveViewed> update, bool /*force_apply*/);
void on_update(tl_object_ptr<telegram_api::updateLoginToken> update, bool /*force_apply*/);
};