Immediately succeed reorder usernames queries if they can't change order.
This commit is contained in:
parent
4067ba66d3
commit
41262d4629
@ -6899,6 +6899,9 @@ void ContactsManager::reorder_usernames_impl(vector<string> &&usernames, Promise
|
|||||||
if (!u->usernames.can_reorder_to(usernames)) {
|
if (!u->usernames.can_reorder_to(usernames)) {
|
||||||
return promise.set_error(Status::Error(400, "Invalid username order specified"));
|
return promise.set_error(Status::Error(400, "Invalid username order specified"));
|
||||||
}
|
}
|
||||||
|
if (usernames.size() <= 1) {
|
||||||
|
return promise.set_value(Unit());
|
||||||
|
}
|
||||||
td_->create_handler<ReorderUsernamesQuery>(std::move(promise))->send(std::move(usernames));
|
td_->create_handler<ReorderUsernamesQuery>(std::move(promise))->send(std::move(usernames));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7026,6 +7029,9 @@ void ContactsManager::reorder_channel_usernames(ChannelId channel_id, vector<str
|
|||||||
if (!c->usernames.can_reorder_to(usernames)) {
|
if (!c->usernames.can_reorder_to(usernames)) {
|
||||||
return promise.set_error(Status::Error(400, "Invalid username order specified"));
|
return promise.set_error(Status::Error(400, "Invalid username order specified"));
|
||||||
}
|
}
|
||||||
|
if (usernames.size() <= 1) {
|
||||||
|
return promise.set_value(Unit());
|
||||||
|
}
|
||||||
td_->create_handler<ReorderChannelUsernamesQuery>(std::move(promise))->send(channel_id, std::move(usernames));
|
td_->create_handler<ReorderChannelUsernamesQuery>(std::move(promise))->send(channel_id, std::move(usernames));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33518,13 +33518,15 @@ void MessagesManager::on_get_dialog_query_finished(DialogId dialog_id, Status &&
|
|||||||
void MessagesManager::on_dialog_usernames_updated(DialogId dialog_id, const Usernames &old_usernames,
|
void MessagesManager::on_dialog_usernames_updated(DialogId dialog_id, const Usernames &old_usernames,
|
||||||
const Usernames &new_usernames) {
|
const Usernames &new_usernames) {
|
||||||
CHECK(dialog_id.is_valid());
|
CHECK(dialog_id.is_valid());
|
||||||
auto d = get_dialog(dialog_id);
|
const auto *d = get_dialog(dialog_id);
|
||||||
if (d != nullptr) {
|
if (d != nullptr) {
|
||||||
update_dialogs_hints(d);
|
update_dialogs_hints(d);
|
||||||
}
|
}
|
||||||
if (old_usernames != new_usernames) {
|
if (old_usernames != new_usernames) {
|
||||||
message_embedding_codes_[0].erase(dialog_id);
|
message_embedding_codes_[0].erase(dialog_id);
|
||||||
message_embedding_codes_[1].erase(dialog_id);
|
message_embedding_codes_[1].erase(dialog_id);
|
||||||
|
|
||||||
|
LOG(INFO) << "Update usernames in " << dialog_id << " from " << old_usernames << " to " << new_usernames;
|
||||||
}
|
}
|
||||||
if (!old_usernames.is_empty() && old_usernames != new_usernames) {
|
if (!old_usernames.is_empty() && old_usernames != new_usernames) {
|
||||||
for (auto &username : old_usernames.get_active_usernames()) {
|
for (auto &username : old_usernames.get_active_usernames()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user