Add warning when reply quote changes.

This commit is contained in:
levlam 2023-10-31 18:20:55 +03:00
parent d5d069416e
commit 0e2300e1fa
3 changed files with 18 additions and 5 deletions

View File

@ -35928,7 +35928,7 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr
return is_deleted_message(d, reply_message_full_id.get_message_id());
};
if (RepliedMessageInfo::need_reply_changed_warning(
old_message->replied_message_info, new_message->replied_message_info,
td_, old_message->replied_message_info, new_message->replied_message_info,
old_message->top_thread_message_id, message_id.is_yet_unsent() && !is_message_in_dialog,
is_reply_to_deleted_message)) {
LOG(ERROR) << message_id << " in " << dialog_id << " has changed replied message from "

View File

@ -193,8 +193,9 @@ bool RepliedMessageInfo::need_reget() const {
}
bool RepliedMessageInfo::need_reply_changed_warning(
const RepliedMessageInfo &old_info, const RepliedMessageInfo &new_info, MessageId old_top_thread_message_id,
bool is_yet_unsent, std::function<bool(const RepliedMessageInfo &info)> is_reply_to_deleted_message) {
const Td *td, const RepliedMessageInfo &old_info, const RepliedMessageInfo &new_info,
MessageId old_top_thread_message_id, bool is_yet_unsent,
std::function<bool(const RepliedMessageInfo &info)> is_reply_to_deleted_message) {
if (old_info.origin_date_ != new_info.origin_date_ && old_info.origin_date_ != 0 && new_info.origin_date_ != 0) {
// date of the original message can't change
return true;
@ -204,6 +205,17 @@ bool RepliedMessageInfo::need_reply_changed_warning(
// only signature can change in the message origin
return true;
}
if (old_info.is_quote_manual_ != new_info.is_quote_manual_) {
// quote manual property can't change
return true;
}
if (old_info.quote_ != new_info.quote_) {
auto max_size = static_cast<size_t>(td->option_manager_->get_option_integer("message_reply_quote_length_max"));
if (old_info.quote_.text.size() < max_size && new_info.quote_.text.size() < max_size) {
// quote can't change, unless truncated differently
return true;
}
}
if (old_info.dialog_id_ != new_info.dialog_id_ && old_info.dialog_id_ != DialogId() &&
new_info.dialog_id_ != DialogId()) {
// reply chat can't change

View File

@ -71,8 +71,9 @@ class RepliedMessageInfo {
bool need_reget() const;
static bool need_reply_changed_warning(
const RepliedMessageInfo &old_info, const RepliedMessageInfo &new_info, MessageId old_top_thread_message_id,
bool is_yet_unsent, std::function<bool(const RepliedMessageInfo &info)> is_reply_to_deleted_message);
const Td *td, const RepliedMessageInfo &old_info, const RepliedMessageInfo &new_info,
MessageId old_top_thread_message_id, bool is_yet_unsent,
std::function<bool(const RepliedMessageInfo &info)> is_reply_to_deleted_message);
vector<FileId> get_file_ids(Td *td) const;