Fix mixed order of messages for dices and files too

This commit is contained in:
Eric Kotato 2021-03-30 16:52:23 +03:00
parent 252a0d6581
commit 3ae7ac50c3
2 changed files with 46 additions and 42 deletions

View file

@ -122,18 +122,20 @@ void SendExistingMedia(
session->data().registerMessageRandomId(randomId, newId); session->data().registerMessageRandomId(randomId, newId);
history->addNewLocalMessage( if (!forwarding) {
newId.msg, history->addNewLocalMessage(
flags, newId.msg,
clientFlags, flags,
0, clientFlags,
replyTo, 0,
HistoryItem::NewMessageDate(message.action.options.scheduled), replyTo,
messageFromId, HistoryItem::NewMessageDate(message.action.options.scheduled),
messagePostAuthor, messageFromId,
media, messagePostAuthor,
caption, media,
MTPReplyMarkup()); caption,
MTPReplyMarkup());
}
auto performRequest = [=](const auto &repeatRequest) -> void { auto performRequest = [=](const auto &repeatRequest) -> void {
auto &histories = history->owner().histories(); auto &histories = history->owner().histories();
@ -299,34 +301,36 @@ bool SendDice(
session->data().registerMessageRandomId(randomId, newId); session->data().registerMessageRandomId(randomId, newId);
const auto views = 1; if (!forwarding) {
const auto forwards = 0; const auto views = 1;
history->addNewMessage( const auto forwards = 0;
MTP_message( history->addNewMessage(
MTP_flags(flags), MTP_message(
MTP_int(newId.msg), MTP_flags(flags),
peerToMTP(messageFromId), MTP_int(newId.msg),
peerToMTP(history->peer->id), peerToMTP(messageFromId),
MTPMessageFwdHeader(), peerToMTP(history->peer->id),
MTPint(), // via_bot_id MTPMessageFwdHeader(),
replyHeader, MTPint(), // via_bot_id
MTP_int(HistoryItem::NewMessageDate( replyHeader,
message.action.options.scheduled)), MTP_int(HistoryItem::NewMessageDate(
MTP_string(), message.action.options.scheduled)),
MTP_messageMediaDice(MTP_int(0), MTP_string(emoji)), MTP_string(),
MTPReplyMarkup(), MTP_messageMediaDice(MTP_int(0), MTP_string(emoji)),
MTP_vector<MTPMessageEntity>(), MTPReplyMarkup(),
MTP_int(views), MTP_vector<MTPMessageEntity>(),
MTP_int(forwards), MTP_int(views),
MTPMessageReplies(), MTP_int(forwards),
MTPint(), // edit_date MTPMessageReplies(),
MTP_string(messagePostAuthor), MTPint(), // edit_date
MTPlong(), MTP_string(messagePostAuthor),
//MTPMessageReactions(), MTPlong(),
MTPVector<MTPRestrictionReason>(), //MTPMessageReactions(),
MTPint()), // ttl_period MTPVector<MTPRestrictionReason>(),
clientFlags, MTPint()), // ttl_period
NewMessageType::Unread); clientFlags,
NewMessageType::Unread);
}
const auto requestType = Data::Histories::RequestType::Send; const auto requestType = Data::Histories::RequestType::Send;
histories.sendRequest(history, requestType, [=](Fn<void()> finish) { histories.sendRequest(history, requestType, [=](Fn<void()> finish) {

View file

@ -4520,9 +4520,9 @@ void ApiWrap::sendMessage(
} else { } else {
clientFlags |= MTPDmessage_ClientFlag::f_local_history_entry; clientFlags |= MTPDmessage_ClientFlag::f_local_history_entry;
} }
const auto views = 1;
const auto forwards = 0;
if (!forwarding) { if (!forwarding) {
const auto views = 1;
const auto forwards = 0;
lastMessage = history->addNewMessage( lastMessage = history->addNewMessage(
MTP_message( MTP_message(
MTP_flags(flags), MTP_flags(flags),