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;
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;
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;
inputReportReasonCopyright#9b89f93a = 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;
@ -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;
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;
@ -1207,17 +1208,9 @@ inlineQueryPeerTypeChat#d766c50a = InlineQueryPeerType;
inlineQueryPeerTypeMegagroup#5ec4be43 = 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.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---
@ -1378,7 +1371,7 @@ messages.readMessageContents#36a73f77 id:Vector<int> = messages.AffectedMessages
messages.getStickers#43d4f2c emoticon:string hash:int = messages.Stickers;
messages.getAllStickers#1c9618b1 hash:int = messages.AllStickers;
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.importChatInvite#6c50051c hash:string = Updates;
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.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool;
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.deletePhoneCallHistory#6cff1b45 flags:# revoke:flags.0?true = messages.AffectedHistory;
messages.checkHistoryImport#43fe19f3 import_head:string = messages.HistoryImportParsed;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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