Set parser error if invalid reaction is stored in database.

This commit is contained in:
levlam 2024-01-02 03:03:39 +03:00
parent 0e2b7eab27
commit 2bfe13f832

View File

@ -62,12 +62,16 @@ void MessageReaction::parse(ParserT &parser) {
}
if (has_my_recent_chooser_dialog_id) {
td::parse(my_recent_chooser_dialog_id_, parser);
CHECK(my_recent_chooser_dialog_id_.is_valid());
CHECK(td::contains(recent_chooser_dialog_ids_, my_recent_chooser_dialog_id_));
if (!my_recent_chooser_dialog_id_.is_valid() ||
!td::contains(recent_chooser_dialog_ids_, my_recent_chooser_dialog_id_)) {
return parser.set_error("Invalid recent reaction chooser");
}
}
fix_choose_count();
CHECK(!is_empty());
CHECK(!reaction_type_.is_empty());
if (is_empty() || reaction_type_.is_empty()) {
parser.set_error("Invalid message reaction");
}
}
template <class StorerT>
@ -86,7 +90,9 @@ void UnreadMessageReaction::parse(ParserT &parser) {
END_PARSE_FLAGS();
td::parse(reaction_type_, parser);
td::parse(sender_dialog_id_, parser);
CHECK(!reaction_type_.is_empty());
if (reaction_type_.is_empty()) {
parser.set_error("Invalid unread message reaction");
}
}
template <class StorerT>