Skip to content

Commit 9768de9

Browse files
committed
Add basic checks for checklist_task_id.
1 parent 7ab4824 commit 9768de9

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

td/telegram/BusinessConnectionManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ MessageInputReplyTo BusinessConnectionManager::create_business_message_input_rep
11671167
return {};
11681168
}
11691169
return MessageInputReplyTo{message_id, DialogId(), MessageQuote(td_, std::move(reply_to_message->quote_)),
1170-
reply_to_message->checklist_task_id_};
1170+
max(0, reply_to_message->checklist_task_id_)};
11711171
}
11721172
case td_api::inputMessageReplyToExternalMessage::ID:
11731173
return {};

td/telegram/MessagesManager.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20384,6 +20384,7 @@ MessageInputReplyTo MessagesManager::create_message_input_reply_to(
2038420384
if (!can_reply_to_message(d->dialog_id, message_id)) {
2038520385
message_id = {};
2038620386
}
20387+
auto checklist_task_id = max(0, reply_to_message->checklist_task_id_);
2038720388
const Message *m = get_message_force(d, message_id, "create_message_input_reply_to 2");
2038820389
if (m == nullptr) {
2038920390
if (message_id.is_server() && d->dialog_id.get_type() != DialogType::SecretChat &&
@@ -20392,7 +20393,7 @@ MessageInputReplyTo MessagesManager::create_message_input_reply_to(
2039220393
message_id <= d->notification_info->max_push_notification_message_id_)) {
2039320394
// allow to reply to yet unreceived server message in the same chat
2039420395
return MessageInputReplyTo{message_id, DialogId(), MessageQuote{td_, std::move(reply_to_message->quote_)},
20395-
reply_to_message->checklist_task_id_};
20396+
checklist_task_id};
2039620397
}
2039720398
if (!for_draft && top_thread_message_id.is_valid()) {
2039820399
return MessageInputReplyTo{top_thread_message_id, DialogId(), MessageQuote(), 0};
@@ -20403,8 +20404,11 @@ MessageInputReplyTo MessagesManager::create_message_input_reply_to(
2040320404
// TODO replies to yet unsent messages can be allowed with special handling of them on application restart
2040420405
return {};
2040520406
}
20407+
if (checklist_task_id != 0 && m->content->get_type() != MessageContentType::ToDoList) {
20408+
checklist_task_id = 0;
20409+
}
2040620410
return MessageInputReplyTo{m->message_id, DialogId(), MessageQuote{td_, std::move(reply_to_message->quote_)},
20407-
reply_to_message->checklist_task_id_};
20411+
checklist_task_id};
2040820412
}
2040920413
case td_api::inputMessageReplyToExternalMessage::ID: {
2041020414
auto reply_to_message = td_api::move_object_as<td_api::inputMessageReplyToExternalMessage>(reply_to);
@@ -20426,8 +20430,12 @@ MessageInputReplyTo MessagesManager::create_message_input_reply_to(
2042620430
LOG(INFO) << "Can't reply in another chat " << message_id << " in " << reply_d->dialog_id;
2042720431
return {};
2042820432
}
20433+
auto checklist_task_id = max(0, reply_to_message->checklist_task_id_);
20434+
if (checklist_task_id != 0 && m != nullptr && m->content->get_type() != MessageContentType::ToDoList) {
20435+
checklist_task_id = 0;
20436+
}
2042920437
return MessageInputReplyTo{m->message_id, reply_dialog_id, MessageQuote{td_, std::move(reply_to_message->quote_)},
20430-
reply_to_message->checklist_task_id_};
20438+
checklist_task_id};
2043120439
}
2043220440
default:
2043320441
UNREACHABLE();

0 commit comments

Comments
 (0)