Skip to content

Commit 86dfd70

Browse files
committed
Send the whole message in updateChatReplyMarkup.
1 parent 841776c commit 86dfd70

File tree

4 files changed

+22
-23
lines changed

4 files changed

+22
-23
lines changed

‎example/java/org/drinkless/tdlib/example/Example.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ public void onResult(TdApi.Object object) {
555555
TdApi.UpdateChatReplyMarkup updateChat = (TdApi.UpdateChatReplyMarkup) object;
556556
TdApi.Chat chat = chats.get(updateChat.chatId);
557557
synchronized (chat) {
558-
chat.replyMarkupMessageId = updateChat.replyMarkupMessageId;
558+
chat.replyMarkupMessageId = updateChat.replyMarkupMessage != null ? updateChat.replyMarkupMessage.id : 0;
559559
}
560560
break;
561561
}

‎td/generate/scheme/td_api.tl‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3260,7 +3260,7 @@ videoChat group_call_id:int32 has_participants:Bool default_participant_id:Messa
32603260
//@business_bot_manage_bar Information about bar for managing a business bot in the chat; may be null if none
32613261
//@video_chat Information about video chat of the chat
32623262
//@pending_join_requests Information about pending join requests; may be null if none
3263-
//@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat
3263+
//@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no reply markup in the chat
32643264
//@draft_message A draft of a message in the chat; may be null if none
32653265
//@client_data Application-specific data associated with the chat. (For example, the chat scroll position or local chat notification settings can be stored here.) Persistent if the message database is used
32663266
chat id:int53 type:ChatType title:string photo:chatPhotoInfo accent_color_id:int32 background_custom_emoji_id:int64 upgraded_gift_colors:upgradedGiftColors profile_accent_color_id:int32 profile_background_custom_emoji_id:int64 permissions:chatPermissions last_message:message positions:vector<chatPosition> chat_lists:vector<ChatList> message_sender_id:MessageSender block_list:BlockList has_protected_content:Bool is_translatable:Bool is_marked_as_unread:Bool view_as_topics:Bool has_scheduled_messages:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 unread_reaction_count:int32 notification_settings:chatNotificationSettings available_reactions:ChatAvailableReactions message_auto_delete_time:int32 emoji_status:emojiStatus background:chatBackground theme:ChatTheme action_bar:ChatActionBar business_bot_manage_bar:businessBotManageBar video_chat:videoChat pending_join_requests:chatJoinRequestsInfo reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat;
@@ -3441,7 +3441,7 @@ inlineKeyboardButton text:string icon_custom_emoji_id:int64 style:ButtonStyle ty
34413441

34423442
//@class ReplyMarkup @description Contains a description of a custom keyboard and actions that can be done with it to quickly reply to bots
34433443

3444-
//@description Instructs application to remove the keyboard once this message has been received. This kind of keyboard can't be received in an incoming message; instead, updateChatReplyMarkup with message_id == 0 will be sent
3444+
//@description Instructs application to remove the keyboard once this message has been received. This kind of keyboard can't be received in an incoming message; instead, updateChatReplyMarkup with reply_markup_message == null will be sent
34453445
//@is_personal True, if the keyboard is removed only for the mentioned users or the target user of a reply
34463446
replyMarkupRemoveKeyboard is_personal:Bool = ReplyMarkup;
34473447

@@ -9726,10 +9726,8 @@ updateChatNotificationSettings chat_id:int53 notification_settings:chatNotificat
97269726
//@description The chat pending join requests were changed @chat_id Chat identifier @pending_join_requests The new data about pending join requests; may be null
97279727
updateChatPendingJoinRequests chat_id:int53 pending_join_requests:chatJoinRequestsInfo = Update;
97289728

9729-
//@description The default chat reply markup was changed. Can occur because new messages with reply markup were received or because an old reply markup was hidden by the user
9730-
//@chat_id Chat identifier
9731-
//@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat
9732-
updateChatReplyMarkup chat_id:int53 reply_markup_message_id:int53 = Update;
9729+
//@description The chat reply markup was changed @chat_id Chat identifier @reply_markup_message The message from which the reply markup must be used; may be null if there is no default reply markup in the chat
9730+
updateChatReplyMarkup chat_id:int53 reply_markup_message:message = Update;
97339731

97349732
//@description The chat background was changed @chat_id Chat identifier @background The new chat background; may be null if background was reset to default
97359733
updateChatBackground chat_id:int53 background:chatBackground = Update;

