Restore support for ContactsManager::on_update_channel_editable_username.
This commit is contained in:
parent
2d8d3716f9
commit
e8d7f23e2c
@ -811,13 +811,13 @@ class UpdateChannelUsernameQuery final : public Td::ResultHandler {
|
||||
return on_error(Status::Error(500, "Supergroup username is not updated"));
|
||||
}
|
||||
|
||||
// td_->contacts_manager_->on_update_channel_editable_username(channel_id_, std::move(username_));
|
||||
td_->contacts_manager_->on_update_channel_editable_username(channel_id_, std::move(username_));
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
if (status.message() == "USERNAME_NOT_MODIFIED" || status.message() == "CHAT_NOT_MODIFIED") {
|
||||
// td_->contacts_manager_->on_update_channel_editable_username(channel_id_, std::move(username_));
|
||||
td_->contacts_manager_->on_update_channel_editable_username(channel_id_, std::move(username_));
|
||||
if (!td_->auth_manager_->is_bot()) {
|
||||
promise_.set_value(Unit());
|
||||
return;
|
||||
@ -14361,6 +14361,13 @@ void ContactsManager::on_update_channel_noforwards(Channel *c, ChannelId channel
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_channel_editable_username(ChannelId channel_id, string &&username) {
|
||||
Channel *c = get_channel(channel_id);
|
||||
CHECK(c != nullptr);
|
||||
on_update_channel_usernames(c, channel_id, c->usernames.change_editable_username(std::move(username)));
|
||||
update_channel(c, channel_id);
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_channel_usernames(ChannelId channel_id, Usernames &&usernames) {
|
||||
if (!channel_id.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid " << channel_id;
|
||||
|
@ -200,6 +200,7 @@ class ContactsManager final : public Actor {
|
||||
void on_update_chat_default_permissions(ChatId chat_id, RestrictedRights default_permissions, int32 version);
|
||||
void on_update_chat_pinned_message(ChatId chat_id, MessageId pinned_message_id, int32 version);
|
||||
|
||||
void on_update_channel_editable_username(ChannelId channel_id, string &&username);
|
||||
void on_update_channel_usernames(ChannelId channel_id, Usernames &&usernames);
|
||||
void on_update_channel_description(ChannelId channel_id, string &&description);
|
||||
void on_update_channel_sticker_set(ChannelId channel_id, StickerSetId sticker_set_id);
|
||||
|
@ -67,6 +67,19 @@ tl_object_ptr<td_api::usernames> Usernames::get_usernames_object() const {
|
||||
editable_username_pos_ == -1 ? string() : active_usernames_[editable_username_pos_]);
|
||||
}
|
||||
|
||||
Usernames Usernames::change_editable_username(string &&new_username) const {
|
||||
Usernames result = *this;
|
||||
if (editable_username_pos_ != -1) {
|
||||
// keep position
|
||||
result.active_usernames_[editable_username_pos_] = std::move(new_username);
|
||||
} else {
|
||||
// add to the beginning
|
||||
result.active_usernames_.insert(result.active_usernames_.begin(), std::move(new_username));
|
||||
result.editable_username_pos_ = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Usernames::can_reorder_to(const vector<string> &new_username_order) const {
|
||||
if (new_username_order.size() != active_usernames_.size()) {
|
||||
return false;
|
||||
|
@ -63,6 +63,8 @@ class Usernames {
|
||||
return active_usernames_;
|
||||
}
|
||||
|
||||
Usernames change_editable_username(string &&new_username) const;
|
||||
|
||||
bool can_reorder_to(const vector<string> &new_username_order) const;
|
||||
|
||||
Usernames reorder_to(vector<string> &&new_username_order) const;
|
||||
|
Loading…
Reference in New Issue
Block a user