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

Function ChatCreateDone

Telegram/SourceFiles/boxes/add_contact_box.cpp:66–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void ChatCreateDone(
67 not_null<Window::SessionNavigation*> navigation,
68 QImage image,
69 TimeId ttlPeriod,
70 const MTPmessages_InvitedUsers &result,
71 Fn<void(not_null<PeerData*>)> done) {
72 const auto &data = result.data();
73 navigation->session().api().applyUpdates(data.vupdates());
74
75 const auto success = base::make_optional(&data.vupdates())
76 | [](auto updates) -> std::optional<const QVector<MTPChat>*> {
77 switch (updates->type()) {
78 case mtpc_updates:
79 return &updates->c_updates().vchats().v;
80 case mtpc_updatesCombined:
81 return &updates->c_updatesCombined().vchats().v;
82 }
83 LOG(("API Error: unexpected update cons %1 "
84 "(GroupInfoBox::creationDone)").arg(updates->type()));
85 return std::nullopt;
86 }
87 | [](auto chats) {
88 return (!chats->empty()
89 && chats->front().type() == mtpc_chat)
90 ? base::make_optional(chats)
91 : std::nullopt;
92 }
93 | [&](auto chats) {
94 return navigation->session().data().chat(
95 chats->front().c_chat().vid());
96 }
97 | [&](not_null<ChatData*> chat) {
98 if (!image.isNull()) {
99 chat->session().api().peerPhoto().upload(
100 chat,
101 { std::move(image) });
102 }
103 if (ttlPeriod) {
104 chat->setMessagesTTL(ttlPeriod);
105 }
106 if (done) {
107 done(chat);
108 } else {
109 const auto show = navigation->uiShow();
110 navigation->showPeerHistory(chat);
111 ChatInviteForbidden(
112 show,
113 chat,
114 CollectForbiddenUsers(&chat->session(), result));
115 chat->owner().addRecentJoinChat({
116 .fromPeerId = chat->id,
117 .joinedPeerId = chat->id,
118 });
119 }
120 };
121 if (!success) {
122 LOG(("API Error: chat not found in updates "
123 "(ContactsBox::creationDone)"));

Callers 1

createGroupMethod · 0.85

Calls 15

ChatInviteForbiddenFunction · 0.85
CollectForbiddenUsersFunction · 0.85
apiMethod · 0.80
frontMethod · 0.80
setMessagesTTLMethod · 0.80
addRecentJoinChatMethod · 0.80
dataMethod · 0.45
applyUpdatesMethod · 0.45
sessionMethod · 0.45
typeMethod · 0.45
emptyMethod · 0.45
chatMethod · 0.45

Tested by

no test coverage detected