Fix reply_to_top_id in local sent stickers.

Fixes #8758.
This commit is contained in:
John Preston 2020-10-06 14:01:19 +03:00
parent 5a3733b5b6
commit cd506dfff5
2 changed files with 27 additions and 17 deletions

View File

@ -374,18 +374,22 @@ MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer) {
return result;
}
MsgId LookupReplyToTop(not_null<History*> history, MsgId replyToId) {
const auto &owner = history->owner();
if (const auto item = owner.message(history->channelId(), replyToId)) {
return item->replyToTop();
}
return 0;
}
MTPMessageReplyHeader NewMessageReplyHeader(const Api::SendAction &action) {
if (const auto id = action.replyTo) {
const auto history = action.history;
const auto &owner = history->owner();
if (const auto item = owner.message(history->channelId(), id)) {
if (item->replyToId()) {
return MTP_messageReplyHeader(
MTP_flags(MTPDmessageReplyHeader::Flag::f_reply_to_top_id),
MTP_int(id),
MTPPeer(),
MTP_int(item->replyToTop()));
}
if (const auto replyToTop = LookupReplyToTop(action.history, id)) {
return MTP_messageReplyHeader(
MTP_flags(MTPDmessageReplyHeader::Flag::f_reply_to_top_id),
MTP_int(id),
MTPPeer(),
MTP_int(replyToTop));
}
return MTP_messageReplyHeader(
MTP_flags(0),
@ -741,7 +745,9 @@ void HistoryMessage::createComponentsHelper(
if (flags & MTPDmessage::Flag::f_via_bot_id) config.viaBotId = viaBotId;
if (flags & MTPDmessage::Flag::f_reply_to) {
config.replyToTop = config.replyTo = replyTo;
config.replyTo = replyTo;
const auto replyToTop = LookupReplyToTop(history(), replyTo);
config.replyToTop = replyToTop ? replyToTop : replyTo;
}
if (flags & MTPDmessage::Flag::f_reply_markup) config.mtpMarkup = &markup;
if (flags & MTPDmessage::Flag::f_post_author) config.author = postAuthor;

View File

@ -21,16 +21,20 @@ struct HistoryMessageEdited;
struct HistoryMessageReply;
struct HistoryMessageViews;
Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
[[nodiscard]] Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
not_null<HistoryItem*> item);
MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer);
MTPDmessage_ClientFlags NewMessageClientFlags();
MTPMessageReplyHeader NewMessageReplyHeader(const Api::SendAction &action);
QString GetErrorTextForSending(
[[nodiscard]] MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer);
[[nodiscard]] MTPDmessage_ClientFlags NewMessageClientFlags();
[[nodiscard]] MsgId LookupReplyToTop(
not_null<History*> history,
MsgId replyToId);
[[nodiscard]] MTPMessageReplyHeader NewMessageReplyHeader(
const Api::SendAction &action);
[[nodiscard]] QString GetErrorTextForSending(
not_null<PeerData*> peer,
const HistoryItemsList &items,
bool ignoreSlowmodeCountdown = false);
QString GetErrorTextForSending(
[[nodiscard]] QString GetErrorTextForSending(
not_null<PeerData*> peer,
const HistoryItemsList &items,
const TextWithTags &comment,