Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Nov 15, 2023
1 parent b776aa8 commit c0bdc02
Show file tree
Hide file tree
Showing 19 changed files with 94 additions and 39 deletions.
22 changes: 11 additions & 11 deletions Telegram/SourceFiles/api/api_peer_photo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,20 +734,20 @@ void PeerPhoto::requestEmojiList(EmojiListType type) {
const auto send = [&](auto &&request) {
return _api.request(
std::move(request)
).done([=](const MTPEmojiList &result) {
).done([=](const TLstickers &result) {
auto &list = emojiList(type);
list.requestId = 0;

const auto &stickers = data.vstickers().v;
list.list = EmojiList();
list.list.reserve(stickers.size());
for (const auto &sticker : stickers) {
const auto document = _session->data().processDocument(
sticker);
if (document->sticker()) {
list.list.push_back(document->id);
}
}
const auto &stickers = result.data().vstickers().v;
list.list = ranges::views::all(
result.data().vstickers().v
) | ranges::view::transform([&](const TLsticker &sticker) {
return _session->data().processDocument(sticker);
}) | ranges::views::filter([](not_null<DocumentData*> sticker) {
return sticker->sticker() != nullptr;
}) | ranges::views::transform(
&DocumentData::id
) | ranges::to_vector;
}).fail([=] {
emojiList(type).requestId = 0;
}).send();
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/api/api_polls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void Polls::create(

_api.request(Tdb::TLsendMessage(
peerToTdbChat(peer->id),
Tdb::tl_int53(action.replyTo.topicRootId.bare),
MessageThreadId(peer, action),
MessageReplyTo(action),
MessageSendOptions(peer, action),
PollToTL(&data)
Expand Down
17 changes: 17 additions & 0 deletions Telegram/SourceFiles/api/api_premium.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace {

using namespace Tdb;

#if 0 // mtp
[[nodiscard]] GiftCode Parse(const MTPDpayments_checkedGiftCode &data) {
return {
.from = peerFromMTP(data.vfrom_id()),
Expand Down Expand Up @@ -59,6 +60,7 @@ using namespace Tdb;
}
return options;
}
#endif

} // namespace

Expand Down Expand Up @@ -398,6 +400,7 @@ void Premium::checkGiftCode(
_api.request(_giftCodeRequestId).cancel();
}
_giftCodeSlug = slug;
#if 0 // todo
_giftCodeRequestId = _api.request(MTPpayments_CheckGiftCode(
MTP_string(slug)
)).done([=](const MTPpayments_CheckedGiftCode &result) {
Expand All @@ -412,6 +415,7 @@ void Premium::checkGiftCode(

done(updateGiftCode(slug, {}));
}).send();
#endif
}

GiftCode Premium::updateGiftCode(
Expand All @@ -435,6 +439,7 @@ rpl::producer<GiftCode> Premium::giftCodeValue(const QString &slug) const {
}

void Premium::applyGiftCode(const QString &slug, Fn<void(QString)> done) {
#if 0 // todo
_api.request(MTPpayments_ApplyGiftCode(
MTP_string(slug)
)).done([=](const MTPUpdates &result) {
Expand All @@ -443,6 +448,7 @@ void Premium::applyGiftCode(const QString &slug, Fn<void(QString)> done) {
}).fail([=](const MTP::Error &error) {
done(error.type());
}).send();
#endif
}

void Premium::resolveGiveawayInfo(
Expand All @@ -461,6 +467,7 @@ void Premium::resolveGiveawayInfo(
}
_giveawayInfoPeer = peer;
_giveawayInfoMessageId = messageId;
#if 0 // todo
_giveawayInfoRequestId = _api.request(MTPpayments_GetGiveawayInfo(
_giveawayInfoPeer->input,
MTP_int(_giveawayInfoMessageId.bare)
Expand Down Expand Up @@ -495,6 +502,7 @@ void Premium::resolveGiveawayInfo(
_giveawayInfoRequestId = 0;
_giveawayInfoDone({});
}).send();
#endif
}

const Data::SubscriptionOptions &Premium::subscriptionOptions() const {
Expand All @@ -503,7 +511,10 @@ const Data::SubscriptionOptions &Premium::subscriptionOptions() const {

PremiumGiftCodeOptions::PremiumGiftCodeOptions(not_null<PeerData*> peer)
: _peer(peer)
#if 0 // mtp
, _api(&peer->session().api().instance()) {
#endif
, _api(&peer->session().sender()) {
}

rpl::producer<rpl::no_value, QString> PremiumGiftCodeOptions::request() {
Expand All @@ -514,6 +525,7 @@ rpl::producer<rpl::no_value, QString> PremiumGiftCodeOptions::request() {
return lifetime;
}

#if 0 // todo
using TLOption = MTPPremiumGiftCodeOption;
_api.request(MTPpayments_GetPremiumGiftCodeOptions(
MTP_flags(
Expand Down Expand Up @@ -552,6 +564,7 @@ rpl::producer<rpl::no_value, QString> PremiumGiftCodeOptions::request() {
}).fail([=](const MTP::Error &error) {
consumer.put_error_copy(error.type());
}).send();
#endif

return lifetime;
};
Expand All @@ -567,6 +580,7 @@ rpl::producer<rpl::no_value, QString> PremiumGiftCodeOptions::applyPrepaid(
return lifetime;
}

#if 0 // todo
_api.request(MTPpayments_LaunchPrepaidGiveaway(
_peer->input,
MTP_long(prepaidId),
Expand All @@ -577,6 +591,7 @@ rpl::producer<rpl::no_value, QString> PremiumGiftCodeOptions::applyPrepaid(
}).fail([=](const MTP::Error &error) {
consumer.put_error_copy(error.type());
}).send();
#endif

return lifetime;
};
Expand Down Expand Up @@ -612,6 +627,7 @@ Data::SubscriptionOptions PremiumGiftCodeOptions::options(int amount) {
if (it != end(_subscriptionOptions)) {
return it->second;
} else {
#if 0 // todo
auto tlOptions = QVector<MTPPremiumGiftCodeOption>();
for (auto i = 0; i < _optionsForOnePerson.months.size(); i++) {
tlOptions.push_back(MTP_premiumGiftCodeOption(
Expand All @@ -624,6 +640,7 @@ Data::SubscriptionOptions PremiumGiftCodeOptions::options(int amount) {
MTP_long(_optionsForOnePerson.totalCosts[i] * amount)));
}
_subscriptionOptions[amount] = GiftCodesFromTL(tlOptions);
#endif
return _subscriptionOptions[amount];
}
}
Expand Down
36 changes: 23 additions & 13 deletions Telegram/SourceFiles/api/api_sending.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,16 @@ void SendPreparedAlbumIfReady(
const auto session = &peer->session();
session->sender().request(TLsendMessageAlbum(
peerToTdbChat(peer->id),
tl_int53(action.replyTo.topicRootId.bare),
MessageThreadId(peer, action),
MessageReplyTo(action),
tl_messageSendOptions(
tl_bool(silentPost),
tl_bool(false), // from_background
tl_bool(false), // update_order_of_installed_stickers_sets
ScheduledToTL(action.options.scheduled),
tl_int32(0)), // sending_id
tl_vector(std::move(contents)),
tl_bool(false) // only_preview
tl_int32(0), // sending_id
tl_bool(false)), // only_preview
tl_vector(std::move(contents))
)).done([=](const TLmessages &result) {
// They should've been added by updates.
}).fail([=](const Error &error) {
Expand Down Expand Up @@ -587,7 +587,7 @@ bool SendDice(MessageToSend &message) {
const auto &action = message.action;
session->sender().request(TLsendMessage(
peerToTdbChat(peer->id),
tl_int53(action.replyTo.topicRootId.bare),
MessageThreadId(peer, action),
MessageReplyTo(action),
MessageSendOptions(peer, action),
tl_inputMessageDice(tl_string(emoji), tl_bool(action.clearDraft))
Expand Down Expand Up @@ -888,23 +888,33 @@ TLmessageSendOptions MessageSendOptions(
tl_bool(false), // from_background
tl_bool(false), // update_order_of_installed_stickers_sets
ScheduledToTL(action.options.scheduled),
tl_int32(sendingId));
tl_int32(sendingId),
tl_bool(false)); // only_preview
}

std::optional<TLmessageReplyTo> MessageReplyTo(
std::optional<TLinputMessageReplyTo> MessageReplyTo(
const SendAction &action) {
if (const auto &storyId = action.replyTo.storyId) {
return tl_messageReplyToStory(
return tl_inputMessageReplyToStory(
peerToTdbChat(storyId.peer),
tl_int32(storyId.story));
} else if (const auto to = action.replyTo.msgId) {
return tl_messageReplyToMessage(
peerToTdbChat(action.history->peer->id),
tl_int53(to.bare));
} else if (const auto to = action.replyTo.messageId) {
return tl_inputMessageReplyToMessage(
peerToTdbChat(to.peer),
tl_int53(to.msg.bare),
(action.replyTo.quote.empty()
? std::optional<TLformattedText>()
: Api::FormattedTextToTdb(action.replyTo.quote)));
}
return std::nullopt;
}

TLint53 MessageThreadId(
not_null<PeerData*> peer,
const SendAction &action) {
return tl_int53(action.replyTo.topicRootId.bare);
}

void SendPreparedMessage(
const SendAction &action,
TLinputMessageContent content,
Expand All @@ -924,7 +934,7 @@ void SendPreparedMessage(
const auto sendingId = ClientMsgIndex(localId);
session->sender().request(TLsendMessage(
peerToTdbChat(peer->id),
tl_int53(topicRootId.bare),
MessageThreadId(peer, action),
MessageReplyTo(action),
MessageSendOptions(peer, action, sendingId),
std::move(content)
Expand Down
12 changes: 10 additions & 2 deletions Telegram/SourceFiles/api/api_sending.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ class PhotoData;
class DocumentData;
struct FileLoadResult;

namespace tl {
class int64_type;
} // namespace tl

namespace Tdb {
class TLinputMessageContent;
class TLmessageSchedulingState;
class TLmessageSendOptions;
class TLmessageReplyTo;
class TLinputMessageReplyTo;
using TLint53 = tl::int64_type;
} // namespace Tdb

namespace InlineBots {
Expand Down Expand Up @@ -57,7 +62,10 @@ void SendConfirmedFile(
not_null<PeerData*> peer,
const SendAction &action,
int32 sendingId = 0);
[[nodiscard]] std::optional<Tdb::TLmessageReplyTo> MessageReplyTo(
[[nodiscard]] std::optional<Tdb::TLinputMessageReplyTo> MessageReplyTo(
const SendAction &action);
[[nodiscard]] Tdb::TLint53 MessageThreadId(
not_null<PeerData*> peer,
const SendAction &action);

void SendPreparedMessage(
Expand Down
8 changes: 4 additions & 4 deletions Telegram/SourceFiles/apiwrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4182,11 +4182,11 @@ void ApiWrap::forwardMessages(
tl_bool(false), // from_background
tl_bool(false), // update_order_of_installed_stickers_sets
Api::ScheduledToTL(action.options.scheduled),
tl_int32(0)), // sending_id
tl_int32(0), // sending_id
tl_bool(false)), // only_preview
tl_bool(draft.options != Data::ForwardOptions::PreserveInfo),
tl_bool(
draft.options == Data::ForwardOptions::NoNamesAndCaptions),
tl_bool(false) // only_preview
draft.options == Data::ForwardOptions::NoNamesAndCaptions)
)).done([=](const TLmessages &result) {
// They should've been added by updates.
}).fail([=](const Error &error) {
Expand Down Expand Up @@ -4854,7 +4854,7 @@ void ApiWrap::sendInlineResult(
const auto sendingId = ClientMsgIndex(localId);
sender().request(TLsendInlineQueryResultMessage(
peerToTdbChat(peer->id),
tl_int53(action.replyTo.topicRootId.bare),
MessageThreadId(peer, action),
MessageReplyTo(action),
MessageSendOptions(peer, action, sendingId),
tl_int64(data->getQueryId()),
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ void EditPeerColorBox(
state->emojiId.value()
), {});

#if 0 // todo
const auto appConfig = &peer->session().account().appConfig();
auto indices = rpl::single(
rpl::empty
Expand All @@ -816,6 +817,8 @@ void EditPeerColorBox(
return uint8(i);
}) | ranges::to_vector;
});
#endif
auto indices = rpl::single(std::vector<uint8>{ 0, 1, 2, 3, 4, 5, 6 });
const auto margin = st::settingsColorRadioMargin;
const auto skip = st::settingsColorRadioSkip;
box->addRow(
Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/boxes/reactions_settings_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ PeerId GenerateUser(not_null<History*> history, const QString &name) {
Tdb::TLstring(), // phone_number
Tdb::tl_userStatusEmpty(), // status
Tdb::null, // profile_photo
Tdb::tl_int32(Data::DecideColorIndex(peerId)),
Tdb::tl_int64(0), // background_custom_emoji_id
Tdb::null, // emoji_status
Tdb::tl_bool(false), // is_contact
Tdb::tl_bool(false), // is_mutual_contact
Expand Down
3 changes: 2 additions & 1 deletion Telegram/SourceFiles/boxes/share_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,8 @@ ShareBox::SubmitCallback ShareBox::DefaultForwardCallback(
tl_bool(true), // from_background.
tl_bool(false), // update_order_of_installed_stickers_sets
Api::ScheduledToTL(options.scheduled),
tl_int32(0));
tl_int32(0), // sending_id
tl_bool(false)); // only_preview

// If we have only one message to send
// Then there is a chance we should send a game score.
Expand Down
1 change: 0 additions & 1 deletion Telegram/SourceFiles/data/data_drafts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ void ApplyPeerCloudDraft(
auto cloudDraft = std::make_unique<Draft>(
textWithTags,
replyTo,
topicRootId,
MessageCursor(Ui::kQFixedMax, Ui::kQFixedMax, Ui::kQFixedMax),
std::move(webpage));
cloudDraft->date = date;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ Main::Session &MyChannelsListController::session() const {

void MyChannelsListController::prepare() {
delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled);
#if 0 // todo
const auto api = _apiLifetime.make_state<MTP::Sender>(
&session().api().instance());
api->request(
Expand Down Expand Up @@ -285,6 +286,7 @@ void MyChannelsListController::prepare() {
delegate()->peerListRefreshRows();
_selected.clear();
}).send();
#endif
}

void MyChannelsListController::setCheckError(Fn<bool(int)> callback) {
Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ void AttachWebView::request(const WebViewButton &button) {
tl_string(_startCommand.isEmpty() ? button.url : _startCommand),
Window::Theme::WebViewTheme(),
tl_string("tdesktop"),
tl_int53(action.replyTo.topicRootId.bare),
MessageThreadId(action.history->peer, action),
MessageReplyTo(action)
)).done([=](const TLwebAppInfo &result) {
_requestId = 0;
Expand Down Expand Up @@ -1394,7 +1394,7 @@ void AttachWebView::requestMenu(
tl_string(url),
Window::Theme::WebViewTheme(),
tl_string("tdesktop"),
tl_int53(action.replyTo.topicRootId.bare),
MessageThreadId(action.history->peer, action),
MessageReplyTo(action)
)).done([=](const TLwebAppInfo &result) {
_requestId = 0;
Expand Down
Loading

0 comments on commit c0bdc02

Please sign in to comment.