Skip to content

Commit

Permalink
Fixed the build for 1.8.36.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Oct 16, 2024
1 parent 39b7366 commit c153a24
Show file tree
Hide file tree
Showing 29 changed files with 378 additions and 26 deletions.
10 changes: 10 additions & 0 deletions Telegram/SourceFiles/api/api_premium.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,18 +999,28 @@ bool PremiumGiftCodeOptions::giveawayGiftsPurchaseAvailable() const {
}

SponsoredToggle::SponsoredToggle(not_null<Main::Session*> session)
#if 0 // mtp
: _api(&session->api().instance()) {
#endif
: _session(session)
, _api(&session->sender()) {
}

rpl::producer<bool> SponsoredToggle::toggled() {
return [=](auto consumer) {
auto lifetime = rpl::lifetime();

_api.request(TLgetUserFullInfo(
tl_int53(peerToUser(_session->userPeerId()).bare)
)).done([=](const TLDuserFullInfo &data) {
consumer.put_next_copy(data.vhas_sponsored_messages_enabled().v);
#if 0 // mtp
_api.request(MTPusers_GetFullUser(
MTP_inputUserSelf()
)).done([=](const MTPusers_UserFull &result) {
consumer.put_next_copy(
result.data().vfull_user().data().is_sponsored_enabled());
#endif
}).fail([=] { consumer.put_next(false); }).send();

return lifetime;
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/api/api_premium.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ class SponsoredToggle final {
[[nodiscard]] rpl::producer<rpl::no_value, QString> setToggled(bool);

private:
const not_null<Main::Session*> _session;
MTP::Sender _api;

};
Expand Down
72 changes: 51 additions & 21 deletions Telegram/SourceFiles/api/api_updates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ For license and copyright information please follow this link:
#include "boxes/peers/add_participants_box.h"
#include "window/notifications_manager.h"
#include "data/components/factchecks.h"
#include "mainwidget.h"

namespace Api {
namespace {
Expand Down Expand Up @@ -2881,6 +2882,10 @@ void Updates::applyUpdate(const TLupdate &update) {
owner.applyLastMessage(data);
}, [&](const TLDupdateChatPosition &data) {
owner.applyDialogPosition(data);
}, [&](const TLDupdateChatAddedToList &data) {
// ?? can be in chat list and without position in that list
}, [&](const TLDupdateChatRemovedFromList &data) {
// ?? can be not in chat list and with a position in that list
}, [&](const TLDupdateChatMessageSender &data) {
const auto peerId = peerFromTdbChat(data.vchat_id());
if (const auto peer = owner.peerLoaded(peerId)) {
Expand Down Expand Up @@ -2915,6 +2920,13 @@ void Updates::applyUpdate(const TLupdate &update) {
if (const auto history = owner.historyLoaded(peerId)) {
history->setUnreadMark(data.vis_marked_as_unread().v);
}
}, [&](const TLDupdateChatViewAsTopics &data) {
const auto peerId = peerFromTdbChat(data.vchat_id());
if (const auto peer = owner.peerLoaded(peerId)) {
if (const auto channel = peer->asChannel()) {
channel->setViewAsMessagesFlag(!data.vview_as_topics().v);
}
}
}, [&](const TLDupdateChatBlockList &data) {
const auto peerId = peerFromTdbChat(data.vchat_id());
if (const auto peer = session().data().peerLoaded(peerId)) {
Expand Down Expand Up @@ -2986,6 +2998,8 @@ void Updates::applyUpdate(const TLupdate &update) {
}
}, [&](const TLDupdateActiveEmojiReactions &data) {
owner.reactions().refreshActive(data);
}, [&](const TLDupdateAvailableMessageEffects &data) {
owner.reactions().refreshEffects(data);
}, [&](const TLDupdateDefaultReactionType &data) {
owner.reactions().refreshFavorite(data);
}, [&](const TLDupdateChatNotificationSettings &data) {
Expand All @@ -3005,6 +3019,7 @@ void Updates::applyUpdate(const TLupdate &update) {
return Data::DefaultNotify::Broadcast;
});
owner.notifySettings().apply(type, data.vnotification_settings());
}, [&](const TLDupdateReactionNotificationSettings &data) {
}, [&](const TLDupdateChatMessageAutoDeleteTime &data) {
const auto peerId = peerFromTdbChat(data.vchat_id());
if (const auto peer = owner.peerLoaded(peerId)) {
Expand All @@ -3015,6 +3030,11 @@ void Updates::applyUpdate(const TLupdate &update) {
if (const auto peer = owner.peerLoaded(peerId)) {
peer->setActionBar(data.vaction_bar());
}
}, [&](const TLDupdateChatBusinessBotManageBar &data) {
const auto peerId = peerFromTdbChat(data.vchat_id());
if (const auto peer = owner.peerLoaded(peerId)) {
peer->updateBusinessBot(data.vbusiness_bot_manage_bar());
}
}, [&](const TLDupdateChatBackground &data) {
const auto peerId = peerFromTdbChat(data.vchat_id());
if (const auto peer = owner.peerLoaded(peerId)) {
Expand Down Expand Up @@ -3055,6 +3075,11 @@ void Updates::applyUpdate(const TLupdate &update) {
history->applyPosition(position.data());
}
}
}, [&](const TLDupdateChatEmojiStatus &data) {
const auto peerId = peerFromTdbChat(data.vchat_id());
if (const auto peer = owner.peerLoaded(peerId)) {
peer->setEmojiStatus(data.vemoji_status());
}
}, [&](const TLDupdateChatFolders &data) {
owner.chatsFilters().apply(data);
}, [&](const TLDupdateChatOnlineMemberCount &data) {
Expand Down Expand Up @@ -3168,11 +3193,12 @@ void Updates::applyUpdate(const TLupdate &update) {
session().data().stickers().apply(data);
}, [&](const TLDupdateSavedNotificationSounds &data) {
session().api().ringtones().applyUpdate();
}, [&](const TLDupdateSelectedBackground &data) {
}, [&](const TLDupdateDefaultBackground &data) {
}, [&](const TLDupdateChatThemes &data) {
session().data().cloudThemes().applyUpdate(data);
}, [&](const TLDupdateAccentColors &data) {
session().applyAccentColors(data);
}, [&](const TLDupdateProfileAccentColors &data) {
}, [&](const TLDupdateLanguagePackStrings &data) {
Lang::CurrentCloudManager().apply(data);
}, [&](const TLDupdateTermsOfService &data) {
Expand Down Expand Up @@ -3238,26 +3264,6 @@ void Updates::applyUpdate(const TLupdate &update) {
}, [&](const TLDupdateFileAddedToDownloads &data) {
}, [&](const TLDupdateFileDownload &data) {
}, [&](const TLDupdateFileRemovedFromDownloads &data) {
}, [&](const TLDupdateAddChatMembersPrivacyForbidden &data) {
const auto peerId = peerFromTdbChat(data.vchat_id());
if (const auto peer = owner.peerLoaded(peerId)) {
auto users = std::vector<not_null<UserData*>>();
for (const auto &id : data.vuser_ids().v) {
if (const auto user = owner.userLoaded(UserId(id.v))) {
users.push_back(user);
}
}
if (const auto window = Core::App().windowFor(peer)) {
if (const auto controller = window->sessionController()) {
if (&controller->session() == &peer->session()) {
ChatInviteForbidden(
window->uiShow(),
peer,
std::move(users));
}
}
}
}
}, [&](const TLDupdateAutosaveSettings &data) {
}, [&](const TLDupdateForumTopicInfo &data) {
const auto peerId = peerFromTdbChat(data.vchat_id());
Expand All @@ -3267,6 +3273,21 @@ void Updates::applyUpdate(const TLupdate &update) {
topic->applyInfo(data.vinfo());
}
}
}, [&](const TLDupdateOwnedStarCount &data) {
session().setCredits(data.vstar_count().v);
}, [&](const TLDupdateSpeechRecognitionTrial &data) {
session().api().transcribes().apply(data);
}, [&](const TLDupdateSpeedLimitNotification &data) {
if (const auto window = Core::App().activeWindow()) {
if (const auto controller = window->sessionController()) {
if (&controller->session() == &session()) {
controller->content()->showNonPremiumLimitToast(
!data.vis_upload().v);
}
}
}
}, [&](const TLDupdateContactCloseBirthdays &data) {

}, [&](const TLDupdateStory &data) {
owner.stories().apply(data);
}, [&](const TLDupdateStoryDeleted &data) {
Expand All @@ -3278,6 +3299,13 @@ void Updates::applyUpdate(const TLupdate &update) {
}, [&](const TLDupdateStoryStealthMode &data) {
owner.stories().apply(data);

}, [&](const TLDupdateSavedMessagesTags &data) {
owner.reactions().refreshMyTags(data);
}, [&](const TLDupdateSavedMessagesTopic &data) {
owner.savedMessages().apply(data);
}, [&](const TLDupdateSavedMessagesTopicCount &data) {
owner.savedMessages().apply(data);

}, [&](const TLDupdateQuickReplyShortcut &data) {
owner.shortcutMessages().apply(data);
}, [&](const TLDupdateQuickReplyShortcutDeleted &data) {
Expand All @@ -3290,6 +3318,8 @@ void Updates::applyUpdate(const TLupdate &update) {
// Updates below are handled in a different place.
}, [&](const TLDupdateConnectionState &data) {
}, [&](const TLDupdateServiceNotification &data) {
}, [&](const TLDupdateChatRevenueAmount &data) {
}, [&](const TLDupdateStarRevenueStatus &data) {

// Updates below are not relevant.
}, [&](const TLDupdateStorySendSucceeded &data) {
Expand Down
23 changes: 23 additions & 0 deletions Telegram/SourceFiles/apiwrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3309,10 +3309,16 @@ void ApiWrap::setGroupEmojiSet(
Expects(megagroup->mgInfo != nullptr);

megagroup->mgInfo->emojiSet = set;
sender().request(TLsetSupergroupCustomEmojiStickerSet(
tl_int53(peerToChannel(megagroup->id).bare),
tl_int64(set.id)
)).send();
#if 0 // mtp
request(MTPchannels_SetEmojiStickers(
megagroup->inputChannel,
Data::InputStickerSet(set)
)).send();
#endif
_session->changes().peerUpdated(
megagroup,
Data::PeerUpdate::Flag::EmojiSet);
Expand Down Expand Up @@ -3995,11 +4001,17 @@ void ApiWrap::requestHistory(
return;
}

auto prepared = Api::PrepareHistoryRequest(peer, messageId, slice);
#if 0 // mtp
const auto prepared = Api::PrepareHistoryRequest(peer, messageId, slice);
auto &histories = history->owner().histories();
const auto requestType = Data::Histories::RequestType::History;
histories.sendRequest(history, requestType, [=](Fn<void()> finish) {
return request(
#endif
{
const auto finish = [] {};
sender().request(
std::move(prepared)
).done([=](const Api::HistoryRequestResult &result) {
_historyRequests.remove(key);
Expand All @@ -4017,7 +4029,10 @@ void ApiWrap::requestHistory(
_historyRequests.remove(key);
finish();
}).send();
}
#if 0 // mtp
});
#endif
_historyRequests.emplace(key);
}

Expand Down Expand Up @@ -4632,6 +4647,13 @@ void ApiWrap::cancelLocalItem(not_null<HistoryItem*> item) {
void ApiWrap::sendShortcutMessages(
not_null<PeerData*> peer,
BusinessShortcutId id) {
sender().request(TLsendQuickReplyShortcutMessages(
peerToTdbChat(peer->id),
tl_int32(id),
tl_int32(0) // sending_id
)).fail([=](const Error &error) {
}).send();
#if 0 // mtp
auto ids = QVector<MTPint>();
auto randomIds = QVector<MTPlong>();
request(MTPmessages_SendQuickReplyMessages(
Expand All @@ -4643,6 +4665,7 @@ void ApiWrap::sendShortcutMessages(
applyUpdates(result);
}).fail([=](const MTP::Error &error) {
}).send();
#endif
}

void ApiWrap::sendMessage(MessageToSend &&message) {
Expand Down
38 changes: 38 additions & 0 deletions Telegram/SourceFiles/core/local_url_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ PersonalChannelController::PersonalChannelController(

PersonalChannelController::~PersonalChannelController() {
if (_requestId) {
#if 0 // mtp
_window->session().api().request(_requestId).cancel();
#endif
_window->session().sender().request(_requestId).cancel();
}
}

Expand All @@ -118,6 +121,7 @@ void PersonalChannelController::prepare() {
tr::lng_contacts_loading(),
computeListSt().about));

#if 0 // mtp
using Flag = MTPchannels_GetAdminedPublicChannels::Flag;
_requestId = _window->session().api().request(
MTPchannels_GetAdminedPublicChannels(
Expand All @@ -132,6 +136,16 @@ void PersonalChannelController::prepare() {
const auto owner = &_window->session().data();
for (const auto &chat : chats) {
if (const auto peer = owner->processChat(chat)) {
#endif
_requestId = _window->session().sender().request(
TLgetSuitablePersonalChats()
).done([=](const TLchats &result) {
_requestId = 0;

setDescription(nullptr);
const auto owner = &_window->session().data();
for (const auto &chat : result.data().vchat_ids().v) {
if (const auto peer = owner->peerLoaded(peerFromTdbChat(chat))) {
const auto rowId = peer->id.value;
const auto channel = peer->asChannel();
if (channel && !delegate()->peerListFindRow(rowId)) {
Expand Down Expand Up @@ -194,6 +208,7 @@ void SavePersonalChannel(
|| (messageId
&& self->personalChannelMessageId() != messageId)) {
self->setPersonalChannel(channelId, messageId);
#if 0 // mtp
self->session().api().request(MTPaccount_UpdatePersonalChannel(
channel ? channel->inputChannel : MTP_inputChannelEmpty()
)).done(crl::guard(window, [=] {
Expand All @@ -203,6 +218,16 @@ void SavePersonalChannel(
})).fail(crl::guard(window, [=](const MTP::Error &error) {
window->showToast(u"Error: "_q + error.type());
})).send();
#endif
self->session().sender().request(TLsetPersonalChat(
channel ? peerToTdbChat(channel->id) : tl_int53(0)
)).done(crl::guard(window, [=] {
window->showToast((channel
? tr::lng_settings_channel_saved
: tr::lng_settings_channel_removed)(tr::now));
})).fail(crl::guard(window, [=](const Error &error) {
window->showToast(error.message);
})).send();
}
}

Expand Down Expand Up @@ -819,6 +844,7 @@ bool ShowEditBirthday(
const auto save = [=](Data::Birthday result) {
user->setBirthday(result);

#if 0 // mtp
using Flag = MTPaccount_UpdateBirthday::Flag;
using BFlag = MTPDbirthday::Flag;
user->session().api().request(MTPaccount_UpdateBirthday(
Expand All @@ -836,6 +862,18 @@ bool ShowEditBirthday(
? tr::lng_flood_error(tr::now)
: (u"Error: "_q + error.type()));
})).handleFloodErrors().send();
#endif
user->session().sender().request(TLsetBirthdate(result
? tl_birthdate(
tl_int32(result.day()),
tl_int32(result.month()),
tl_int32(result.year()))
: std::optional<TLbirthdate>()
)).done(crl::guard(controller, [=] {
controller->showToast(tr::lng_settings_birthday_saved(tr::now));
})).fail(crl::guard(controller, [=](const Error &error) {
controller->showToast(error.message);
})).send();
};
controller->show(Box(
Ui::EditBirthdayBox,
Expand Down
Loading

0 comments on commit c153a24

Please sign in to comment.