Skip to content

Commit 5c7d272

Browse files
committed
Update API scheme to layer 223. Owners.
1 parent 17e8fd5 commit 5c7d272

9 files changed

Lines changed: 192 additions & 106 deletions

File tree

‎Telegram/Resources/langs/lang.strings‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
16551655
"lng_leave_next_owner_box_title_group" = "Leave Group?";
16561656
"lng_leave_next_owner_box_about" = "If you leave, **{user}** will become the new owner of **{chat}** in **1 week**.";
16571657
"lng_leave_next_owner_box_about_admin" = "If you leave, **{user}** will become the new admin of **{chat}** in **1 week**.";
1658+
"lng_leave_next_owner_box_about_legacy" = "If you leave, **{user}** will immediately become the new owner of **{chat}**.";
1659+
"lng_leave_next_owner_box_about_admin_legacy" = "If you leave, **{user}** will immediately become the new admin of **{chat}**.";
16581660
"lng_select_next_owner_box" = "Appoint Another Owner";
16591661
"lng_select_next_owner_box_admin" = "Appoint Another Admin";
16601662
"lng_select_next_owner_box_title" = "Appoint New Owner";

‎Telegram/SourceFiles/api/api_text_entities.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ EntitiesInText EntitiesFromMTP(
238238
d.vlength().v,
239239
d.is_collapsed() ? u"1"_q : QString(),
240240
});
241+
}, [&](const MTPDmessageEntityFormattedDate &d) {
241242
});
242243
}
243244
return result;

‎Telegram/SourceFiles/boxes/peers/channel_ownership_transfer.cpp‎

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -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

4948
void 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() {
11098
void 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
}

‎Telegram/SourceFiles/boxes/peers/channel_ownership_transfer.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ For license and copyright information please follow this link:
77
*/
88
#pragma once
99

10-
class ChannelData;
1110
class UserData;
1211

1312
namespace Ui {
@@ -36,7 +35,6 @@ class ChannelOwnershipTransfer {
3635
void sendRequest(
3736
base::weak_qptr<PasscodeBox> box,
3837
const Core::CloudPasswordResult &result);
39-
void startTransfer(not_null<ChannelData*> channel);
4038

4139
const not_null<PeerData*> _peer;
4240
const not_null<UserData*> _selectedUser;

0 commit comments

Comments
 (0)