‎td/telegram/MessagesManager.cpp‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8575,7 +8575,7 @@ void MessagesManager::clear_dialog_message_list(Dialog *d, bool remove_from_dial
85758575
}
85768576

85778577
if (d->reply_markup_message_id != MessageId()) {
8578-
set_dialog_reply_markup(d, MessageId());
8578+
set_dialog_reply_markup(d, MessageId(), nullptr);
85798579
}
85808580

85818581
set_dialog_first_database_message_id(d, MessageId(), "delete_all_dialog_messages 4");
@@ -9901,7 +9901,7 @@ void MessagesManager::on_message_ttl_expired_impl(Dialog *d, Message *m, bool is
99019901
if (m->reply_markup != nullptr) {
99029902
if (m->reply_markup->type != ReplyMarkup::Type::InlineKeyboard) {
99039903
if (d->reply_markup_message_id == m->message_id) {
9904-
set_dialog_reply_markup(d, MessageId());
9904+
set_dialog_reply_markup(d, MessageId(), nullptr);
99059905
}
99069906
m->had_reply_markup = true;
99079907
}
@@ -11517,7 +11517,7 @@ MessageFullId MessagesManager::on_get_message(MessageInfo &&message_info, const
1151711517
// set dialog reply markup only after updateNewMessage and updateChatLastMessage are sent
1151811518
if (need_update && m->reply_markup != nullptr && !m->message_id.is_scheduled() &&
1151911519
m->reply_markup->type != ReplyMarkup::Type::InlineKeyboard && m->reply_markup->is_personal) {
11520-
set_dialog_reply_markup(d, message_id);
11520+
set_dialog_reply_markup(d, message_id, m);
1152111521
}
1152211522

1152311523
if (from_update) {
@@ -11762,7 +11762,7 @@ void MessagesManager::set_dialog_is_empty(Dialog *d, const char *source) {
1176211762
send_update_chat_unread_reaction_count(d, "set_dialog_is_empty");
1176311763
}
1176411764
if (d->reply_markup_message_id != MessageId()) {
11765-
set_dialog_reply_markup(d, MessageId());
11765+
set_dialog_reply_markup(d, MessageId(), nullptr);
1176611766
}
1176711767
std::fill(d->message_count_by_index.begin(), d->message_count_by_index.end(), 0);
1176811768
if (d->notification_info != nullptr) {
@@ -11892,7 +11892,7 @@ void MessagesManager::save_pinned_folder_dialog_ids(const DialogList &list) cons
1189211892
','));
1189311893
}
1189411894

11895-
void MessagesManager::set_dialog_reply_markup(Dialog *d, MessageId message_id) {
11895+
void MessagesManager::set_dialog_reply_markup(Dialog *d, MessageId message_id, const Message *m) {
1189611896
if (td_->auth_manager_->is_bot()) {
1189711897
return;
1189811898
}
@@ -11910,7 +11910,8 @@ void MessagesManager::set_dialog_reply_markup(Dialog *d, MessageId message_id) {
1191011910
d->reply_markup_message_id = message_id;
1191111911
send_closure(G()->td(), &Td::send_update,
1191211912
td_api::make_object<td_api::updateChatReplyMarkup>(
11913-
get_chat_id_object(d->dialog_id, "updateChatReplyMarkup"), message_id.get()));
11913+
get_chat_id_object(d->dialog_id, "updateChatReplyMarkup"),
11914+
m == nullptr ? nullptr : get_message_object(d->dialog_id, m, "set_dialog_reply_markup")));
1191411915
}
1191511916
}
1191611917

@@ -11922,11 +11923,11 @@ void MessagesManager::try_restore_dialog_reply_markup(Dialog *d, const Message *
1192211923
CHECK(!m->message_id.is_scheduled());
1192311924
if (m->had_reply_markup) {
1192411925
LOG(INFO) << "Restore deleted reply markup in " << d->dialog_id;
11925-
set_dialog_reply_markup(d, MessageId());
11926+
set_dialog_reply_markup(d, MessageId(), nullptr);
1192611927
} else if (m->reply_markup != nullptr && m->reply_markup->type != ReplyMarkup::Type::InlineKeyboard &&
1192711928
m->reply_markup->is_personal) {
1192811929
LOG(INFO) << "Restore reply markup in " << d->dialog_id << " to " << m->message_id;
11929-
set_dialog_reply_markup(d, m->message_id);
11930+
set_dialog_reply_markup(d, m->message_id, m);
1193011931
}
1193111932
}
1193211933

@@ -13045,7 +13046,7 @@ void MessagesManager::on_message_deleted_from_database(Dialog *d, const Message
1304513046
auto message_id = m->message_id;
1304613047
// TODO update reply_markup in topics
1304713048
if (d->reply_markup_message_id == message_id) {
13048-
set_dialog_reply_markup(d, MessageId());
13049+
set_dialog_reply_markup(d, MessageId(), nullptr);
1304913050
}
1305013051
// if last_read_inbox_message_id is not known, we can't be sure whether unread_count should be decreased or not
1305113052
if (has_incoming_notification(d, m) && message_id > d->last_read_inbox_message_id &&
@@ -15392,14 +15393,14 @@ Status MessagesManager::delete_dialog_reply_markup(DialogId dialog_id, MessageId
1539215393
CHECK(m->reply_markup != nullptr);
1539315394

1539415395
if (m->reply_markup->type == ReplyMarkup::Type::ForceReply) {
15395-
set_dialog_reply_markup(d, MessageId());
15396+
set_dialog_reply_markup(d, MessageId(), nullptr);
1539615397
} else if (m->reply_markup->type == ReplyMarkup::Type::ShowKeyboard) {
1539715398
if (!m->reply_markup->is_one_time_keyboard) {
1539815399
return Status::Error(400, "Do not need to delete non one-time keyboard");
1539915400
}
1540015401
if (m->reply_markup->is_personal) {
1540115402
m->reply_markup->is_personal = false;
15402-
set_dialog_reply_markup(d, message_id);
15403+
set_dialog_reply_markup(d, message_id, m);
1540315404

1540415405
on_message_changed(d, m, true, "delete_dialog_reply_markup");
1540515406
}
@@ -28560,7 +28561,7 @@ void MessagesManager::on_dialog_bots_updated(DialogId dialog_id, vector<UserId>
2856028561
if (m == nullptr || (m->sender_user_id.is_valid() && !td::contains(bot_user_ids, m->sender_user_id))) {
2856128562
LOG(INFO) << "Remove reply markup in " << dialog_id << ", because bot "
2856228563
<< (m == nullptr ? UserId() : m->sender_user_id) << " isn't a member of the chat";
28563-
set_dialog_reply_markup(d, MessageId());
28564+
set_dialog_reply_markup(d, MessageId(), nullptr);
2856428565
}
2856528566
}
2856628567
}
@@ -30252,12 +30253,12 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
3025230253
if (bot_dialog_id.is_valid()) {
3025330254
const Message *old_message = get_message_force(d, d->reply_markup_message_id, "add_message_to_dialog 1");
3025430255
if (old_message == nullptr || get_message_sender(old_message) == bot_dialog_id) {
30255-
set_dialog_reply_markup(d, MessageId());
30256+
set_dialog_reply_markup(d, MessageId(), nullptr);
3025630257
}
3025730258
}
3025830259
}
3025930260

30260-
// must be after set_dialog_reply_markup(d, MessageId()), but before try_restore_dialog_reply_markup
30261+
// must be after set_dialog_reply_markup(d, MessageId(), nullptr), but before try_restore_dialog_reply_markup
3026130262
remove_message_remove_keyboard_reply_markup(message.get());
3026230263

3026330264
{
@@ -31668,7 +31669,7 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr
3166831669
if (reply_markup_changed) {
3166931670
if (d->reply_markup_message_id == message_id && !td_->auth_manager_->is_bot() &&
3167031671
new_message->reply_markup == nullptr) {
31671-
set_dialog_reply_markup(d, MessageId());
31672+
set_dialog_reply_markup(d, MessageId(), nullptr);
3167231673
}
3167331674
LOG(DEBUG) << "Update message reply keyboard";
3167431675
old_message->reply_markup = std::move(new_message->reply_markup);

‎td/telegram/MessagesManager.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2542,7 +2542,7 @@ class MessagesManager final : public Actor {
25422542

25432543
void do_set_dialog_folder_id(Dialog *d, FolderId folder_id);
25442544

2545-
void set_dialog_reply_markup(Dialog *d, MessageId message_id);
2545+
void set_dialog_reply_markup(Dialog *d, MessageId message_id, const Message *m);
25462546

25472547
void try_restore_dialog_reply_markup(Dialog *d, const Message *m);
25482548

0 commit comments

Comments
 (0)