mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 23:27:09 +02:00
Show correct reply in Replies bot.
This commit is contained in:
parent
4a94a0c438
commit
be14456290
10 changed files with 62 additions and 20 deletions
|
@ -1153,6 +1153,9 @@ Message ParseMessage(
|
|||
result.replyToPeerId = data.vreply_to_peer_id()
|
||||
? ParsePeerId(*data.vreply_to_peer_id())
|
||||
: 0;
|
||||
if (result.replyToPeerId == result.peerId) {
|
||||
result.replyToPeerId = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1712,7 +1715,7 @@ MessagesSlice ParseMessagesSlice(
|
|||
MessagesSlice AdjustMigrateMessageIds(MessagesSlice slice) {
|
||||
for (auto &message : slice.list) {
|
||||
message.id += kMigratedMessagesIdShift;
|
||||
if (message.replyToMsgId) {
|
||||
if (message.replyToMsgId && !message.replyToPeerId) {
|
||||
message.replyToMsgId += kMigratedMessagesIdShift;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1192,8 +1192,12 @@ auto HtmlWriter::Wrap::pushMessage(
|
|||
}
|
||||
if (message.replyToMsgId) {
|
||||
block.append(pushDiv("reply_to details"));
|
||||
block.append("In reply to ");
|
||||
block.append(wrapReplyToLink("this message"));
|
||||
if (message.replyToPeerId) {
|
||||
block.append("In reply to a message in another chat");
|
||||
} else {
|
||||
block.append("In reply to ");
|
||||
block.append(wrapReplyToLink("this message"));
|
||||
}
|
||||
block.append(popTag());
|
||||
}
|
||||
|
||||
|
|
|
@ -303,6 +303,9 @@ QByteArray SerializeMessage(
|
|||
const QByteArray &label = "reply_to_message_id") {
|
||||
if (message.replyToMsgId) {
|
||||
push(label, message.replyToMsgId);
|
||||
if (message.replyToPeerId) {
|
||||
push("reply_to_peer_id", message.replyToPeerId);
|
||||
}
|
||||
}
|
||||
};
|
||||
const auto pushUserNames = [&](
|
||||
|
|
|
@ -957,7 +957,7 @@ not_null<HistoryItem*> HistoryItem::Create(
|
|||
data.vid().v,
|
||||
data.vflags().v,
|
||||
clientFlags,
|
||||
0, // #TODO replies data.vreply_to()
|
||||
MsgId(0), // No need to pass reply_to data here.
|
||||
data.vvia_bot_id().value_or_empty(),
|
||||
data.vdate().v,
|
||||
data.vfrom_id() ? peerFromMTP(*data.vfrom_id()) : PeerId(0));
|
||||
|
|
|
@ -204,7 +204,9 @@ bool HistoryMessageReply::updateData(
|
|||
}
|
||||
if (!replyToMsg) {
|
||||
replyToMsg = holder->history()->owner().message(
|
||||
holder->channelId(),
|
||||
(replyToPeerId
|
||||
? peerToChannel(replyToPeerId)
|
||||
: holder->channelId()),
|
||||
replyToMsgId);
|
||||
if (replyToMsg) {
|
||||
if (replyToMsg->isEmpty()) {
|
||||
|
|
|
@ -105,6 +105,7 @@ struct HistoryMessageReply : public RuntimeComponent<HistoryMessageReply, Histor
|
|||
HistoryMessageReply(HistoryMessageReply &&other) = delete;
|
||||
HistoryMessageReply &operator=(const HistoryMessageReply &other) = delete;
|
||||
HistoryMessageReply &operator=(HistoryMessageReply &&other) {
|
||||
replyToPeerId = other.replyToPeerId;
|
||||
replyToMsgId = other.replyToMsgId;
|
||||
replyToMsgTop = other.replyToMsgTop;
|
||||
replyToDocumentId = other.replyToDocumentId;
|
||||
|
@ -147,6 +148,9 @@ struct HistoryMessageReply : public RuntimeComponent<HistoryMessageReply, Histor
|
|||
int w,
|
||||
PaintFlags flags) const;
|
||||
|
||||
[[nodiscard]] PeerId replyToPeer() const {
|
||||
return replyToPeerId;
|
||||
}
|
||||
[[nodiscard]] MsgId replyToId() const {
|
||||
return replyToMsgId;
|
||||
}
|
||||
|
@ -164,6 +168,7 @@ struct HistoryMessageReply : public RuntimeComponent<HistoryMessageReply, Histor
|
|||
|
||||
void refreshReplyToDocument();
|
||||
|
||||
PeerId replyToPeerId = 0;
|
||||
MsgId replyToMsgId = 0;
|
||||
MsgId replyToMsgTop = 0;
|
||||
HistoryItem *replyToMsg = nullptr;
|
||||
|
|
|
@ -405,6 +405,7 @@ QString GetErrorTextForSending(
|
|||
}
|
||||
|
||||
struct HistoryMessage::CreateConfig {
|
||||
PeerId replyToPeer = 0;
|
||||
MsgId replyTo = 0;
|
||||
MsgId replyToTop = 0;
|
||||
UserId viaBotId = 0;
|
||||
|
@ -466,7 +467,12 @@ HistoryMessage::HistoryMessage(
|
|||
}
|
||||
if (const auto reply = data.vreply_to()) {
|
||||
reply->match([&](const MTPDmessageReplyHeader &data) {
|
||||
// #TODO replies reply_to_peer_id.
|
||||
if (const auto peer = data.vreply_to_peer_id()) {
|
||||
config.replyToPeer = peerFromMTP(*peer);
|
||||
if (config.replyToPeer == history->peer->id) {
|
||||
config.replyToPeer = 0;
|
||||
}
|
||||
}
|
||||
config.replyTo = data.vreply_to_msg_id().v;
|
||||
config.replyToTop = data.vreply_to_top_id().value_or(
|
||||
config.replyTo);
|
||||
|
@ -514,9 +520,14 @@ HistoryMessage::HistoryMessage(
|
|||
|
||||
if (const auto reply = data.vreply_to()) {
|
||||
reply->match([&](const MTPDmessageReplyHeader &data) {
|
||||
config.replyTo = data.vreply_to_msg_id().v;
|
||||
config.replyToTop = data.vreply_to_top_id().value_or(
|
||||
config.replyTo);
|
||||
const auto peer = data.vreply_to_peer_id()
|
||||
? peerFromMTP(*data.vreply_to_peer_id())
|
||||
: history->peer->id;
|
||||
if (!peer || peer == history->peer->id) {
|
||||
config.replyTo = data.vreply_to_msg_id().v;
|
||||
config.replyToTop = data.vreply_to_top_id().value_or(
|
||||
config.replyTo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -911,11 +922,15 @@ void HistoryMessage::createComponents(const CreateConfig &config) {
|
|||
UpdateComponents(mask);
|
||||
|
||||
if (const auto reply = Get<HistoryMessageReply>()) {
|
||||
reply->replyToPeerId = config.replyToPeer;
|
||||
reply->replyToMsgId = config.replyTo;
|
||||
reply->replyToMsgTop = isScheduled() ? 0 : config.replyToTop;
|
||||
if (!reply->updateData(this)) {
|
||||
history()->session().api().requestMessageData(
|
||||
history()->peer->asChannel(),
|
||||
(peerIsChannel(reply->replyToPeerId)
|
||||
? history()->owner().channel(
|
||||
peerToChannel(reply->replyToPeerId)).get()
|
||||
: history()->peer->asChannel()),
|
||||
reply->replyToMsgId,
|
||||
HistoryDependentItemCallback(this));
|
||||
}
|
||||
|
|
|
@ -681,17 +681,22 @@ void HistoryService::createFromMtp(const MTPDmessageService &message) {
|
|||
Get<HistoryServicePayment>()->amount = HistoryView::FillAmountAndCurrency(amount, currency);
|
||||
}
|
||||
if (const auto replyTo = message.vreply_to()) {
|
||||
if (message.vaction().type() == mtpc_messageActionPinMessage) {
|
||||
UpdateComponents(HistoryServicePinned::Bit());
|
||||
}
|
||||
replyTo->match([&](const MTPDmessageReplyHeader &data) {
|
||||
if (const auto dependent = GetDependentData()) {
|
||||
dependent->msgId = data.vreply_to_msg_id().v;
|
||||
if (!updateDependent()) {
|
||||
history()->session().api().requestMessageData(
|
||||
history()->peer->asChannel(),
|
||||
dependent->msgId,
|
||||
HistoryDependentItemCallback(this));
|
||||
const auto peer = data.vreply_to_peer_id()
|
||||
? peerFromMTP(*data.vreply_to_peer_id())
|
||||
: history()->peer->id;
|
||||
if (!peer || peer == history()->peer->id) {
|
||||
if (message.vaction().type() == mtpc_messageActionPinMessage) {
|
||||
UpdateComponents(HistoryServicePinned::Bit());
|
||||
}
|
||||
if (const auto dependent = GetDependentData()) {
|
||||
dependent->msgId = data.vreply_to_msg_id().v;
|
||||
if (!updateDependent()) {
|
||||
history()->session().api().requestMessageData(
|
||||
history()->peer->asChannel(),
|
||||
dependent->msgId,
|
||||
HistoryDependentItemCallback(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1794,6 +1794,8 @@ void HistoryWidget::showHistory(
|
|||
updateNotifyControls();
|
||||
session().data().requestNotifySettings(_peer);
|
||||
refreshSilentToggle();
|
||||
} else if (_peer->isRepliesChat()) {
|
||||
updateNotifyControls();
|
||||
}
|
||||
refreshScheduledToggle();
|
||||
|
||||
|
|
|
@ -737,6 +737,9 @@ void Notification::updateNotifyDisplay() {
|
|||
if (_fromScheduled && _history->peer->isSelf()) {
|
||||
Ui::EmptyUserpic::PaintSavedMessages(p, st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), width(), st::notifyPhotoSize);
|
||||
_userpicLoaded = true;
|
||||
} else if (_history->peer->isRepliesChat()) {
|
||||
Ui::EmptyUserpic::PaintRepliesMessages(p, st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), width(), st::notifyPhotoSize);
|
||||
_userpicLoaded = true;
|
||||
} else {
|
||||
_userpicView = _history->peer->createUserpicView();
|
||||
_history->peer->loadUserpic();
|
||||
|
|
Loading…
Add table
Reference in a new issue