Added ephemeral message actions and restrictions to context menus.

This commit is contained in:
23rd
2026-06-11 13:26:08 +03:00
committed by John Preston
parent 88fec5742f
commit 967b0bc875
11 changed files with 222 additions and 51 deletions
+29 -10
View File
@@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "chat_helpers/bot_command.h"
#include "core/core_cloud_password.h"
#include "core/click_handler_types.h"
#include "data/components/ephemeral_messages.h"
#include "data/data_changes.h"
#include "data/data_peer.h"
#include "data/data_poll.h"
@@ -58,7 +59,7 @@ void SendBotCallbackData(
std::optional<Core::CloudPasswordResult> password,
Fn<void()> done = nullptr,
Fn<void(const QString &)> handleError = nullptr) {
if (!item->isRegular()) {
if (!item->isRegular() && !item->isEphemeral()) {
return;
}
const auto history = item->history();
@@ -91,15 +92,16 @@ void SendBotCallbackData(
if (withPassword) {
flags |= MTPmessages_GetBotCallbackAnswer::Flag::f_password;
}
const auto ephemeralId = item->isEphemeral()
? session->ephemeralMessages().lookupId(item)
: 0;
if (item->isEphemeral() && (!ephemeralId || isGame || withPassword)) {
return;
}
const auto weak = base::make_weak(controller);
const auto show = controller->uiShow();
button->requestId = api->request(MTPmessages_GetBotCallbackAnswer(
MTP_flags(flags),
history->peer->input(),
MTP_int(item->id),
MTP_bytes(sendData),
password ? password->result : MTP_inputCheckPasswordEmpty()
)).done([=](const MTPmessages_BotCallbackAnswer &result) {
const auto handleDone = [=](
const MTPmessages_BotCallbackAnswer &result) {
const auto guard = gsl::finally([&] {
if (done) {
done();
@@ -149,7 +151,8 @@ void SendBotCallbackData(
} else if (withPassword) {
show->hideLayer();
}
}).fail([=](const MTP::Error &error) {
};
const auto handleFail = [=](const MTP::Error &error) {
const auto guard = gsl::finally([&] {
if (handleError) {
handleError(error.type());
@@ -164,7 +167,23 @@ void SendBotCallbackData(
button->requestId = 0;
owner->requestItemRepaint(item);
}
}).send();
};
button->requestId = ephemeralId
? api->request(MTPephemeral_GetCallbackAnswer(
MTP_flags(sendData.isEmpty()
? MTPephemeral_GetCallbackAnswer::Flag(0)
: MTPephemeral_GetCallbackAnswer::Flag::f_data),
history->peer->input(),
MTP_int(ephemeralId),
MTP_bytes(sendData)
)).done(handleDone).fail(handleFail).send()
: api->request(MTPmessages_GetBotCallbackAnswer(
MTP_flags(flags),
history->peer->input(),
MTP_int(item->id),
MTP_bytes(sendData),
password ? password->result : MTP_inputCheckPasswordEmpty()
)).done(handleDone).fail(handleFail).send();
session->changes().messageUpdated(
item,