MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / startMainSession

Method startMainSession

Telegram/SourceFiles/export/export_api_wrap.cpp:717–775  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

715}
716
717void ApiWrap::startMainSession(FnMut<void()> done) {
718 using Type = Settings::Type;
719 const auto sizeLimit = _settings->media.sizeLimit;
720 const auto hasFiles = ((_settings->media.types != 0) && (sizeLimit > 0))
721 || (_settings->types & Type::Userpics)
722 || (_settings->types & Type::Stories);
723
724 using Flag = MTPaccount_InitTakeoutSession::Flag;
725 const auto flags = Flag(0)
726 | (_settings->types & Type::Contacts ? Flag::f_contacts : Flag(0))
727 | (hasFiles ? Flag::f_files : Flag(0))
728 | ((hasFiles && sizeLimit < kFileMaxSize)
729 ? Flag::f_file_max_size
730 : Flag(0))
731 | (_settings->types & (Type::PersonalChats | Type::BotChats)
732 ? Flag::f_message_users
733 : Flag(0))
734 | (_settings->types & Type::PrivateGroups
735 ? (Flag::f_message_chats | Flag::f_message_megagroups)
736 : Flag(0))
737 | (_settings->types & Type::PublicGroups
738 ? Flag::f_message_megagroups
739 : Flag(0))
740 | (_settings->types & (Type::PrivateChannels | Type::PublicChannels)
741 ? Flag::f_message_channels
742 : Flag(0));
743
744 _mtp.request(MTPusers_GetUsers(
745 MTP_vector<MTPInputUser>(1, MTP_inputUserSelf())
746 )).done([=, done = std::move(done)](
747 const MTPVector<MTPUser> &result) mutable {
748 for (const auto &user : result.v) {
749 user.match([&](const MTPDuser &data) {
750 if (data.is_self()) {
751 _selfId.emplace(data.vid());
752 }
753 }, [&](const MTPDuserEmpty&) {
754 });
755 }
756 if (!_selfId) {
757 error("Could not retrieve selfId.");
758 return;
759 }
760 _mtp.request(MTPaccount_InitTakeoutSession(
761 MTP_flags(flags),
762 MTP_long(sizeLimit)
763 )).done([=, done = std::move(done)](
764 const MTPaccount_Takeout &result) mutable {
765 _takeoutId = result.match([](const MTPDaccount_takeout &data) {
766 return data.vid().v;
767 });
768 done();
769 }).fail([=](const MTP::Error &result) {
770 error(result);
771 }).toDC(MTP::ShiftDcId(0, MTP::kExportDcShift)).send();
772 }).fail([=](const MTP::Error &result) {
773 error(result);
774 }).send();

Callers

nothing calls this directly

Calls 11

errorFunction · 0.85
MTP_flagsFunction · 0.85
MTP_longFunction · 0.85
ShiftDcIdFunction · 0.85
emplaceMethod · 0.80
toDCMethod · 0.80
FlagEnum · 0.50
sendMethod · 0.45
failMethod · 0.45
doneMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected