Update API scheme.

This commit is contained in:
John Preston 2021-01-25 17:42:02 +04:00
parent 7410c1fc73
commit 36ad24bfcd
8 changed files with 271 additions and 281 deletions

View file

@ -217,7 +217,7 @@ inputPeerNotifySettings#9c3d198e flags:# show_previews:flags.0?Bool silent:flags
peerNotifySettings#af509d20 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?string = PeerNotifySettings; peerNotifySettings#af509d20 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?string = PeerNotifySettings;
peerSettings#733f2961 flags:# report_spam:flags.0?true add_contact:flags.1?true block_contact:flags.2?true share_contact:flags.3?true need_contacts_exception:flags.4?true report_geo:flags.5?true autoarchived:flags.7?true geo_distance:flags.6?int = PeerSettings; peerSettings#733f2961 flags:# report_spam:flags.0?true add_contact:flags.1?true block_contact:flags.2?true share_contact:flags.3?true need_contacts_exception:flags.4?true report_geo:flags.5?true autoarchived:flags.7?true invite_members:flags.8?true geo_distance:flags.6?int = PeerSettings;
wallPaper#a437c3ed id:long flags:# creator:flags.0?true default:flags.1?true pattern:flags.3?true dark:flags.4?true access_hash:long slug:string document:Document settings:flags.2?WallPaperSettings = WallPaper; wallPaper#a437c3ed id:long flags:# creator:flags.0?true default:flags.1?true pattern:flags.3?true dark:flags.4?true access_hash:long slug:string document:Document settings:flags.2?WallPaperSettings = WallPaper;
wallPaperNoFile#8af40b25 flags:# default:flags.1?true dark:flags.4?true settings:flags.2?WallPaperSettings = WallPaper; wallPaperNoFile#8af40b25 flags:# default:flags.1?true dark:flags.4?true settings:flags.2?WallPaperSettings = WallPaper;
@ -229,6 +229,7 @@ inputReportReasonChildAbuse#adf44ee3 = ReportReason;
inputReportReasonOther#e1746d0a text:string = ReportReason; inputReportReasonOther#e1746d0a text:string = ReportReason;
inputReportReasonCopyright#9b89f93a = ReportReason; inputReportReasonCopyright#9b89f93a = ReportReason;
inputReportReasonGeoIrrelevant#dbd4feed = ReportReason; inputReportReasonGeoIrrelevant#dbd4feed = ReportReason;
inputReportReasonFake#f5ddd6e7 = ReportReason;
userFull#edf17c12 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true user:User about:flags.1?string settings:PeerSettings profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int = UserFull; userFull#edf17c12 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true user:User about:flags.1?string settings:PeerSettings profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int = UserFull;
@ -1195,7 +1196,7 @@ groupCall#55903081 flags:# join_muted:flags.1?true can_change_join_muted:flags.2
inputGroupCall#d8aa840f id:long access_hash:long = InputGroupCall; inputGroupCall#d8aa840f id:long access_hash:long = InputGroupCall;
groupCallParticipant#b881f32b flags:# muted:flags.0?true left:flags.1?true can_self_unmute:flags.2?true just_joined:flags.4?true versioned:flags.5?true muted_by_you:flags.9?true user_id:int date:int active_date:flags.3?int source:int volume:flags.7?int muted_cnt:flags.8?int = GroupCallParticipant; groupCallParticipant#64c62a15 flags:# muted:flags.0?true left:flags.1?true can_self_unmute:flags.2?true just_joined:flags.4?true versioned:flags.5?true muted_by_you:flags.9?true user_id:int date:int active_date:flags.3?int source:int volume:flags.7?int = GroupCallParticipant;
phone.groupCall#66ab0bfc call:GroupCall participants:Vector<GroupCallParticipant> participants_next_offset:string users:Vector<User> = phone.GroupCall; phone.groupCall#66ab0bfc call:GroupCall participants:Vector<GroupCallParticipant> participants_next_offset:string users:Vector<User> = phone.GroupCall;
@ -1207,17 +1208,9 @@ inlineQueryPeerTypeChat#d766c50a = InlineQueryPeerType;
inlineQueryPeerTypeMegagroup#5ec4be43 = InlineQueryPeerType; inlineQueryPeerTypeMegagroup#5ec4be43 = InlineQueryPeerType;
inlineQueryPeerTypeBroadcast#6334ee9a = InlineQueryPeerType; inlineQueryPeerTypeBroadcast#6334ee9a = InlineQueryPeerType;
chatInviteImporter#1e3e6680 user_id:int date:int = ChatInviteImporter;
messages.exportedChatInvites#bdc62dcc count:int invites:Vector<ExportedChatInvite> users:Vector<User> = messages.ExportedChatInvites;
messages.exportedChatInvite#1871be50 invite:ExportedChatInvite users:Vector<User> = messages.ExportedChatInvite;
messages.chatInviteImporters#81b6b00a count:int importers:Vector<ChatInviteImporter> users:Vector<User> = messages.ChatInviteImporters;
messages.historyImport#1662af0b id:long = messages.HistoryImport; messages.historyImport#1662af0b id:long = messages.HistoryImport;
messages.historyImportParsed#8d94ab42 flags:# pm:flags.0?true group:flags.1?true title:flags.1?string = messages.HistoryImportParsed; messages.historyImportParsed#5e0fb7b9 flags:# pm:flags.0?true group:flags.1?true title:flags.2?string = messages.HistoryImportParsed;
---functions--- ---functions---
@ -1378,7 +1371,7 @@ messages.readMessageContents#36a73f77 id:Vector<int> = messages.AffectedMessages
messages.getStickers#43d4f2c emoticon:string hash:int = messages.Stickers; messages.getStickers#43d4f2c emoticon:string hash:int = messages.Stickers;
messages.getAllStickers#1c9618b1 hash:int = messages.AllStickers; messages.getAllStickers#1c9618b1 hash:int = messages.AllStickers;
messages.getWebPagePreview#8b68b0cc flags:# message:string entities:flags.3?Vector<MessageEntity> = MessageMedia; messages.getWebPagePreview#8b68b0cc flags:# message:string entities:flags.3?Vector<MessageEntity> = MessageMedia;
messages.exportChatInvite#14b9bcd7 flags:# legacy_revoke_permanent:flags.2?true peer:InputPeer expire_date:flags.0?int usage_limit:flags.1?int = ExportedChatInvite; messages.exportChatInvite#df7534c peer:InputPeer = ExportedChatInvite;
messages.checkChatInvite#3eadb1bb hash:string = ChatInvite; messages.checkChatInvite#3eadb1bb hash:string = ChatInvite;
messages.importChatInvite#6c50051c hash:string = Updates; messages.importChatInvite#6c50051c hash:string = Updates;
messages.getStickerSet#2619a90e stickerset:InputStickerSet = messages.StickerSet; messages.getStickerSet#2619a90e stickerset:InputStickerSet = messages.StickerSet;
@ -1468,11 +1461,6 @@ messages.getReplies#24b581ba peer:InputPeer msg_id:int offset_id:int offset_date
messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.DiscussionMessage; messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.DiscussionMessage;
messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool; messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool;
messages.unpinAllMessages#f025bc8b peer:InputPeer = messages.AffectedHistory; messages.unpinAllMessages#f025bc8b peer:InputPeer = messages.AffectedHistory;
messages.getExportedChatInvites#6a72ac6c flags:# revoked:flags.3?true peer:InputPeer admin_id:flags.0?InputUser offset_date:flags.2?int offset_link:flags.2?string limit:int = messages.ExportedChatInvites;
messages.editExportedChatInvite#2e4ffbe flags:# revoked:flags.2?true peer:InputPeer link:string expire_date:flags.0?int usage_limit:flags.1?int = messages.ExportedChatInvite;
messages.deleteRevokedExportedChatInvites#52041463 peer:InputPeer = Bool;
messages.deleteExportedChatInvite#d464a42b peer:InputPeer link:string = Bool;
messages.getChatInviteImporters#26fb7289 peer:InputPeer link:string offset_date:int offset_user:InputUser limit:int = messages.ChatInviteImporters;
messages.deleteChat#83247d11 chat_id:int = Bool; messages.deleteChat#83247d11 chat_id:int = Bool;
messages.deletePhoneCallHistory#6cff1b45 flags:# revoke:flags.0?true = messages.AffectedHistory; messages.deletePhoneCallHistory#6cff1b45 flags:# revoke:flags.0?true = messages.AffectedHistory;
messages.checkHistoryImport#43fe19f3 import_head:string = messages.HistoryImportParsed; messages.checkHistoryImport#43fe19f3 import_head:string = messages.HistoryImportParsed;

View file

@ -41,26 +41,27 @@ void RemovePermanent(PeerInviteLinks &links) {
} // namespace } // namespace
JoinedByLinkSlice ParseJoinedByLinkSlice( // #TODO links
not_null<PeerData*> peer, //JoinedByLinkSlice ParseJoinedByLinkSlice(
const MTPmessages_ChatInviteImporters &slice) { // not_null<PeerData*> peer,
auto result = JoinedByLinkSlice(); // const MTPmessages_ChatInviteImporters &slice) {
slice.match([&](const MTPDmessages_chatInviteImporters &data) { // auto result = JoinedByLinkSlice();
auto &owner = peer->session().data(); // slice.match([&](const MTPDmessages_chatInviteImporters &data) {
owner.processUsers(data.vusers()); // auto &owner = peer->session().data();
result.count = data.vcount().v; // owner.processUsers(data.vusers());
result.users.reserve(data.vimporters().v.size()); // result.count = data.vcount().v;
for (const auto importer : data.vimporters().v) { // result.users.reserve(data.vimporters().v.size());
importer.match([&](const MTPDchatInviteImporter &data) { // for (const auto importer : data.vimporters().v) {
result.users.push_back({ // importer.match([&](const MTPDchatInviteImporter &data) {
.user = owner.user(data.vuser_id().v), // result.users.push_back({
.date = data.vdate().v, // .user = owner.user(data.vuser_id().v),
}); // .date = data.vdate().v,
}); // });
} // });
}); // }
return result; // });
} // return result;
//}
InviteLinks::InviteLinks(not_null<ApiWrap*> api) : _api(api) { InviteLinks::InviteLinks(not_null<ApiWrap*> api) : _api(api) {
} }
@ -91,16 +92,19 @@ void InviteLinks::performCreate(
callbacks.push_back(std::move(done)); callbacks.push_back(std::move(done));
} }
using Flag = MTPmessages_ExportChatInvite::Flag; // #TODO links
//using Flag = MTPmessages_ExportChatInvite::Flag;
//_api->request(MTPmessages_ExportChatInvite(
// MTP_flags((revokeLegacyPermanent
// ? Flag::f_legacy_revoke_permanent
// : Flag(0))
// | (expireDate ? Flag::f_expire_date : Flag(0))
// | (usageLimit ? Flag::f_usage_limit : Flag(0))),
// peer->input,
// MTP_int(expireDate),
// MTP_int(usageLimit)
_api->request(MTPmessages_ExportChatInvite( _api->request(MTPmessages_ExportChatInvite(
MTP_flags((revokeLegacyPermanent peer->input
? Flag::f_legacy_revoke_permanent
: Flag(0))
| (expireDate ? Flag::f_expire_date : Flag(0))
| (usageLimit ? Flag::f_usage_limit : Flag(0))),
peer->input,
MTP_int(expireDate),
MTP_int(usageLimit)
)).done([=](const MTPExportedChatInvite &result) { )).done([=](const MTPExportedChatInvite &result) {
const auto callbacks = _createCallbacks.take(peer); const auto callbacks = _createCallbacks.take(peer);
const auto link = prepend(peer, result); const auto link = prepend(peer, result);
@ -215,51 +219,51 @@ void InviteLinks::performEdit(
if (done) { if (done) {
callbacks.push_back(std::move(done)); callbacks.push_back(std::move(done));
} }
// #TODO links
using Flag = MTPmessages_EditExportedChatInvite::Flag; //using Flag = MTPmessages_EditExportedChatInvite::Flag;
_api->request(MTPmessages_EditExportedChatInvite( //_api->request(MTPmessages_EditExportedChatInvite(
MTP_flags((revoke ? Flag::f_revoked : Flag(0)) // MTP_flags((revoke ? Flag::f_revoked : Flag(0))
| ((!revoke && expireDate) ? Flag::f_expire_date : Flag(0)) // | ((!revoke && expireDate) ? Flag::f_expire_date : Flag(0))
| ((!revoke && usageLimit) ? Flag::f_usage_limit : Flag(0))), // | ((!revoke && usageLimit) ? Flag::f_usage_limit : Flag(0))),
peer->input, // peer->input,
MTP_string(link), // MTP_string(link),
MTP_int(expireDate), // MTP_int(expireDate),
MTP_int(usageLimit) // MTP_int(usageLimit)
)).done([=](const MTPmessages_ExportedChatInvite &result) { //)).done([=](const MTPmessages_ExportedChatInvite &result) {
const auto callbacks = _editCallbacks.take(key); // const auto callbacks = _editCallbacks.take(key);
const auto peer = key.peer; // const auto peer = key.peer;
result.match([&](const MTPDmessages_exportedChatInvite &data) { // result.match([&](const MTPDmessages_exportedChatInvite &data) {
_api->session().data().processUsers(data.vusers()); // _api->session().data().processUsers(data.vusers());
const auto link = parse(peer, data.vinvite()); // const auto link = parse(peer, data.vinvite());
auto i = _firstSlices.find(peer); // auto i = _firstSlices.find(peer);
if (i != end(_firstSlices)) { // if (i != end(_firstSlices)) {
const auto j = ranges::find( // const auto j = ranges::find(
i->second.links, // i->second.links,
key.link, // key.link,
&Link::link); // &Link::link);
if (j != end(i->second.links)) { // if (j != end(i->second.links)) {
if (link.revoked && !j->revoked) { // if (link.revoked && !j->revoked) {
i->second.links.erase(j); // i->second.links.erase(j);
if (i->second.count > 0) { // if (i->second.count > 0) {
--i->second.count; // --i->second.count;
} // }
} else { // } else {
*j = link; // *j = link;
} // }
} // }
} // }
for (const auto &callback : *callbacks) { // for (const auto &callback : *callbacks) {
callback(link); // callback(link);
} // }
_updates.fire(Update{ // _updates.fire(Update{
.peer = peer, // .peer = peer,
.was = key.link, // .was = key.link,
.now = link, // .now = link,
}); // });
}); // });
}).fail([=](const RPCError &error) { //}).fail([=](const RPCError &error) {
_editCallbacks.erase(key); // _editCallbacks.erase(key);
}).send(); //}).send();
} }
void InviteLinks::revoke( void InviteLinks::revoke(
@ -293,24 +297,24 @@ void InviteLinks::destroy(
if (done) { if (done) {
callbacks.push_back(std::move(done)); callbacks.push_back(std::move(done));
} }
// #TODO links
_api->request(MTPmessages_DeleteExportedChatInvite( //_api->request(MTPmessages_DeleteExportedChatInvite(
peer->input, // peer->input,
MTP_string(link) // MTP_string(link)
)).done([=](const MTPBool &result) { //)).done([=](const MTPBool &result) {
const auto callbacks = _deleteCallbacks.take(key); // const auto callbacks = _deleteCallbacks.take(key);
if (callbacks) { // if (callbacks) {
for (const auto &callback : *callbacks) { // for (const auto &callback : *callbacks) {
callback(); // callback();
} // }
} // }
_updates.fire(Update{ // _updates.fire(Update{
.peer = peer, // .peer = peer,
.was = key.link, // .was = key.link,
}); // });
}).fail([=](const RPCError &error) { //}).fail([=](const RPCError &error) {
_deleteCallbacks.erase(key); // _deleteCallbacks.erase(key);
}).send(); //}).send();
} }
void InviteLinks::destroyAllRevoked( void InviteLinks::destroyAllRevoked(
@ -327,61 +331,62 @@ void InviteLinks::destroyAllRevoked(
if (done) { if (done) {
callbacks.push_back(std::move(done)); callbacks.push_back(std::move(done));
} }
// #TODO links
_api->request(MTPmessages_DeleteRevokedExportedChatInvites( //_api->request(MTPmessages_DeleteRevokedExportedChatInvites(
peer->input // peer->input
)).done([=](const MTPBool &result) { //)).done([=](const MTPBool &result) {
if (const auto callbacks = _deleteRevokedCallbacks.take(peer)) { // if (const auto callbacks = _deleteRevokedCallbacks.take(peer)) {
for (const auto &callback : *callbacks) { // for (const auto &callback : *callbacks) {
callback(); // callback();
} // }
} // }
_allRevokedDestroyed.fire_copy(peer); // _allRevokedDestroyed.fire_copy(peer);
}).fail([=](const RPCError &error) { //}).fail([=](const RPCError &error) {
}).send(); //}).send();
} }
void InviteLinks::requestLinks(not_null<PeerData*> peer) { void InviteLinks::requestLinks(not_null<PeerData*> peer) {
if (_firstSliceRequests.contains(peer)) { if (_firstSliceRequests.contains(peer)) {
return; return;
} }
const auto requestId = _api->request(MTPmessages_GetExportedChatInvites( // #TODO links
MTP_flags(0), //const auto requestId = _api->request(MTPmessages_GetExportedChatInvites(
peer->input, // MTP_flags(0),
MTPInputUser(), // admin_id // peer->input,
MTPint(), // offset_date // MTPInputUser(), // admin_id
MTPstring(), // offset_link // MTPint(), // offset_date
MTP_int(kFirstPage) // MTPstring(), // offset_link
)).done([=](const MTPmessages_ExportedChatInvites &result) { // MTP_int(kFirstPage)
_firstSliceRequests.remove(peer); //)).done([=](const MTPmessages_ExportedChatInvites &result) {
auto slice = parseSlice(peer, result); // _firstSliceRequests.remove(peer);
auto i = _firstSlices.find(peer); // auto slice = parseSlice(peer, result);
const auto permanent = (i != end(_firstSlices)) // auto i = _firstSlices.find(peer);
? lookupPermanent(i->second) // const auto permanent = (i != end(_firstSlices))
: nullptr; // ? lookupPermanent(i->second)
if (!permanent) { // : nullptr;
BringPermanentToFront(slice); // if (!permanent) {
const auto j = _firstSlices.emplace_or_assign( // BringPermanentToFront(slice);
peer, // const auto j = _firstSlices.emplace_or_assign(
std::move(slice)).first; // peer,
if (const auto permanent = lookupPermanent(j->second)) { // std::move(slice)).first;
editPermanentLink(peer, permanent->link); // if (const auto permanent = lookupPermanent(j->second)) {
} // editPermanentLink(peer, permanent->link);
} else { // }
RemovePermanent(slice); // } else {
auto &existing = i->second.links; // RemovePermanent(slice);
existing.erase(begin(existing) + 1, end(existing)); // auto &existing = i->second.links;
existing.insert( // existing.erase(begin(existing) + 1, end(existing));
end(existing), // existing.insert(
begin(slice.links), // end(existing),
end(slice.links)); // begin(slice.links),
i->second.count = std::max(slice.count, int(existing.size())); // end(slice.links));
} // i->second.count = std::max(slice.count, int(existing.size()));
notify(peer); // }
}).fail([=](const RPCError &error) { // notify(peer);
_firstSliceRequests.remove(peer); //}).fail([=](const RPCError &error) {
}).send(); // _firstSliceRequests.remove(peer);
_firstSliceRequests.emplace(peer, requestId); //}).send();
//_firstSliceRequests.emplace(peer, requestId);
} }
std::optional<JoinedByLinkSlice> InviteLinks::lookupJoinedFirstSlice( std::optional<JoinedByLinkSlice> InviteLinks::lookupJoinedFirstSlice(
@ -442,23 +447,23 @@ rpl::producer<> InviteLinks::allRevokedDestroyed(
} }
void InviteLinks::requestJoinedFirstSlice(LinkKey key) { void InviteLinks::requestJoinedFirstSlice(LinkKey key) {
if (_firstJoinedRequests.contains(key)) { //if (_firstJoinedRequests.contains(key)) { // #TODO links
return; // return;
} //}
const auto requestId = _api->request(MTPmessages_GetChatInviteImporters( //const auto requestId = _api->request(MTPmessages_GetChatInviteImporters(
key.peer->input, // key.peer->input,
MTP_string(key.link), // MTP_string(key.link),
MTP_int(0), // offset_date // MTP_int(0), // offset_date
MTP_inputUserEmpty(), // offset_user // MTP_inputUserEmpty(), // offset_user
MTP_int(kJoinedFirstPage) // MTP_int(kJoinedFirstPage)
)).done([=](const MTPmessages_ChatInviteImporters &result) { //)).done([=](const MTPmessages_ChatInviteImporters &result) {
_firstJoinedRequests.remove(key); // _firstJoinedRequests.remove(key);
_firstJoined[key] = ParseJoinedByLinkSlice(key.peer, result); // _firstJoined[key] = ParseJoinedByLinkSlice(key.peer, result);
_joinedFirstSliceLoaded.fire_copy(key); // _joinedFirstSliceLoaded.fire_copy(key);
}).fail([=](const RPCError &error) { //}).fail([=](const RPCError &error) {
_firstJoinedRequests.remove(key); // _firstJoinedRequests.remove(key);
}).send(); //}).send();
_firstJoinedRequests.emplace(key, requestId); //_firstJoinedRequests.emplace(key, requestId);
} }
void InviteLinks::setPermanent( void InviteLinks::setPermanent(
@ -546,27 +551,27 @@ auto InviteLinks::links(not_null<PeerData*> peer) const -> const Links & {
const auto i = _firstSlices.find(peer); const auto i = _firstSlices.find(peer);
return (i != end(_firstSlices)) ? i->second : kEmpty; return (i != end(_firstSlices)) ? i->second : kEmpty;
} }
// #TODO links
auto InviteLinks::parseSlice( //auto InviteLinks::parseSlice(
not_null<PeerData*> peer, // not_null<PeerData*> peer,
const MTPmessages_ExportedChatInvites &slice) const -> Links { // const MTPmessages_ExportedChatInvites &slice) const -> Links {
auto i = _firstSlices.find(peer); // auto i = _firstSlices.find(peer);
const auto permanent = (i != end(_firstSlices)) // const auto permanent = (i != end(_firstSlices))
? lookupPermanent(i->second) // ? lookupPermanent(i->second)
: nullptr; // : nullptr;
auto result = Links(); // auto result = Links();
slice.match([&](const MTPDmessages_exportedChatInvites &data) { // slice.match([&](const MTPDmessages_exportedChatInvites &data) {
peer->session().data().processUsers(data.vusers()); // peer->session().data().processUsers(data.vusers());
result.count = data.vcount().v; // result.count = data.vcount().v;
for (const auto &invite : data.vinvites().v) { // for (const auto &invite : data.vinvites().v) {
const auto link = parse(peer, invite); // const auto link = parse(peer, invite);
if (!permanent || link.link != permanent->link) { // if (!permanent || link.link != permanent->link) {
result.links.push_back(link); // result.links.push_back(link);
} // }
} // }
}); // });
return result; // return result;
} //}
auto InviteLinks::parse( auto InviteLinks::parse(
not_null<PeerData*> peer, not_null<PeerData*> peer,
@ -592,22 +597,23 @@ void InviteLinks::requestMoreLinks(
const QString &lastLink, const QString &lastLink,
bool revoked, bool revoked,
Fn<void(Links)> done) { Fn<void(Links)> done) {
using Flag = MTPmessages_GetExportedChatInvites::Flag; // #TODO links
_api->request(MTPmessages_GetExportedChatInvites( //using Flag = MTPmessages_GetExportedChatInvites::Flag;
MTP_flags(Flag::f_offset_link //_api->request(MTPmessages_GetExportedChatInvites(
| (revoked ? Flag::f_revoked : Flag(0))), // MTP_flags(Flag::f_offset_link
peer->input, // | (revoked ? Flag::f_revoked : Flag(0))),
MTPInputUser(), // admin_id, // peer->input,
MTP_int(lastDate), // MTPInputUser(), // admin_id,
MTP_string(lastLink), // MTP_int(lastDate),
MTP_int(kPerPage) // MTP_string(lastLink),
)).done([=](const MTPmessages_ExportedChatInvites &result) { // MTP_int(kPerPage)
auto slice = parseSlice(peer, result); //)).done([=](const MTPmessages_ExportedChatInvites &result) {
RemovePermanent(slice); // auto slice = parseSlice(peer, result);
done(std::move(slice)); // RemovePermanent(slice);
}).fail([=](const RPCError &error) { // done(std::move(slice));
done(Links()); //}).fail([=](const RPCError &error) {
}).send(); // done(Links());
//}).send();
} }
void InviteLinks::editPermanentLink( void InviteLinks::editPermanentLink(

View file

@ -43,10 +43,10 @@ struct InviteLinkUpdate {
QString was; QString was;
std::optional<InviteLink> now; std::optional<InviteLink> now;
}; };
// #TODO links
[[nodiscard]] JoinedByLinkSlice ParseJoinedByLinkSlice( //[[nodiscard]] JoinedByLinkSlice ParseJoinedByLinkSlice(
not_null<PeerData*> peer, // not_null<PeerData*> peer,
const MTPmessages_ChatInviteImporters &slice); // const MTPmessages_ChatInviteImporters &slice);
class InviteLinks final { class InviteLinks final {
public: public:
@ -124,9 +124,10 @@ private:
} }
}; };
[[nodiscard]] Links parseSlice( // #TODO links
not_null<PeerData*> peer, //[[nodiscard]] Links parseSlice(
const MTPmessages_ExportedChatInvites &slice) const; // not_null<PeerData*> peer,
// const MTPmessages_ExportedChatInvites &slice) const;
[[nodiscard]] Link parse( [[nodiscard]] Link parse(
not_null<PeerData*> peer, not_null<PeerData*> peer,
const MTPExportedChatInvite &invite) const; const MTPExportedChatInvite &invite) const;

View file

@ -696,7 +696,6 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio
channel, channel,
std::move(image)); std::move(image));
} }
using Flag = MTPmessages_ExportChatInvite::Flag;
_createdChannel = channel; _createdChannel = channel;
checkInviteLink(); checkInviteLink();
}; };

View file

@ -987,29 +987,29 @@ void Controller::fillManageSection() {
[=] { ShowEditPermissions(_navigation, _peer); }, [=] { ShowEditPermissions(_navigation, _peer); },
st::infoIconPermissions); st::infoIconPermissions);
} }
if (canEditInviteLinks) { //if (canEditInviteLinks) { // #TODO links
AddButtonWithCount( // AddButtonWithCount(
_controls.buttonsLayout, // _controls.buttonsLayout,
tr::lng_manage_peer_invite_links(), // tr::lng_manage_peer_invite_links(),
Info::Profile::MigratedOrMeValue( // Info::Profile::MigratedOrMeValue(
_peer // _peer
) | rpl::map([=](not_null<PeerData*> peer) { // ) | rpl::map([=](not_null<PeerData*> peer) {
peer->session().api().inviteLinks().requestLinks(peer); // peer->session().api().inviteLinks().requestLinks(peer);
return peer->session().changes().peerUpdates( // return peer->session().changes().peerUpdates(
peer, // peer,
Data::PeerUpdate::Flag::InviteLinks // Data::PeerUpdate::Flag::InviteLinks
) | rpl::map([=] { // ) | rpl::map([=] {
return peer->session().api().inviteLinks().links( // return peer->session().api().inviteLinks().links(
peer).count; // peer).count;
}); // });
}) | rpl::flatten_latest( // }) | rpl::flatten_latest(
) | ToPositiveNumberString(), // ) | ToPositiveNumberString(),
[=] { Ui::show( // [=] { Ui::show(
Box(ManageInviteLinksBox, _peer), // Box(ManageInviteLinksBox, _peer),
Ui::LayerOption::KeepOther); // Ui::LayerOption::KeepOther);
}, // },
st::infoIconInviteLinks); // st::infoIconInviteLinks);
} //}
if (canViewAdmins) { if (canViewAdmins) {
AddButtonWithCount( AddButtonWithCount(
_controls.buttonsLayout, _controls.buttonsLayout,

View file

@ -222,21 +222,22 @@ void Controller::loadMoreRows() {
if (_requestId || _allLoaded) { if (_requestId || _allLoaded) {
return; return;
} }
_requestId = _api.request(MTPmessages_GetChatInviteImporters( _allLoaded = true; // #TODO links
_peer->input, //_requestId = _api.request(MTPmessages_GetChatInviteImporters(
MTP_string(_data.link), // _peer->input,
MTP_int(_lastUser ? _lastUser->date : 0), // MTP_string(_data.link),
_lastUser ? _lastUser->user->inputUser : MTP_inputUserEmpty(), // MTP_int(_lastUser ? _lastUser->date : 0),
MTP_int(_lastUser ? kPerPage : kFirstPage) // _lastUser ? _lastUser->user->inputUser : MTP_inputUserEmpty(),
)).done([=](const MTPmessages_ChatInviteImporters &result) { // MTP_int(_lastUser ? kPerPage : kFirstPage)
_requestId = 0; //)).done([=](const MTPmessages_ChatInviteImporters &result) {
auto slice = Api::ParseJoinedByLinkSlice(_peer, result); // _requestId = 0;
_allLoaded = slice.users.empty(); // auto slice = Api::ParseJoinedByLinkSlice(_peer, result);
appendSlice(slice); // _allLoaded = slice.users.empty();
}).fail([=](const RPCError &error) { // appendSlice(slice);
_requestId = 0; //}).fail([=](const RPCError &error) {
_allLoaded = true; // _requestId = 0;
}).send(); // _allLoaded = true;
//}).send();
} }
void Controller::appendSlice(const Api::JoinedByLinkSlice &slice) { void Controller::appendSlice(const Api::JoinedByLinkSlice &slice) {

View file

@ -177,20 +177,20 @@ void Controller::createContent() {
_wrap->add(createInviteLinkBlock()); _wrap->add(createInviteLinkBlock());
_wrap->add(createUsernameEdit()); _wrap->add(createUsernameEdit());
using namespace Settings; //using namespace Settings; // #TODO links
AddSkip(_wrap.get()); //AddSkip(_wrap.get());
_wrap->add(EditPeerInfoBox::CreateButton( //_wrap->add(EditPeerInfoBox::CreateButton(
_wrap.get(), // _wrap.get(),
tr::lng_group_invite_manage(), // tr::lng_group_invite_manage(),
rpl::single(QString()), // rpl::single(QString()),
[=] { Ui::show( // [=] { Ui::show(
Box(ManageInviteLinksBox, _peer), // Box(ManageInviteLinksBox, _peer),
Ui::LayerOption::KeepOther); // Ui::LayerOption::KeepOther);
}, // },
st::manageGroupButton, // st::manageGroupButton,
&st::infoIconInviteLinks)); // &st::infoIconInviteLinks));
AddSkip(_wrap.get()); //AddSkip(_wrap.get());
AddDividerText(_wrap.get(), tr::lng_group_invite_manage_about()); //AddDividerText(_wrap.get(), tr::lng_group_invite_manage_about());
if (_controls.privacy->value() == Privacy::NoUsername) { if (_controls.privacy->value() == Privacy::NoUsername) {
checkUsernameAvailability(); checkUsernameAvailability();

View file

@ -377,12 +377,10 @@ void GroupCall::applySelfInCallLocally() {
? i->lastActive ? i->lastActive
: TimeId(0); : TimeId(0);
const auto canSelfUnmute = (muted() != MuteState::ForceMuted); const auto canSelfUnmute = (muted() != MuteState::ForceMuted);
const auto mutedCount = (i != end(participants)) ? /*i->mutedCount*/0 : 0;
const auto flags = (canSelfUnmute ? Flag::f_can_self_unmute : Flag(0)) const auto flags = (canSelfUnmute ? Flag::f_can_self_unmute : Flag(0))
| (lastActive ? Flag::f_active_date : Flag(0)) | (lastActive ? Flag::f_active_date : Flag(0))
| (_mySsrc ? Flag(0) : Flag::f_left) | (_mySsrc ? Flag(0) : Flag::f_left)
| ((muted() != MuteState::Active) ? Flag::f_muted : Flag(0)) | ((muted() != MuteState::Active) ? Flag::f_muted : Flag(0));
| (mutedCount ? Flag::f_muted_cnt : Flag(0));
call->applyUpdateChecked( call->applyUpdateChecked(
MTP_updateGroupCallParticipants( MTP_updateGroupCallParticipants(
inputCall(), inputCall(),
@ -394,8 +392,7 @@ void GroupCall::applySelfInCallLocally() {
MTP_int(date), MTP_int(date),
MTP_int(lastActive), MTP_int(lastActive),
MTP_int(_mySsrc), MTP_int(_mySsrc),
MTP_int(10000), // volume MTP_int(10000))), // volume
MTP_int(mutedCount))),
MTP_int(0)).c_updateGroupCallParticipants()); MTP_int(0)).c_updateGroupCallParticipants());
} }
@ -413,8 +410,7 @@ void GroupCall::applyParticipantLocally(
const auto flags = (canSelfUnmute ? Flag::f_can_self_unmute : Flag(0)) const auto flags = (canSelfUnmute ? Flag::f_can_self_unmute : Flag(0))
| (participant->lastActive ? Flag::f_active_date : Flag(0)) | (participant->lastActive ? Flag::f_active_date : Flag(0))
| (participant->muted ? Flag::f_muted : Flag(0)) | (participant->muted ? Flag::f_muted : Flag(0))
| (participant->mutedByMe ? Flag::f_muted_by_you : Flag(0)) | (participant->mutedByMe ? Flag::f_muted_by_you : Flag(0));
| (mutedCount ? Flag::f_muted_cnt : Flag(0));
_peer->groupCall()->applyUpdateChecked( _peer->groupCall()->applyUpdateChecked(
MTP_updateGroupCallParticipants( MTP_updateGroupCallParticipants(
inputCall(), inputCall(),
@ -426,8 +422,7 @@ void GroupCall::applyParticipantLocally(
MTP_int(participant->date), MTP_int(participant->date),
MTP_int(participant->lastActive), MTP_int(participant->lastActive),
MTP_int(participant->ssrc), MTP_int(participant->ssrc),
MTP_int(volume.value_or(participant->volume)), // volume MTP_int(volume.value_or(participant->volume)))),
MTP_int(mutedCount))),
MTP_int(0)).c_updateGroupCallParticipants()); MTP_int(0)).c_updateGroupCallParticipants());
} }