Fixed glitch for scheduled messages with elapsed date in channels.

This commit is contained in:
23rd 2020-10-07 21:38:45 +03:00 committed by John Preston
parent 7de9bcad03
commit 5540b0bb8b
2 changed files with 24 additions and 18 deletions

View file

@ -63,6 +63,22 @@ enum class DataIsLoadedResult {
Ok = 3,
};
void ProcessScheduledMessageWithElapsedTime(
not_null<Main::Session*> session,
bool needToAdd,
const MTPDmessage &data) {
if (needToAdd && !data.is_from_scheduled()) {
// If we still need to add a new message,
// we should first check if this message is in
// the list of scheduled messages.
// This is necessary to correctly update the file reference.
// Note that when a message is scheduled until online
// while the recipient is already online, the server sends
// an ordinary new message with skipped "from_scheduled" flag.
session->data().scheduledMessages().checkEntitiesAndUpdate(data);
}
}
bool IsForceLogoutNotification(const MTPDupdateServiceNotification &data) {
return qs(data.vtype()).startsWith(qstr("AUTH_KEY_DROP_"));
}
@ -958,17 +974,7 @@ void Updates::applyUpdateNoPtsCheck(const MTPUpdate &update) {
LOG(("Skipping message, because it is already in blocks!"));
needToAdd = false;
}
if (needToAdd && !data.is_from_scheduled()) {
// If we still need to add a new message,
// we should first check if this message is in
// the list of scheduled messages.
// This is necessary to correctly update the file reference.
// Note that when a message is scheduled until online
// while the recipient is already online, the server sends
// an ordinary new message with skipped "from_scheduled" flag.
_session->data().scheduledMessages().checkEntitiesAndUpdate(
data);
}
ProcessScheduledMessageWithElapsedTime(_session, needToAdd, data);
}
if (needToAdd) {
_session->data().addNewMessage(
@ -1057,10 +1063,12 @@ void Updates::applyUpdateNoPtsCheck(const MTPUpdate &update) {
auto &d = update.c_updateNewChannelMessage();
auto needToAdd = true;
if (d.vmessage().type() == mtpc_message) { // index forwarded messages to links _overview
if (_session->data().checkEntitiesAndViewsUpdate(d.vmessage().c_message())) { // already in blocks
const auto &data = d.vmessage().c_message();
if (_session->data().checkEntitiesAndViewsUpdate(data)) { // already in blocks
LOG(("Skipping message, because it is already in blocks!"));
needToAdd = false;
}
ProcessScheduledMessageWithElapsedTime(_session, needToAdd, data);
}
if (needToAdd) {
_session->data().addNewMessage(

View file

@ -228,14 +228,12 @@ void ScheduledMessages::apply(const MTPDupdateNewScheduledMessage &update) {
void ScheduledMessages::checkEntitiesAndUpdate(const MTPDmessage &data) {
// When the user sends a message with a media scheduled until online
// while the recipient is already online, the server sends
// updateNewMessage to the client and the client calls this method.
// while the recipient is already online, or scheduled message
// is already due and is sent immediately, the server sends
// updateNewMessage or updateNewChannelMessage to the client
// and the client calls this method.
const auto peer = peerFromMTP(data.vpeer_id());
if (!peerIsUser(peer)) {
return;
}
const auto history = _session->data().historyLoaded(peer);
if (!history) {
return;