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; 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) { MTPMessageReplyHeader NewMessageReplyHeader(const Api::SendAction &action) {
if (const auto id = action.replyTo) { if (const auto id = action.replyTo) {
const auto history = action.history; if (const auto replyToTop = LookupReplyToTop(action.history, id)) {
const auto &owner = history->owner(); return MTP_messageReplyHeader(
if (const auto item = owner.message(history->channelId(), id)) { MTP_flags(MTPDmessageReplyHeader::Flag::f_reply_to_top_id),
if (item->replyToId()) { MTP_int(id),
return MTP_messageReplyHeader( MTPPeer(),
MTP_flags(MTPDmessageReplyHeader::Flag::f_reply_to_top_id), MTP_int(replyToTop));
MTP_int(id),
MTPPeer(),
MTP_int(item->replyToTop()));
}
} }
return MTP_messageReplyHeader( return MTP_messageReplyHeader(
MTP_flags(0), 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_via_bot_id) config.viaBotId = viaBotId;
if (flags & MTPDmessage::Flag::f_reply_to) { 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_reply_markup) config.mtpMarkup = &markup;
if (flags & MTPDmessage::Flag::f_post_author) config.author = postAuthor; if (flags & MTPDmessage::Flag::f_post_author) config.author = postAuthor;

View File

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