@@ -11,7 +11,6 @@ For license and copyright information please follow this link:
1111#include " apiwrap.h"
1212#include " boxes/passcode_box.h"
1313#include " core/core_cloud_password.h"
14- #include " data/data_channel.h"
1514#include " data/data_user.h"
1615#include " lang/lang_keys.h"
1716#include " main/main_session.h"
@@ -47,21 +46,10 @@ bool ChannelOwnershipTransfer::handleTransferPasswordError(
4746}
4847
4948void ChannelOwnershipTransfer::start () {
50- if (const auto chat = _peer->asChatNotMigrated ()) {
51- _peer->session ().api ().migrateChat (chat, [=](
52- not_null<ChannelData*> channel) {
53- startTransfer (channel);
54- });
55- } else if (const auto channel = _peer->asChannelOrMigrated ()) {
56- startTransfer (channel);
57- }
58- }
59-
60- void ChannelOwnershipTransfer::startTransfer (not_null<ChannelData*> channel) {
61- const auto api = &channel->session ().api ();
49+ const auto api = &_peer->session ().api ();
6250 api->cloudPassword ().reload ();
63- api->request (MTPchannels_EditCreator (
64- channel-> inputChannel (),
51+ api->request (MTPmessages_EditChatCreator (
52+ _peer-> input (),
6553 MTP_inputUserEmpty (),
6654 MTP_inputCheckPasswordEmpty ()
6755 )).fail ([=](const MTP ::Error &error) {
@@ -78,7 +66,7 @@ void ChannelOwnershipTransfer::startTransfer(not_null<ChannelData*> channel) {
7866 .text = tr::lng_rights_transfer_about (
7967 tr::now,
8068 lt_group,
81- tr::bold (channel ->name ()),
69+ tr::bold (_peer ->name ()),
8270 lt_user,
8371 tr::bold (_selectedUser->shortName ()),
8472 tr::rich),
@@ -110,20 +98,16 @@ void ChannelOwnershipTransfer::requestPassword() {
11098void ChannelOwnershipTransfer::sendRequest (
11199 base::weak_qptr<PasscodeBox> box,
112100 const Core::CloudPasswordResult &result) {
113- const auto channel = _peer->asChannelOrMigrated ();
114- if (!channel) {
115- return ;
116- }
117- const auto api = &channel->session ().api ();
118- api->request (MTPchannels_EditCreator (
119- channel->inputChannel (),
101+ const auto api = &_peer->session ().api ();
102+ api->request (MTPmessages_EditChatCreator (
103+ _peer->input (),
120104 _selectedUser->inputUser (),
121105 result.result
122106 )).done ([=](const MTPUpdates &result) {
123107 api->applyUpdates (result);
124108 const auto currentShow = box ? box->uiShow () : _show;
125109 currentShow->showToast (
126- (channel ->isBroadcast ()
110+ (_peer ->isBroadcast ()
127111 ? tr::lng_rights_transfer_done_channel
128112 : tr::lng_rights_transfer_done_group)(
129113 tr::now,
@@ -143,11 +127,13 @@ void ChannelOwnershipTransfer::sendRequest(
143127 } else if (type == u" CHANNELS_ADMIN_LOCATED_TOO_MUCH" _q) {
144128 return tr::lng_channels_too_much_located_other (tr::now);
145129 } else if (type == u" ADMINS_TOO_MUCH" _q) {
146- return (channel ->isBroadcast ()
130+ return (_peer ->isBroadcast ()
147131 ? tr::lng_error_admin_limit_channel
148132 : tr::lng_error_admin_limit)(tr::now);
149- } else if (type == u" CHANNEL_INVALID" _q) {
150- return (channel->isBroadcast ()
133+ } else if (type == u" CHANNEL_INVALID" _q
134+ || type == u" CHAT_CREATOR_REQUIRED" _q
135+ || type == u" PARTICIPANT_MISSING" _q) {
136+ return (_peer->isBroadcast ()
151137 ? tr::lng_channel_not_accessible
152138 : tr::lng_group_not_accessible)(tr::now);
153139 }
0 commit comments