mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Send as a channel in HistoryWidget.
This commit is contained in:
parent
1bd74fe478
commit
773755d70e
32 changed files with 221 additions and 156 deletions
|
@ -1085,6 +1085,8 @@ PRIVATE
|
||||||
ui/chat/attach/attach_item_single_file_preview.h
|
ui/chat/attach/attach_item_single_file_preview.h
|
||||||
ui/chat/attach/attach_item_single_media_preview.cpp
|
ui/chat/attach/attach_item_single_media_preview.cpp
|
||||||
ui/chat/attach/attach_item_single_media_preview.h
|
ui/chat/attach/attach_item_single_media_preview.h
|
||||||
|
ui/chat/choose_send_as.cpp
|
||||||
|
ui/chat/choose_send_as.h
|
||||||
ui/chat/choose_theme_controller.cpp
|
ui/chat/choose_theme_controller.cpp
|
||||||
ui/chat/choose_theme_controller.h
|
ui/chat/choose_theme_controller.h
|
||||||
ui/effects/fireworks_animation.cpp
|
ui/effects/fireworks_animation.cpp
|
||||||
|
|
|
@ -12,6 +12,7 @@ class History;
|
||||||
namespace Api {
|
namespace Api {
|
||||||
|
|
||||||
struct SendOptions {
|
struct SendOptions {
|
||||||
|
PeerData *sendAs = nullptr;
|
||||||
TimeId scheduled = 0;
|
TimeId scheduled = 0;
|
||||||
bool silent = false;
|
bool silent = false;
|
||||||
bool handleSupportSwitch = false;
|
bool handleSupportSwitch = false;
|
||||||
|
@ -25,7 +26,11 @@ enum class SendType {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SendAction {
|
struct SendAction {
|
||||||
explicit SendAction(not_null<History*> history) : history(history) {
|
explicit SendAction(
|
||||||
|
not_null<History*> history,
|
||||||
|
SendOptions options = SendOptions())
|
||||||
|
: history(history)
|
||||||
|
, options(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<History*> history;
|
not_null<History*> history;
|
||||||
|
@ -37,7 +42,7 @@ struct SendAction {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MessageToSend {
|
struct MessageToSend {
|
||||||
explicit MessageToSend(not_null<History*> history) : action(history) {
|
explicit MessageToSend(SendAction action) : action(action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SendAction action;
|
SendAction action;
|
||||||
|
|
|
@ -60,6 +60,10 @@ void Polls::create(
|
||||||
if (action.options.scheduled) {
|
if (action.options.scheduled) {
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_schedule_date;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_schedule_date;
|
||||||
}
|
}
|
||||||
|
const auto sendAs = action.options.sendAs;
|
||||||
|
if (sendAs) {
|
||||||
|
sendFlags |= MTPmessages_SendMedia::Flag::f_send_as;
|
||||||
|
}
|
||||||
auto &histories = history->owner().histories();
|
auto &histories = history->owner().histories();
|
||||||
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) {
|
||||||
|
@ -74,7 +78,7 @@ void Polls::create(
|
||||||
MTPReplyMarkup(),
|
MTPReplyMarkup(),
|
||||||
MTPVector<MTPMessageEntity>(),
|
MTPVector<MTPMessageEntity>(),
|
||||||
MTP_int(action.options.scheduled),
|
MTP_int(action.options.scheduled),
|
||||||
MTPInputPeer() // #TODO send_as
|
(sendAs ? sendAs->input : MTP_inputPeerEmpty())
|
||||||
)).done([=](
|
)).done([=](
|
||||||
const MTPUpdates &result,
|
const MTPUpdates &result,
|
||||||
const MTP::Response &response) mutable {
|
const MTP::Response &response) mutable {
|
||||||
|
|
|
@ -90,8 +90,18 @@ void SendExistingMedia(
|
||||||
if (silentPost) {
|
if (silentPost) {
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
||||||
}
|
}
|
||||||
auto messageFromId = anonymousPost ? 0 : session->userPeerId();
|
const auto sendAs = message.action.options.sendAs;
|
||||||
auto messagePostAuthor = peer->isBroadcast() ? session->user()->name : QString();
|
const auto messageFromId = sendAs
|
||||||
|
? sendAs->id
|
||||||
|
: anonymousPost
|
||||||
|
? 0
|
||||||
|
: session->userPeerId();
|
||||||
|
if (sendAs) {
|
||||||
|
sendFlags |= MTPmessages_SendMedia::Flag::f_send_as;
|
||||||
|
}
|
||||||
|
const auto messagePostAuthor = peer->isBroadcast()
|
||||||
|
? session->user()->name
|
||||||
|
: QString();
|
||||||
|
|
||||||
auto caption = TextWithEntities{
|
auto caption = TextWithEntities{
|
||||||
message.textWithTags.text,
|
message.textWithTags.text,
|
||||||
|
@ -143,7 +153,7 @@ void SendExistingMedia(
|
||||||
MTPReplyMarkup(),
|
MTPReplyMarkup(),
|
||||||
sentEntities,
|
sentEntities,
|
||||||
MTP_int(message.action.options.scheduled),
|
MTP_int(message.action.options.scheduled),
|
||||||
MTPInputPeer() // #TODO send_as
|
(sendAs ? sendAs->input : MTP_inputPeerEmpty())
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
api->applyUpdates(result, randomId);
|
api->applyUpdates(result, randomId);
|
||||||
finish();
|
finish();
|
||||||
|
@ -263,8 +273,18 @@ bool SendDice(MessageToSend &message) {
|
||||||
if (silentPost) {
|
if (silentPost) {
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
||||||
}
|
}
|
||||||
auto messageFromId = anonymousPost ? 0 : session->userPeerId();
|
const auto sendAs = message.action.options.sendAs;
|
||||||
auto messagePostAuthor = peer->isBroadcast() ? session->user()->name : QString();
|
const auto messageFromId = sendAs
|
||||||
|
? sendAs->id
|
||||||
|
: anonymousPost
|
||||||
|
? 0
|
||||||
|
: session->userPeerId();
|
||||||
|
if (sendAs) {
|
||||||
|
sendFlags |= MTPmessages_SendMedia::Flag::f_send_as;
|
||||||
|
}
|
||||||
|
const auto messagePostAuthor = peer->isBroadcast()
|
||||||
|
? session->user()->name
|
||||||
|
: QString();
|
||||||
const auto replyTo = message.action.replyTo;
|
const auto replyTo = message.action.replyTo;
|
||||||
|
|
||||||
if (message.action.options.scheduled) {
|
if (message.action.options.scheduled) {
|
||||||
|
@ -299,7 +319,7 @@ bool SendDice(MessageToSend &message) {
|
||||||
MTPReplyMarkup(),
|
MTPReplyMarkup(),
|
||||||
MTP_vector<MTPMessageEntity>(),
|
MTP_vector<MTPMessageEntity>(),
|
||||||
MTP_int(message.action.options.scheduled),
|
MTP_int(message.action.options.scheduled),
|
||||||
MTPInputPeer() // #TODO send_as
|
(sendAs ? sendAs->input : MTP_inputPeerEmpty())
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
api->applyUpdates(result, randomId);
|
api->applyUpdates(result, randomId);
|
||||||
finish();
|
finish();
|
||||||
|
@ -352,8 +372,7 @@ void SendConfirmedFile(
|
||||||
const auto history = session->data().history(file->to.peer);
|
const auto history = session->data().history(file->to.peer);
|
||||||
const auto peer = history->peer;
|
const auto peer = history->peer;
|
||||||
|
|
||||||
auto action = SendAction(history);
|
auto action = SendAction(history, file->to.options);
|
||||||
action.options = file->to.options;
|
|
||||||
action.clearDraft = false;
|
action.clearDraft = false;
|
||||||
action.replyTo = file->to.replyTo;
|
action.replyTo = file->to.replyTo;
|
||||||
action.generateLocal = true;
|
action.generateLocal = true;
|
||||||
|
@ -392,7 +411,12 @@ void SendConfirmedFile(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto messageFromId = anonymousPost ? 0 : session->userPeerId();
|
const auto messageFromId =
|
||||||
|
file->to.options.sendAs
|
||||||
|
? file->to.options.sendAs->id
|
||||||
|
: anonymousPost
|
||||||
|
? PeerId()
|
||||||
|
: session->userPeerId();
|
||||||
const auto messagePostAuthor = peer->isBroadcast()
|
const auto messagePostAuthor = peer->isBroadcast()
|
||||||
? session->user()->name
|
? session->user()->name
|
||||||
: QString();
|
: QString();
|
||||||
|
|
|
@ -3676,6 +3676,7 @@ void ApiWrap::forwardMessages(
|
||||||
}
|
}
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
const auto anonymousPost = peer->amAnonymous();
|
||||||
const auto silentPost = ShouldSendSilent(peer, action.options);
|
const auto silentPost = ShouldSendSilent(peer, action.options);
|
||||||
|
const auto sendAs = action.options.sendAs;
|
||||||
|
|
||||||
auto flags = MessageFlags();
|
auto flags = MessageFlags();
|
||||||
auto sendFlags = MTPmessages_ForwardMessages::Flags(0);
|
auto sendFlags = MTPmessages_ForwardMessages::Flags(0);
|
||||||
|
@ -3693,6 +3694,9 @@ void ApiWrap::forwardMessages(
|
||||||
if (draft.options == Data::ForwardOptions::NoNamesAndCaptions) {
|
if (draft.options == Data::ForwardOptions::NoNamesAndCaptions) {
|
||||||
sendFlags |= MTPmessages_ForwardMessages::Flag::f_drop_media_captions;
|
sendFlags |= MTPmessages_ForwardMessages::Flag::f_drop_media_captions;
|
||||||
}
|
}
|
||||||
|
if (sendAs) {
|
||||||
|
sendFlags |= MTPmessages_ForwardMessages::Flag::f_send_as;
|
||||||
|
}
|
||||||
|
|
||||||
auto forwardFrom = draft.items.front()->history()->peer;
|
auto forwardFrom = draft.items.front()->history()->peer;
|
||||||
auto ids = QVector<MTPint>();
|
auto ids = QVector<MTPint>();
|
||||||
|
@ -3713,7 +3717,7 @@ void ApiWrap::forwardMessages(
|
||||||
MTP_vector<MTPlong>(randomIds),
|
MTP_vector<MTPlong>(randomIds),
|
||||||
peer->input,
|
peer->input,
|
||||||
MTP_int(action.options.scheduled),
|
MTP_int(action.options.scheduled),
|
||||||
MTPInputPeer() // #TODO send_as
|
(sendAs ? sendAs->input : MTP_inputPeerEmpty())
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
applyUpdates(result);
|
applyUpdates(result);
|
||||||
if (shared && !--shared->requestsLeft) {
|
if (shared && !--shared->requestsLeft) {
|
||||||
|
@ -3749,7 +3753,9 @@ void ApiWrap::forwardMessages(
|
||||||
peerToChannel(peer->id),
|
peerToChannel(peer->id),
|
||||||
_session->data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
const auto self = _session->user();
|
const auto self = _session->user();
|
||||||
const auto messageFromId = anonymousPost
|
const auto messageFromId = sendAs
|
||||||
|
? sendAs->id
|
||||||
|
: anonymousPost
|
||||||
? PeerId(0)
|
? PeerId(0)
|
||||||
: self->id;
|
: self->id;
|
||||||
const auto messagePostAuthor = peer->isBroadcast()
|
const auto messagePostAuthor = peer->isBroadcast()
|
||||||
|
@ -3830,7 +3836,11 @@ void ApiWrap::sendSharedContact(
|
||||||
if (action.options.scheduled) {
|
if (action.options.scheduled) {
|
||||||
flags |= MessageFlag::IsOrWasScheduled;
|
flags |= MessageFlag::IsOrWasScheduled;
|
||||||
}
|
}
|
||||||
const auto messageFromId = anonymousPost ? 0 : _session->userPeerId();
|
const auto messageFromId = action.options.sendAs
|
||||||
|
? action.options.sendAs->id
|
||||||
|
: anonymousPost
|
||||||
|
? PeerId()
|
||||||
|
: _session->userPeerId();
|
||||||
const auto messagePostAuthor = peer->isBroadcast()
|
const auto messagePostAuthor = peer->isBroadcast()
|
||||||
? _session->user()->name
|
? _session->user()->name
|
||||||
: QString();
|
: QString();
|
||||||
|
@ -3910,9 +3920,8 @@ void ApiWrap::sendFiles(
|
||||||
const SendAction &action) {
|
const SendAction &action) {
|
||||||
const auto haveCaption = !caption.text.isEmpty();
|
const auto haveCaption = !caption.text.isEmpty();
|
||||||
if (haveCaption && !list.canAddCaption(album != nullptr)) {
|
if (haveCaption && !list.canAddCaption(album != nullptr)) {
|
||||||
auto message = MessageToSend(action.history);
|
auto message = MessageToSend(action);
|
||||||
message.textWithTags = base::take(caption);
|
message.textWithTags = base::take(caption);
|
||||||
message.action = action;
|
|
||||||
message.action.clearDraft = false;
|
message.action.clearDraft = false;
|
||||||
sendMessage(std::move(message));
|
sendMessage(std::move(message));
|
||||||
}
|
}
|
||||||
|
@ -4086,8 +4095,16 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||||
history->clearCloudDraft();
|
history->clearCloudDraft();
|
||||||
history->startSavingCloudDraft();
|
history->startSavingCloudDraft();
|
||||||
}
|
}
|
||||||
auto messageFromId = anonymousPost ? 0 : _session->userPeerId();
|
const auto sendAs = action.options.sendAs;
|
||||||
auto messagePostAuthor = peer->isBroadcast()
|
const auto messageFromId = sendAs
|
||||||
|
? sendAs->id
|
||||||
|
: anonymousPost
|
||||||
|
? PeerId()
|
||||||
|
: _session->userPeerId();
|
||||||
|
if (sendAs) {
|
||||||
|
sendFlags |= MTPmessages_SendMessage::Flag::f_send_as;
|
||||||
|
}
|
||||||
|
const auto messagePostAuthor = peer->isBroadcast()
|
||||||
? _session->user()->name
|
? _session->user()->name
|
||||||
: QString();
|
: QString();
|
||||||
if (action.options.scheduled) {
|
if (action.options.scheduled) {
|
||||||
|
@ -4116,7 +4133,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||||
MTPReplyMarkup(),
|
MTPReplyMarkup(),
|
||||||
sentEntities,
|
sentEntities,
|
||||||
MTP_int(action.options.scheduled),
|
MTP_int(action.options.scheduled),
|
||||||
MTPInputPeer() // #TODO send_as
|
(sendAs ? sendAs->input : MTP_inputPeerEmpty())
|
||||||
)).done([=](
|
)).done([=](
|
||||||
const MTPUpdates &result,
|
const MTPUpdates &result,
|
||||||
const MTP::Response &response) {
|
const MTP::Response &response) {
|
||||||
|
@ -4160,7 +4177,8 @@ void ApiWrap::sendBotStart(not_null<UserData*> bot, PeerData *chat) {
|
||||||
auto &info = bot->botInfo;
|
auto &info = bot->botInfo;
|
||||||
auto &token = chat ? info->startGroupToken : info->startToken;
|
auto &token = chat ? info->startGroupToken : info->startToken;
|
||||||
if (token.isEmpty()) {
|
if (token.isEmpty()) {
|
||||||
auto message = ApiWrap::MessageToSend(_session->data().history(bot));
|
auto message = MessageToSend(
|
||||||
|
Api::SendAction(_session->data().history(bot)));
|
||||||
message.textWithTags = { qsl("/start"), TextWithTags::Tags() };
|
message.textWithTags = { qsl("/start"), TextWithTags::Tags() };
|
||||||
sendMessage(std::move(message));
|
sendMessage(std::move(message));
|
||||||
return;
|
return;
|
||||||
|
@ -4213,7 +4231,14 @@ void ApiWrap::sendInlineResult(
|
||||||
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_schedule_date;
|
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_schedule_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto messageFromId = anonymousPost ? 0 : _session->userPeerId();
|
const auto sendAs = action.options.sendAs;
|
||||||
|
const auto messageFromId = sendAs
|
||||||
|
? sendAs->id
|
||||||
|
: anonymousPost ? PeerId()
|
||||||
|
: _session->userPeerId();
|
||||||
|
if (sendAs) {
|
||||||
|
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_send_as;
|
||||||
|
}
|
||||||
const auto messagePostAuthor = peer->isBroadcast()
|
const auto messagePostAuthor = peer->isBroadcast()
|
||||||
? _session->user()->name
|
? _session->user()->name
|
||||||
: QString();
|
: QString();
|
||||||
|
@ -4244,7 +4269,7 @@ void ApiWrap::sendInlineResult(
|
||||||
MTP_long(data->getQueryId()),
|
MTP_long(data->getQueryId()),
|
||||||
MTP_string(data->getId()),
|
MTP_string(data->getId()),
|
||||||
MTP_int(action.options.scheduled),
|
MTP_int(action.options.scheduled),
|
||||||
MTPInputPeer() // #TODO send_as
|
(sendAs ? sendAs->input : MTP_inputPeerEmpty())
|
||||||
)).done([=](
|
)).done([=](
|
||||||
const MTPUpdates &result,
|
const MTPUpdates &result,
|
||||||
const MTP::Response &response) {
|
const MTP::Response &response) {
|
||||||
|
@ -4381,6 +4406,9 @@ void ApiWrap::sendMediaWithRandomId(
|
||||||
: MTPmessages_SendMedia::Flag(0))
|
: MTPmessages_SendMedia::Flag(0))
|
||||||
| (options.scheduled
|
| (options.scheduled
|
||||||
? MTPmessages_SendMedia::Flag::f_schedule_date
|
? MTPmessages_SendMedia::Flag::f_schedule_date
|
||||||
|
: MTPmessages_SendMedia::Flag(0))
|
||||||
|
| (options.sendAs
|
||||||
|
? MTPmessages_SendMedia::Flag::f_send_as
|
||||||
: MTPmessages_SendMedia::Flag(0));
|
: MTPmessages_SendMedia::Flag(0));
|
||||||
|
|
||||||
auto &histories = history->owner().histories();
|
auto &histories = history->owner().histories();
|
||||||
|
@ -4398,7 +4426,7 @@ void ApiWrap::sendMediaWithRandomId(
|
||||||
MTPReplyMarkup(),
|
MTPReplyMarkup(),
|
||||||
sentEntities,
|
sentEntities,
|
||||||
MTP_int(options.scheduled),
|
MTP_int(options.scheduled),
|
||||||
MTPInputPeer() // #TODO send_as
|
(options.sendAs ? options.sendAs->input : MTP_inputPeerEmpty())
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
applyUpdates(result);
|
applyUpdates(result);
|
||||||
finish();
|
finish();
|
||||||
|
@ -4481,6 +4509,7 @@ void ApiWrap::sendAlbumIfReady(not_null<SendingAlbum*> album) {
|
||||||
}
|
}
|
||||||
const auto history = sample->history();
|
const auto history = sample->history();
|
||||||
const auto replyTo = sample->replyToId();
|
const auto replyTo = sample->replyToId();
|
||||||
|
const auto sendAs = album->options.sendAs;
|
||||||
const auto flags = MTPmessages_SendMultiMedia::Flags(0)
|
const auto flags = MTPmessages_SendMultiMedia::Flags(0)
|
||||||
| (replyTo
|
| (replyTo
|
||||||
? MTPmessages_SendMultiMedia::Flag::f_reply_to_msg_id
|
? MTPmessages_SendMultiMedia::Flag::f_reply_to_msg_id
|
||||||
|
@ -4490,6 +4519,9 @@ void ApiWrap::sendAlbumIfReady(not_null<SendingAlbum*> album) {
|
||||||
: MTPmessages_SendMultiMedia::Flag(0))
|
: MTPmessages_SendMultiMedia::Flag(0))
|
||||||
| (album->options.scheduled
|
| (album->options.scheduled
|
||||||
? MTPmessages_SendMultiMedia::Flag::f_schedule_date
|
? MTPmessages_SendMultiMedia::Flag::f_schedule_date
|
||||||
|
: MTPmessages_SendMultiMedia::Flag(0))
|
||||||
|
| (sendAs
|
||||||
|
? MTPmessages_SendMultiMedia::Flag::f_send_as
|
||||||
: MTPmessages_SendMultiMedia::Flag(0));
|
: MTPmessages_SendMultiMedia::Flag(0));
|
||||||
auto &histories = history->owner().histories();
|
auto &histories = history->owner().histories();
|
||||||
const auto requestType = Data::Histories::RequestType::Send;
|
const auto requestType = Data::Histories::RequestType::Send;
|
||||||
|
@ -4501,7 +4533,7 @@ void ApiWrap::sendAlbumIfReady(not_null<SendingAlbum*> album) {
|
||||||
MTP_int(replyTo),
|
MTP_int(replyTo),
|
||||||
MTP_vector<MTPInputSingleMedia>(medias),
|
MTP_vector<MTPInputSingleMedia>(medias),
|
||||||
MTP_int(album->options.scheduled),
|
MTP_int(album->options.scheduled),
|
||||||
MTPInputPeer() // #TODO send_as
|
(sendAs ? sendAs->input : MTP_inputPeerEmpty())
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
_sendingAlbums.remove(groupId);
|
_sendingAlbums.remove(groupId);
|
||||||
applyUpdates(result);
|
applyUpdates(result);
|
||||||
|
|
|
@ -670,8 +670,7 @@ void EditCaptionBox::save() {
|
||||||
options.scheduled = item->isScheduled() ? item->date() : 0;
|
options.scheduled = item->isScheduled() ? item->date() : 0;
|
||||||
|
|
||||||
if (!_preparedList.files.empty()) {
|
if (!_preparedList.files.empty()) {
|
||||||
auto action = Api::SendAction(item->history());
|
auto action = Api::SendAction(item->history(), options);
|
||||||
action.options = options;
|
|
||||||
action.replaceMediaOf = item->fullId().msg;
|
action.replaceMediaOf = item->fullId().msg;
|
||||||
|
|
||||||
Storage::ApplyModifications(_preparedList);
|
Storage::ApplyModifications(_preparedList);
|
||||||
|
|
|
@ -51,7 +51,7 @@ void ShareBotGame(not_null<UserData*> bot, not_null<PeerData*> chat) {
|
||||||
MTPReplyMarkup(),
|
MTPReplyMarkup(),
|
||||||
MTPVector<MTPMessageEntity>(),
|
MTPVector<MTPMessageEntity>(),
|
||||||
MTP_int(0), // schedule_date
|
MTP_int(0), // schedule_date
|
||||||
MTPInputPeer() // #TODO send_as
|
MTPInputPeer() // send_as
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
api->applyUpdates(result, randomId);
|
api->applyUpdates(result, randomId);
|
||||||
finish();
|
finish();
|
||||||
|
|
|
@ -1144,9 +1144,8 @@ void ShareInviteLinkBox(not_null<PeerData*> peer, const QString &link) {
|
||||||
auto &api = peer->session().api();
|
auto &api = peer->session().api();
|
||||||
for (const auto peer : result) {
|
for (const auto peer : result) {
|
||||||
const auto history = owner->history(peer);
|
const auto history = owner->history(peer);
|
||||||
auto message = ApiWrap::MessageToSend(history);
|
auto message = Api::MessageToSend(Api::SendAction(history, options));
|
||||||
message.textWithTags = comment;
|
message.textWithTags = comment;
|
||||||
message.action.options = options;
|
|
||||||
message.action.clearDraft = false;
|
message.action.clearDraft = false;
|
||||||
api.sendMessage(std::move(message));
|
api.sendMessage(std::move(message));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1026,9 +1026,7 @@ void SendFilesBox::send(
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendFilesBox::sendSilent() {
|
void SendFilesBox::sendSilent() {
|
||||||
auto options = Api::SendOptions();
|
send({ .silent = true });
|
||||||
options.silent = true;
|
|
||||||
send(options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendFilesBox::sendScheduled() {
|
void SendFilesBox::sendScheduled() {
|
||||||
|
|
|
@ -496,9 +496,7 @@ void ShareBox::submit(Api::SendOptions options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShareBox::submitSilent() {
|
void ShareBox::submitSilent() {
|
||||||
auto options = Api::SendOptions();
|
submit({ .silent = true });
|
||||||
options.silent = true;
|
|
||||||
submit(options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShareBox::submitScheduled() {
|
void ShareBox::submitScheduled() {
|
||||||
|
|
|
@ -625,7 +625,7 @@ void StickerSetBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
if (index < 0 || index >= _pack.size() || isMasksSet()) {
|
if (index < 0 || index >= _pack.size() || isMasksSet()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
send(_pack[index], Api::SendOptions());
|
send(_pack[index], {});
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickerSetBox::Inner::send(
|
void StickerSetBox::Inner::send(
|
||||||
|
|
|
@ -175,9 +175,9 @@ object_ptr<ShareBox> ShareInviteLinkBox(
|
||||||
auto &api = peer->session().api();
|
auto &api = peer->session().api();
|
||||||
for (const auto peer : result) {
|
for (const auto peer : result) {
|
||||||
const auto history = owner->history(peer);
|
const auto history = owner->history(peer);
|
||||||
auto message = ApiWrap::MessageToSend(history);
|
auto message = Api::MessageToSend(
|
||||||
|
Api::SendAction(history, options));
|
||||||
message.textWithTags = comment;
|
message.textWithTags = comment;
|
||||||
message.action.options = options;
|
|
||||||
message.action.clearDraft = false;
|
message.action.clearDraft = false;
|
||||||
api.sendMessage(std::move(message));
|
api.sendMessage(std::move(message));
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
bool chooseAtIndex(
|
bool chooseAtIndex(
|
||||||
FieldAutocomplete::ChooseMethod method,
|
FieldAutocomplete::ChooseMethod method,
|
||||||
int index,
|
int index,
|
||||||
Api::SendOptions options = Api::SendOptions()) const;
|
Api::SendOptions options = {}) const;
|
||||||
|
|
||||||
void setRecentInlineBotsInRows(int32 bots);
|
void setRecentInlineBotsInRows(int32 bots);
|
||||||
void setSendMenuType(Fn<SendMenu::Type()> &&callback);
|
void setSendMenuType(Fn<SendMenu::Type()> &&callback);
|
||||||
|
|
|
@ -1683,7 +1683,8 @@ ClickHandlerPtr MediaDice::MakeHandler(
|
||||||
const ClickHandlerPtr &handler,
|
const ClickHandlerPtr &handler,
|
||||||
Qt::MouseButton button) {
|
Qt::MouseButton button) {
|
||||||
if (button == Qt::LeftButton && !ShownToast.empty()) {
|
if (button == Qt::LeftButton && !ShownToast.empty()) {
|
||||||
auto message = Api::MessageToSend(history);
|
auto message = Api::MessageToSend(
|
||||||
|
Api::SendAction(history));
|
||||||
message.action.clearDraft = false;
|
message.action.clearDraft = false;
|
||||||
message.textWithTags.text = emoji;
|
message.textWithTags.text = emoji;
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ void ScheduledMessages::sendNowSimpleMessage(
|
||||||
MTP_message(
|
MTP_message(
|
||||||
MTP_flags(flags),
|
MTP_flags(flags),
|
||||||
update.vid(),
|
update.vid(),
|
||||||
peerToMTP(_session->userPeerId()),
|
peerToMTP(local->from()->id),
|
||||||
peerToMTP(history->peer->id),
|
peerToMTP(history->peer->id),
|
||||||
MTPMessageFwdHeader(),
|
MTPMessageFwdHeader(),
|
||||||
MTPlong(), // via_bot_id
|
MTPlong(), // via_bot_id
|
||||||
|
|
|
@ -293,9 +293,9 @@ void FastShareMessage(not_null<HistoryItem*> item) {
|
||||||
for (const auto peer : result) {
|
for (const auto peer : result) {
|
||||||
const auto history = owner->history(peer);
|
const auto history = owner->history(peer);
|
||||||
if (!comment.text.isEmpty()) {
|
if (!comment.text.isEmpty()) {
|
||||||
auto message = ApiWrap::MessageToSend(history);
|
auto message = Api::MessageToSend(
|
||||||
|
Api::SendAction(history, options));
|
||||||
message.textWithTags = comment;
|
message.textWithTags = comment;
|
||||||
message.action.options = options;
|
|
||||||
message.action.clearDraft = false;
|
message.action.clearDraft = false;
|
||||||
api.sendMessage(std::move(message));
|
api.sendMessage(std::move(message));
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ void FastShareMessage(not_null<HistoryItem*> item) {
|
||||||
MTP_vector<MTPlong>(generateRandom()),
|
MTP_vector<MTPlong>(generateRandom()),
|
||||||
peer->input,
|
peer->input,
|
||||||
MTP_int(options.scheduled),
|
MTP_int(options.scheduled),
|
||||||
MTPInputPeer() // #TODO send_as
|
MTP_inputPeerEmpty() // send_as
|
||||||
)).done([=](const MTPUpdates &updates, mtpRequestId requestId) {
|
)).done([=](const MTPUpdates &updates, mtpRequestId requestId) {
|
||||||
history->session().api().applyUpdates(updates);
|
history->session().api().applyUpdates(updates);
|
||||||
data->requests.remove(requestId);
|
data->requests.remove(requestId);
|
||||||
|
|
|
@ -890,9 +890,7 @@ void HistoryWidget::initVoiceRecordBar() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto action = Api::SendAction(_history);
|
auto action = prepareSendAction(data.options);
|
||||||
action.replyTo = replyToId();
|
|
||||||
action.options = data.options;
|
|
||||||
session().api().sendVoiceMessage(
|
session().api().sendVoiceMessage(
|
||||||
data.bytes,
|
data.bytes,
|
||||||
data.waveform,
|
data.waveform,
|
||||||
|
@ -1025,7 +1023,9 @@ void HistoryWidget::supportShareContact(Support::Contact contact) {
|
||||||
if (!history) {
|
if (!history) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto options = Api::SendOptions();
|
auto options = Api::SendOptions{
|
||||||
|
.sendAs = prepareSendAction({}).options.sendAs,
|
||||||
|
};
|
||||||
auto action = Api::SendAction(history);
|
auto action = Api::SendAction(history);
|
||||||
send(options);
|
send(options);
|
||||||
options.handleSupportSwitch = Support::HandleSwitch(modifiers);
|
options.handleSupportSwitch = Support::HandleSwitch(modifiers);
|
||||||
|
@ -1298,7 +1298,7 @@ void HistoryWidget::insertHashtagOrBotCommand(
|
||||||
// Send bot command at once, if it was not inserted by pressing Tab.
|
// Send bot command at once, if it was not inserted by pressing Tab.
|
||||||
if (str.at(0) == '/' && method != FieldAutocomplete::ChooseMethod::ByTab) {
|
if (str.at(0) == '/' && method != FieldAutocomplete::ChooseMethod::ByTab) {
|
||||||
sendBotCommand({ _peer, str, FullMsgId(), replyToId() });
|
sendBotCommand({ _peer, str, FullMsgId(), replyToId() });
|
||||||
session().api().finishForwarding(Api::SendAction(_history));
|
session().api().finishForwarding(prepareSendAction({}));
|
||||||
setFieldText(_field->getTextWithTagsPart(_field->textCursor().position()));
|
setFieldText(_field->getTextWithTagsPart(_field->textCursor().position()));
|
||||||
} else {
|
} else {
|
||||||
_field->insertTag(str);
|
_field->insertTag(str);
|
||||||
|
@ -3405,10 +3405,12 @@ void HistoryWidget::saveEditMsg() {
|
||||||
})();
|
})();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto options = Api::SendOptions();
|
||||||
|
options.removeWebPageId = (webPageId == CancelledWebPageId);
|
||||||
_saveEditMsgRequestId = Api::EditTextMessage(
|
_saveEditMsgRequestId = Api::EditTextMessage(
|
||||||
item,
|
item,
|
||||||
sending,
|
sending,
|
||||||
{ .removeWebPageId = (webPageId == CancelledWebPageId) },
|
options,
|
||||||
done,
|
done,
|
||||||
fail);
|
fail);
|
||||||
}
|
}
|
||||||
|
@ -3448,6 +3450,17 @@ void HistoryWidget::hideSelectorControlsAnimated() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Api::SendAction HistoryWidget::prepareSendAction(
|
||||||
|
Api::SendOptions options) const {
|
||||||
|
auto result = Api::SendAction(_history, options);
|
||||||
|
result.replyTo = replyToId();
|
||||||
|
result.options.sendAs = _sendAs
|
||||||
|
? _history->session().sendAsPeers().resolveChosen(
|
||||||
|
_history->peer).get()
|
||||||
|
: nullptr;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryWidget::send(Api::SendOptions options) {
|
void HistoryWidget::send(Api::SendOptions options) {
|
||||||
if (!_history) {
|
if (!_history) {
|
||||||
return;
|
return;
|
||||||
|
@ -3469,10 +3482,8 @@ void HistoryWidget::send(Api::SendOptions options) {
|
||||||
? _previewData->id
|
? _previewData->id
|
||||||
: WebPageId(0));
|
: WebPageId(0));
|
||||||
|
|
||||||
auto message = ApiWrap::MessageToSend(_history);
|
auto message = ApiWrap::MessageToSend(prepareSendAction(options));
|
||||||
message.textWithTags = _field->getTextWithAppliedMarkdown();
|
message.textWithTags = _field->getTextWithAppliedMarkdown();
|
||||||
message.action.options = options;
|
|
||||||
message.action.replyTo = replyToId();
|
|
||||||
message.webPageId = webPageId;
|
message.webPageId = webPageId;
|
||||||
|
|
||||||
if (_canSendMessages) {
|
if (_canSendMessages) {
|
||||||
|
@ -3512,15 +3523,11 @@ void HistoryWidget::send(Api::SendOptions options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::sendWithModifiers(Qt::KeyboardModifiers modifiers) {
|
void HistoryWidget::sendWithModifiers(Qt::KeyboardModifiers modifiers) {
|
||||||
auto options = Api::SendOptions();
|
send({ .handleSupportSwitch = Support::HandleSwitch(modifiers) });
|
||||||
options.handleSupportSwitch = Support::HandleSwitch(modifiers);
|
|
||||||
send(options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::sendSilent() {
|
void HistoryWidget::sendSilent() {
|
||||||
auto options = Api::SendOptions();
|
send({ .silent = true });
|
||||||
options.silent = true;
|
|
||||||
send(options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::sendScheduled() {
|
void HistoryWidget::sendScheduled() {
|
||||||
|
@ -3894,7 +3901,7 @@ void HistoryWidget::sendBotCommand(const Bot::SendCommandRequest &request) {
|
||||||
? request.command
|
? request.command
|
||||||
: Bot::WrapCommandInChat(_peer, request.command, request.context);
|
: Bot::WrapCommandInChat(_peer, request.command, request.context);
|
||||||
|
|
||||||
auto message = ApiWrap::MessageToSend(_history);
|
auto message = Api::MessageToSend(prepareSendAction({}));
|
||||||
message.textWithTags = { toSend, TextWithTags::Tags() };
|
message.textWithTags = { toSend, TextWithTags::Tags() };
|
||||||
message.action.replyTo = request.replyTo
|
message.action.replyTo = request.replyTo
|
||||||
? ((!_peer->isUser()/* && (botStatus == 0 || botStatus == 2)*/)
|
? ((!_peer->isUser()/* && (botStatus == 0 || botStatus == 2)*/)
|
||||||
|
@ -4675,15 +4682,12 @@ void HistoryWidget::sendingFilesConfirmed(
|
||||||
const auto type = way.sendImagesAsPhotos()
|
const auto type = way.sendImagesAsPhotos()
|
||||||
? SendMediaType::Photo
|
? SendMediaType::Photo
|
||||||
: SendMediaType::File;
|
: SendMediaType::File;
|
||||||
auto action = Api::SendAction(_history);
|
auto action = prepareSendAction(options);
|
||||||
action.replyTo = replyToId();
|
|
||||||
action.options = options;
|
|
||||||
action.clearDraft = false;
|
action.clearDraft = false;
|
||||||
if ((groups.size() != 1 || !groups.front().sentWithCaption())
|
if ((groups.size() != 1 || !groups.front().sentWithCaption())
|
||||||
&& !caption.text.isEmpty()) {
|
&& !caption.text.isEmpty()) {
|
||||||
auto message = Api::MessageToSend(_history);
|
auto message = Api::MessageToSend(action);
|
||||||
message.textWithTags = base::take(caption);
|
message.textWithTags = base::take(caption);
|
||||||
message.action = action;
|
|
||||||
session().api().sendMessage(std::move(message));
|
session().api().sendMessage(std::move(message));
|
||||||
}
|
}
|
||||||
for (auto &group : groups) {
|
for (auto &group : groups) {
|
||||||
|
@ -4773,9 +4777,7 @@ void HistoryWidget::uploadFile(
|
||||||
SendMediaType type) {
|
SendMediaType type) {
|
||||||
if (!canWriteMessage()) return;
|
if (!canWriteMessage()) return;
|
||||||
|
|
||||||
auto action = Api::SendAction(_history);
|
session().api().sendFile(fileContent, type, prepareSendAction({}));
|
||||||
action.replyTo = replyToId();
|
|
||||||
session().api().sendFile(fileContent, type, action);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::handleHistoryChange(not_null<const History*> history) {
|
void HistoryWidget::handleHistoryChange(not_null<const History*> history) {
|
||||||
|
@ -5791,9 +5793,7 @@ void HistoryWidget::sendInlineResult(InlineBots::ResultSelected result) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto action = Api::SendAction(_history);
|
auto action = prepareSendAction(result.options);
|
||||||
action.replyTo = replyToId();
|
|
||||||
action.options = std::move(result.options);
|
|
||||||
action.generateLocal = true;
|
action.generateLocal = true;
|
||||||
session().api().sendInlineResult(result.bot, result.result, action);
|
session().api().sendInlineResult(result.bot, result.result, action);
|
||||||
|
|
||||||
|
@ -6175,10 +6175,9 @@ bool HistoryWidget::sendExistingDocument(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto message = Api::MessageToSend(_history);
|
Api::SendExistingDocument(
|
||||||
message.action.options = std::move(options);
|
Api::MessageToSend(prepareSendAction(options)),
|
||||||
message.action.replyTo = replyToId();
|
document);
|
||||||
Api::SendExistingDocument(std::move(message), document);
|
|
||||||
|
|
||||||
if (_fieldAutocomplete->stickersShown()) {
|
if (_fieldAutocomplete->stickersShown()) {
|
||||||
clearFieldText();
|
clearFieldText();
|
||||||
|
@ -6211,10 +6210,9 @@ bool HistoryWidget::sendExistingPhoto(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto message = Api::MessageToSend(_history);
|
Api::SendExistingPhoto(
|
||||||
message.action.replyTo = replyToId();
|
Api::MessageToSend(prepareSendAction(options)),
|
||||||
message.action.options = std::move(options);
|
photo);
|
||||||
Api::SendExistingPhoto(std::move(message), photo);
|
|
||||||
|
|
||||||
hideSelectorControlsAnimated();
|
hideSelectorControlsAnimated();
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ enum class Type;
|
||||||
|
|
||||||
namespace Api {
|
namespace Api {
|
||||||
struct SendOptions;
|
struct SendOptions;
|
||||||
|
struct SendAction;
|
||||||
} // namespace Api
|
} // namespace Api
|
||||||
|
|
||||||
namespace InlineBots {
|
namespace InlineBots {
|
||||||
|
@ -372,6 +373,8 @@ private:
|
||||||
void requestMessageData(MsgId msgId);
|
void requestMessageData(MsgId msgId);
|
||||||
void messageDataReceived(ChannelData *channel, MsgId msgId);
|
void messageDataReceived(ChannelData *channel, MsgId msgId);
|
||||||
|
|
||||||
|
[[nodiscard]] Api::SendAction prepareSendAction(
|
||||||
|
Api::SendOptions options) const;
|
||||||
void send(Api::SendOptions options);
|
void send(Api::SendOptions options);
|
||||||
void sendWithModifiers(Qt::KeyboardModifiers modifiers);
|
void sendWithModifiers(Qt::KeyboardModifiers modifiers);
|
||||||
void sendSilent();
|
void sendSilent();
|
||||||
|
|
|
@ -570,12 +570,10 @@ MessageToEdit FieldHeader::queryToEdit() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
item->fullId(),
|
.fullId = item->fullId(),
|
||||||
{
|
.options = {
|
||||||
item->isScheduled() ? item->date() : 0,
|
.scheduled = item->isScheduled() ? item->date() : 0,
|
||||||
false,
|
.removeWebPageId = !hasPreview(),
|
||||||
false,
|
|
||||||
!hasPreview(),
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -2062,7 +2062,7 @@ bool Message::hasFromName() const {
|
||||||
case Context::Replies: {
|
case Context::Replies: {
|
||||||
const auto item = message();
|
const auto item = message();
|
||||||
const auto peer = item->history()->peer;
|
const auto peer = item->history()->peer;
|
||||||
if (hasOutLayout() && !item->from()->isMegagroup()) {
|
if (hasOutLayout() && !item->from()->isChannel()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (!peer->isUser()) {
|
} else if (!peer->isUser()) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -735,19 +735,15 @@ void RepliesWidget::sendingFilesConfirmed(
|
||||||
std::move(list),
|
std::move(list),
|
||||||
way,
|
way,
|
||||||
_history->peer->slowmodeApplied());
|
_history->peer->slowmodeApplied());
|
||||||
const auto replyTo = replyToId();
|
|
||||||
const auto type = way.sendImagesAsPhotos()
|
const auto type = way.sendImagesAsPhotos()
|
||||||
? SendMediaType::Photo
|
? SendMediaType::Photo
|
||||||
: SendMediaType::File;
|
: SendMediaType::File;
|
||||||
auto action = Api::SendAction(_history);
|
auto action = prepareSendAction(options);
|
||||||
action.replyTo = replyTo ? replyTo : _rootId;
|
|
||||||
action.options = options;
|
|
||||||
action.clearDraft = false;
|
action.clearDraft = false;
|
||||||
if ((groups.size() != 1 || !groups.front().sentWithCaption())
|
if ((groups.size() != 1 || !groups.front().sentWithCaption())
|
||||||
&& !caption.text.isEmpty()) {
|
&& !caption.text.isEmpty()) {
|
||||||
auto message = Api::MessageToSend(_history);
|
auto message = Api::MessageToSend(action);
|
||||||
message.textWithTags = base::take(caption);
|
message.textWithTags = base::take(caption);
|
||||||
message.action = action;
|
|
||||||
session().api().sendMessage(std::move(message));
|
session().api().sendMessage(std::move(message));
|
||||||
}
|
}
|
||||||
for (auto &group : groups) {
|
for (auto &group : groups) {
|
||||||
|
@ -761,7 +757,7 @@ void RepliesWidget::sendingFilesConfirmed(
|
||||||
album,
|
album,
|
||||||
action);
|
action);
|
||||||
}
|
}
|
||||||
if (_composeControls->replyingToMessage().msg == replyTo) {
|
if (_composeControls->replyingToMessage().msg == action.replyTo) {
|
||||||
_composeControls->cancelReplyMessage();
|
_composeControls->cancelReplyMessage();
|
||||||
refreshTopBarActiveChat();
|
refreshTopBarActiveChat();
|
||||||
}
|
}
|
||||||
|
@ -869,9 +865,7 @@ void RepliesWidget::uploadFile(
|
||||||
const QByteArray &fileContent,
|
const QByteArray &fileContent,
|
||||||
SendMediaType type) {
|
SendMediaType type) {
|
||||||
// #TODO replies schedule
|
// #TODO replies schedule
|
||||||
auto action = Api::SendAction(_history);
|
session().api().sendFile(fileContent, type, prepareSendAction({}));
|
||||||
action.replyTo = replyToId();
|
|
||||||
session().api().sendFile(fileContent, type, action);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RepliesWidget::showSendingFilesError(
|
bool RepliesWidget::showSendingFilesError(
|
||||||
|
@ -918,11 +912,18 @@ bool RepliesWidget::showSendingFilesError(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Api::SendAction RepliesWidget::prepareSendAction(
|
||||||
|
Api::SendOptions options) const {
|
||||||
|
auto result = Api::SendAction(_history, options);
|
||||||
|
result.replyTo = replyToId();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void RepliesWidget::send() {
|
void RepliesWidget::send() {
|
||||||
if (_composeControls->getTextWithAppliedMarkdown().text.isEmpty()) {
|
if (_composeControls->getTextWithAppliedMarkdown().text.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
send(Api::SendOptions());
|
send({});
|
||||||
// #TODO replies schedule
|
// #TODO replies schedule
|
||||||
//const auto callback = [=](Api::SendOptions options) { send(options); };
|
//const auto callback = [=](Api::SendOptions options) { send(options); };
|
||||||
//Ui::show(
|
//Ui::show(
|
||||||
|
@ -931,9 +932,7 @@ void RepliesWidget::send() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesWidget::sendVoice(ComposeControls::VoiceToSend &&data) {
|
void RepliesWidget::sendVoice(ComposeControls::VoiceToSend &&data) {
|
||||||
auto action = Api::SendAction(_history);
|
auto action = prepareSendAction(data.options);
|
||||||
action.replyTo = replyToId();
|
|
||||||
action.options = data.options;
|
|
||||||
session().api().sendVoiceMessage(
|
session().api().sendVoiceMessage(
|
||||||
data.bytes,
|
data.bytes,
|
||||||
data.waveform,
|
data.waveform,
|
||||||
|
@ -952,10 +951,8 @@ void RepliesWidget::send(Api::SendOptions options) {
|
||||||
|
|
||||||
const auto webPageId = _composeControls->webPageId();
|
const auto webPageId = _composeControls->webPageId();
|
||||||
|
|
||||||
auto message = ApiWrap::MessageToSend(_history);
|
auto message = ApiWrap::MessageToSend(prepareSendAction(options));
|
||||||
message.textWithTags = _composeControls->getTextWithAppliedMarkdown();
|
message.textWithTags = _composeControls->getTextWithAppliedMarkdown();
|
||||||
message.action.options = options;
|
|
||||||
message.action.replyTo = replyToId();
|
|
||||||
message.webPageId = webPageId;
|
message.webPageId = webPageId;
|
||||||
|
|
||||||
//const auto error = GetErrorTextForSending(
|
//const auto error = GetErrorTextForSending(
|
||||||
|
@ -1063,7 +1060,7 @@ void RepliesWidget::edit(
|
||||||
|
|
||||||
void RepliesWidget::sendExistingDocument(
|
void RepliesWidget::sendExistingDocument(
|
||||||
not_null<DocumentData*> document) {
|
not_null<DocumentData*> document) {
|
||||||
sendExistingDocument(document, Api::SendOptions());
|
sendExistingDocument(document, {});
|
||||||
// #TODO replies schedule
|
// #TODO replies schedule
|
||||||
//const auto callback = [=](Api::SendOptions options) {
|
//const auto callback = [=](Api::SendOptions options) {
|
||||||
// sendExistingDocument(document, options);
|
// sendExistingDocument(document, options);
|
||||||
|
@ -1088,10 +1085,9 @@ bool RepliesWidget::sendExistingDocument(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto message = Api::MessageToSend(_history);
|
Api::SendExistingDocument(
|
||||||
message.action.replyTo = replyToId();
|
Api::MessageToSend(prepareSendAction(options)),
|
||||||
message.action.options = options;
|
document);
|
||||||
Api::SendExistingDocument(std::move(message), document);
|
|
||||||
|
|
||||||
_composeControls->cancelReplyMessage();
|
_composeControls->cancelReplyMessage();
|
||||||
finishSending();
|
finishSending();
|
||||||
|
@ -1099,7 +1095,7 @@ bool RepliesWidget::sendExistingDocument(
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesWidget::sendExistingPhoto(not_null<PhotoData*> photo) {
|
void RepliesWidget::sendExistingPhoto(not_null<PhotoData*> photo) {
|
||||||
sendExistingPhoto(photo, Api::SendOptions());
|
sendExistingPhoto(photo, {});
|
||||||
// #TODO replies schedule
|
// #TODO replies schedule
|
||||||
//const auto callback = [=](Api::SendOptions options) {
|
//const auto callback = [=](Api::SendOptions options) {
|
||||||
// sendExistingPhoto(photo, options);
|
// sendExistingPhoto(photo, options);
|
||||||
|
@ -1124,10 +1120,9 @@ bool RepliesWidget::sendExistingPhoto(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto message = Api::MessageToSend(_history);
|
Api::SendExistingPhoto(
|
||||||
message.action.replyTo = replyToId();
|
Api::MessageToSend(prepareSendAction(options)),
|
||||||
message.action.options = options;
|
photo);
|
||||||
Api::SendExistingPhoto(std::move(message), photo);
|
|
||||||
|
|
||||||
_composeControls->cancelReplyMessage();
|
_composeControls->cancelReplyMessage();
|
||||||
finishSending();
|
finishSending();
|
||||||
|
@ -1142,7 +1137,7 @@ void RepliesWidget::sendInlineResult(
|
||||||
controller()->show(Box<Ui::InformBox>(errorText));
|
controller()->show(Box<Ui::InformBox>(errorText));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendInlineResult(result, bot, Api::SendOptions());
|
sendInlineResult(result, bot, {});
|
||||||
//const auto callback = [=](Api::SendOptions options) {
|
//const auto callback = [=](Api::SendOptions options) {
|
||||||
// sendInlineResult(result, bot, options);
|
// sendInlineResult(result, bot, options);
|
||||||
//};
|
//};
|
||||||
|
@ -1155,9 +1150,7 @@ void RepliesWidget::sendInlineResult(
|
||||||
not_null<InlineBots::Result*> result,
|
not_null<InlineBots::Result*> result,
|
||||||
not_null<UserData*> bot,
|
not_null<UserData*> bot,
|
||||||
Api::SendOptions options) {
|
Api::SendOptions options) {
|
||||||
auto action = Api::SendAction(_history);
|
auto action = prepareSendAction(options);
|
||||||
action.replyTo = replyToId();
|
|
||||||
action.options = options;
|
|
||||||
action.generateLocal = true;
|
action.generateLocal = true;
|
||||||
session().api().sendInlineResult(bot, result, action);
|
session().api().sendInlineResult(bot, result, action);
|
||||||
|
|
||||||
|
@ -1912,9 +1905,9 @@ void RepliesWidget::listSendBotCommand(
|
||||||
_history->peer,
|
_history->peer,
|
||||||
command,
|
command,
|
||||||
context);
|
context);
|
||||||
auto message = ApiWrap::MessageToSend(_history);
|
auto message = ApiWrap::MessageToSend(
|
||||||
|
prepareSendAction({}));
|
||||||
message.textWithTags = { text };
|
message.textWithTags = { text };
|
||||||
message.action.replyTo = replyToId();
|
|
||||||
session().api().sendMessage(std::move(message));
|
session().api().sendMessage(std::move(message));
|
||||||
finishSending();
|
finishSending();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ enum class Type;
|
||||||
|
|
||||||
namespace Api {
|
namespace Api {
|
||||||
struct SendOptions;
|
struct SendOptions;
|
||||||
|
struct SendAction;
|
||||||
} // namespace Api
|
} // namespace Api
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
|
@ -190,6 +191,8 @@ private:
|
||||||
void clearSelected();
|
void clearSelected();
|
||||||
void setPinnedVisibility(bool shown);
|
void setPinnedVisibility(bool shown);
|
||||||
|
|
||||||
|
[[nodiscard]] Api::SendAction prepareSendAction(
|
||||||
|
Api::SendOptions options) const;
|
||||||
void send();
|
void send();
|
||||||
void send(Api::SendOptions options);
|
void send(Api::SendOptions options);
|
||||||
void sendVoice(Controls::VoiceToSend &&data);
|
void sendVoice(Controls::VoiceToSend &&data);
|
||||||
|
|
|
@ -429,14 +429,12 @@ void ScheduledWidget::sendingFilesConfirmed(
|
||||||
const auto type = way.sendImagesAsPhotos()
|
const auto type = way.sendImagesAsPhotos()
|
||||||
? SendMediaType::Photo
|
? SendMediaType::Photo
|
||||||
: SendMediaType::File;
|
: SendMediaType::File;
|
||||||
auto action = Api::SendAction(_history);
|
auto action = prepareSendAction(options);
|
||||||
action.options = options;
|
|
||||||
action.clearDraft = false;
|
action.clearDraft = false;
|
||||||
if ((groups.size() != 1 || !groups.front().sentWithCaption())
|
if ((groups.size() != 1 || !groups.front().sentWithCaption())
|
||||||
&& !caption.text.isEmpty()) {
|
&& !caption.text.isEmpty()) {
|
||||||
auto message = Api::MessageToSend(_history);
|
auto message = Api::MessageToSend(action);
|
||||||
message.textWithTags = base::take(caption);
|
message.textWithTags = base::take(caption);
|
||||||
message.action = action;
|
|
||||||
session().api().sendMessage(std::move(message));
|
session().api().sendMessage(std::move(message));
|
||||||
}
|
}
|
||||||
for (auto &group : groups) {
|
for (auto &group : groups) {
|
||||||
|
@ -473,10 +471,10 @@ void ScheduledWidget::uploadFile(
|
||||||
const QByteArray &fileContent,
|
const QByteArray &fileContent,
|
||||||
SendMediaType type) {
|
SendMediaType type) {
|
||||||
const auto callback = [=](Api::SendOptions options) {
|
const auto callback = [=](Api::SendOptions options) {
|
||||||
auto action = Api::SendAction(_history);
|
session().api().sendFile(
|
||||||
//action.replyTo = replyToId();
|
fileContent,
|
||||||
action.options = options;
|
type,
|
||||||
session().api().sendFile(fileContent, type, action);
|
prepareSendAction(options));
|
||||||
};
|
};
|
||||||
controller()->show(
|
controller()->show(
|
||||||
PrepareScheduleBox(this, sendMenuType(), callback),
|
PrepareScheduleBox(this, sendMenuType(), callback),
|
||||||
|
@ -518,6 +516,12 @@ bool ScheduledWidget::showSendingFilesError(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Api::SendAction ScheduledWidget::prepareSendAction(
|
||||||
|
Api::SendOptions options) const {
|
||||||
|
auto result = Api::SendAction(_history, options);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void ScheduledWidget::send() {
|
void ScheduledWidget::send() {
|
||||||
if (_composeControls->getTextWithAppliedMarkdown().text.isEmpty()) {
|
if (_composeControls->getTextWithAppliedMarkdown().text.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -531,10 +535,8 @@ void ScheduledWidget::send() {
|
||||||
void ScheduledWidget::send(Api::SendOptions options) {
|
void ScheduledWidget::send(Api::SendOptions options) {
|
||||||
const auto webPageId = _composeControls->webPageId();
|
const auto webPageId = _composeControls->webPageId();
|
||||||
|
|
||||||
auto message = ApiWrap::MessageToSend(_history);
|
auto message = ApiWrap::MessageToSend(prepareSendAction(options));
|
||||||
message.textWithTags = _composeControls->getTextWithAppliedMarkdown();
|
message.textWithTags = _composeControls->getTextWithAppliedMarkdown();
|
||||||
message.action.options = options;
|
|
||||||
//message.action.replyTo = replyToId();
|
|
||||||
message.webPageId = webPageId;
|
message.webPageId = webPageId;
|
||||||
|
|
||||||
//const auto error = GetErrorTextForSending(
|
//const auto error = GetErrorTextForSending(
|
||||||
|
@ -578,9 +580,11 @@ void ScheduledWidget::sendVoice(
|
||||||
VoiceWaveform waveform,
|
VoiceWaveform waveform,
|
||||||
int duration,
|
int duration,
|
||||||
Api::SendOptions options) {
|
Api::SendOptions options) {
|
||||||
auto action = Api::SendAction(_history);
|
session().api().sendVoiceMessage(
|
||||||
action.options = options;
|
bytes,
|
||||||
session().api().sendVoiceMessage(bytes, waveform, duration, action);
|
waveform,
|
||||||
|
duration,
|
||||||
|
prepareSendAction(options));
|
||||||
_composeControls->clearListenState();
|
_composeControls->clearListenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -683,10 +687,9 @@ bool ScheduledWidget::sendExistingDocument(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto message = Api::MessageToSend(_history);
|
Api::SendExistingDocument(
|
||||||
//message.action.replyTo = replyToId();
|
Api::MessageToSend(prepareSendAction(options)),
|
||||||
message.action.options = options;
|
document);
|
||||||
Api::SendExistingDocument(std::move(message), document);
|
|
||||||
|
|
||||||
_composeControls->hidePanelsAnimated();
|
_composeControls->hidePanelsAnimated();
|
||||||
_composeControls->focus();
|
_composeControls->focus();
|
||||||
|
@ -715,10 +718,9 @@ bool ScheduledWidget::sendExistingPhoto(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto message = Api::MessageToSend(_history);
|
Api::SendExistingPhoto(
|
||||||
//message.action.replyTo = replyToId();
|
Api::MessageToSend(prepareSendAction(options)),
|
||||||
message.action.options = options;
|
photo);
|
||||||
Api::SendExistingPhoto(std::move(message), photo);
|
|
||||||
|
|
||||||
_composeControls->hidePanelsAnimated();
|
_composeControls->hidePanelsAnimated();
|
||||||
_composeControls->focus();
|
_composeControls->focus();
|
||||||
|
@ -745,9 +747,7 @@ void ScheduledWidget::sendInlineResult(
|
||||||
not_null<InlineBots::Result*> result,
|
not_null<InlineBots::Result*> result,
|
||||||
not_null<UserData*> bot,
|
not_null<UserData*> bot,
|
||||||
Api::SendOptions options) {
|
Api::SendOptions options) {
|
||||||
auto action = Api::SendAction(_history);
|
auto action = prepareSendAction(options);
|
||||||
//action.replyTo = replyToId();
|
|
||||||
action.options = options;
|
|
||||||
action.generateLocal = true;
|
action.generateLocal = true;
|
||||||
session().api().sendInlineResult(bot, result, action);
|
session().api().sendInlineResult(bot, result, action);
|
||||||
|
|
||||||
|
@ -1213,9 +1213,8 @@ void ScheduledWidget::listSendBotCommand(
|
||||||
_history->peer,
|
_history->peer,
|
||||||
command,
|
command,
|
||||||
context);
|
context);
|
||||||
auto message = ApiWrap::MessageToSend(_history);
|
auto message = ApiWrap::MessageToSend(prepareSendAction(options));
|
||||||
message.textWithTags = { text };
|
message.textWithTags = { text };
|
||||||
message.action.options = options;
|
|
||||||
session().api().sendMessage(std::move(message));
|
session().api().sendMessage(std::move(message));
|
||||||
};
|
};
|
||||||
controller()->show(
|
controller()->show(
|
||||||
|
|
|
@ -22,6 +22,7 @@ enum class Type;
|
||||||
|
|
||||||
namespace Api {
|
namespace Api {
|
||||||
struct SendOptions;
|
struct SendOptions;
|
||||||
|
struct SendAction;
|
||||||
} // namespace Api
|
} // namespace Api
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -155,6 +156,8 @@ private:
|
||||||
void confirmDeleteSelected();
|
void confirmDeleteSelected();
|
||||||
void clearSelected();
|
void clearSelected();
|
||||||
|
|
||||||
|
[[nodiscard]] Api::SendAction prepareSendAction(
|
||||||
|
Api::SendOptions options) const;
|
||||||
void send();
|
void send();
|
||||||
void send(Api::SendOptions options);
|
void send(Api::SendOptions options);
|
||||||
void sendVoice(QByteArray bytes, VoiceWaveform waveform, int duration);
|
void sendVoice(QByteArray bytes, VoiceWaveform waveform, int duration);
|
||||||
|
|
|
@ -1076,7 +1076,7 @@ SendMenu::Type MainWidget::sendMenuType() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::sendExistingDocument(not_null<DocumentData*> document) {
|
bool MainWidget::sendExistingDocument(not_null<DocumentData*> document) {
|
||||||
return sendExistingDocument(document, Api::SendOptions());
|
return sendExistingDocument(document, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::sendExistingDocument(
|
bool MainWidget::sendExistingDocument(
|
||||||
|
|
|
@ -1581,7 +1581,7 @@ void FormController::uploadEncryptedFile(
|
||||||
auto prepared = std::make_shared<FileLoadResult>(
|
auto prepared = std::make_shared<FileLoadResult>(
|
||||||
TaskId(),
|
TaskId(),
|
||||||
file.uploadData->fileId,
|
file.uploadData->fileId,
|
||||||
FileLoadTo(PeerId(0), Api::SendOptions(), MsgId(0), MsgId(0)),
|
FileLoadTo(PeerId(), Api::SendOptions(), MsgId(), MsgId()),
|
||||||
TextWithTags(),
|
TextWithTags(),
|
||||||
std::shared_ptr<SendingAlbum>(nullptr));
|
std::shared_ptr<SendingAlbum>(nullptr));
|
||||||
prepared->type = SendMediaType::Secure;
|
prepared->type = SendMediaType::Secure;
|
||||||
|
|
|
@ -466,7 +466,8 @@ void AppendEmojiPacks(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Api::SendExistingDocument(
|
Api::SendExistingDocument(
|
||||||
Api::MessageToSend(ActiveChat(_controller).history()),
|
Api::MessageToSend(
|
||||||
|
Api::SendAction(ActiveChat(_controller).history())),
|
||||||
document);
|
document);
|
||||||
return true;
|
return true;
|
||||||
} else if (emoji) {
|
} else if (emoji) {
|
||||||
|
|
|
@ -193,7 +193,7 @@ struct SendingAlbum {
|
||||||
|
|
||||||
struct FileLoadTo {
|
struct FileLoadTo {
|
||||||
FileLoadTo(
|
FileLoadTo(
|
||||||
const PeerId &peer,
|
PeerId peer,
|
||||||
Api::SendOptions options,
|
Api::SendOptions options,
|
||||||
MsgId replyTo,
|
MsgId replyTo,
|
||||||
MsgId replaceMediaOf)
|
MsgId replaceMediaOf)
|
||||||
|
|
|
@ -931,11 +931,11 @@ SendAsButton {
|
||||||
sendAsButton: SendAsButton {
|
sendAsButton: SendAsButton {
|
||||||
width: 44px;
|
width: 44px;
|
||||||
height: 46px;
|
height: 46px;
|
||||||
size: 32px;
|
size: 28px;
|
||||||
activeBg: activeButtonBg;
|
activeBg: activeButtonBg;
|
||||||
activeFg: activeButtonFg;
|
activeFg: activeButtonFg;
|
||||||
cross: CrossAnimation {
|
cross: CrossAnimation {
|
||||||
size: 32px;
|
size: 28px;
|
||||||
skip: 10px;
|
skip: 10px;
|
||||||
stroke: 2px;
|
stroke: 2px;
|
||||||
minScale: 0.3;
|
minScale: 0.3;
|
||||||
|
|
|
@ -137,7 +137,11 @@ void ChooseSendAsBox(
|
||||||
delegate->setContent(content);
|
delegate->setContent(content);
|
||||||
controller->setDelegate(delegate);
|
controller->setDelegate(delegate);
|
||||||
box->addButton(tr::lng_settings_save(), [=] {
|
box->addButton(tr::lng_settings_save(), [=] {
|
||||||
|
const auto weak = MakeWeak(box);
|
||||||
done(controller->selected());
|
done(controller->selected());
|
||||||
|
if (weak) {
|
||||||
|
box->closeBox();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||||
}
|
}
|
||||||
|
|
|
@ -706,7 +706,7 @@ void Manager::notificationReplied(
|
||||||
}
|
}
|
||||||
const auto history = session->data().history(id.full.peerId);
|
const auto history = session->data().history(id.full.peerId);
|
||||||
|
|
||||||
auto message = Api::MessageToSend(history);
|
auto message = Api::MessageToSend(Api::SendAction(history));
|
||||||
message.textWithTags = reply;
|
message.textWithTags = reply;
|
||||||
message.action.replyTo = (id.msgId > 0 && !history->peer->isUser())
|
message.action.replyTo = (id.msgId > 0 && !history->peer->isUser())
|
||||||
? id.msgId
|
? id.msgId
|
||||||
|
|
|
@ -821,9 +821,10 @@ void PeerMenuCreatePoll(
|
||||||
if (std::exchange(*lock, true)) {
|
if (std::exchange(*lock, true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto action = Api::SendAction(peer->owner().history(peer));
|
auto action = Api::SendAction(
|
||||||
|
peer->owner().history(peer),
|
||||||
|
result.options);
|
||||||
action.clearDraft = false;
|
action.clearDraft = false;
|
||||||
action.options = result.options;
|
|
||||||
action.replyTo = replyToId;
|
action.replyTo = replyToId;
|
||||||
if (const auto localDraft = action.history->localDraft()) {
|
if (const auto localDraft = action.history->localDraft()) {
|
||||||
action.clearDraft = localDraft->textWithTags.text.isEmpty();
|
action.clearDraft = localDraft->textWithTags.text.isEmpty();
|
||||||
|
|
Loading…
Add table
Reference in a new issue