| 64 | } |
| 65 | |
| 66 | void 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)")); |
no test coverage detected