mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-05 00:46:08 +00:00
Implement sending of shortcutted messages.
This commit is contained in:
@@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_histories.h"
|
||||
|
||||
#include "api/api_text_entities.h"
|
||||
#include "data/business/data_shortcut_messages.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
@@ -821,6 +822,7 @@ void Histories::deleteMessages(const MessageIdsList &ids, bool revoke) {
|
||||
remove.reserve(ids.size());
|
||||
base::flat_map<not_null<History*>, QVector<MTPint>> idsByPeer;
|
||||
base::flat_map<not_null<PeerData*>, QVector<MTPint>> scheduledIdsByPeer;
|
||||
base::flat_map<BusinessShortcutId, QVector<MTPint>> quickIdsByShortcut;
|
||||
for (const auto &itemId : ids) {
|
||||
if (const auto item = _owner->message(itemId)) {
|
||||
const auto history = item->history();
|
||||
@@ -834,6 +836,16 @@ void Histories::deleteMessages(const MessageIdsList &ids, bool revoke) {
|
||||
_owner->scheduledMessages().removeSending(item);
|
||||
}
|
||||
continue;
|
||||
} else if (item->isBusinessShortcut()) {
|
||||
const auto wasOnServer = !item->isSending()
|
||||
&& !item->hasFailed();
|
||||
if (wasOnServer) {
|
||||
quickIdsByShortcut[item->shortcutId()].push_back(MTP_int(
|
||||
_owner->shortcutMessages().lookupId(item)));
|
||||
} else {
|
||||
_owner->shortcutMessages().removeSending(item);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
remove.push_back(item);
|
||||
if (item->isRegular()) {
|
||||
@@ -853,6 +865,15 @@ void Histories::deleteMessages(const MessageIdsList &ids, bool revoke) {
|
||||
peer->session().api().applyUpdates(result);
|
||||
}).send();
|
||||
}
|
||||
for (const auto &[shortcutId, ids] : quickIdsByShortcut) {
|
||||
const auto api = &_owner->session().api();
|
||||
api->request(MTPmessages_DeleteQuickReplyMessages(
|
||||
MTP_int(shortcutId),
|
||||
MTP_vector<MTPint>(ids)
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
api->applyUpdates(result);
|
||||
}).send();
|
||||
}
|
||||
|
||||
for (const auto item : remove) {
|
||||
const auto history = item->history();
|
||||
|
Reference in New Issue
Block a user