Do not return deleted secret chats and replace migrated basic groups with corresponding supergroups in recently found chats.
GitOrigin-RevId: e50390583e3956a4eb8fdb92ec8a82f04cc7914f
This commit is contained in:
parent
fbeea0b108
commit
c1309d7657
@ -12815,6 +12815,14 @@ bool ContactsManager::get_chat_is_active(ChatId chat_id) const {
|
||||
return c->is_active;
|
||||
}
|
||||
|
||||
ChannelId ContactsManager::get_chat_migrated_to_channel_id(ChatId chat_id) const {
|
||||
auto c = get_chat(chat_id);
|
||||
if (c == nullptr) {
|
||||
return ChannelId();
|
||||
}
|
||||
return c->migrated_to_channel_id;
|
||||
}
|
||||
|
||||
DialogParticipantStatus ContactsManager::get_chat_status(ChatId chat_id) const {
|
||||
auto c = get_chat(chat_id);
|
||||
if (c == nullptr) {
|
||||
|
@ -464,6 +464,7 @@ class ContactsManager : public Actor {
|
||||
void reload_chat_full(ChatId chat_id, Promise<Unit> &&promise);
|
||||
|
||||
bool get_chat_is_active(ChatId chat_id) const;
|
||||
ChannelId get_chat_migrated_to_channel_id(ChatId chat_id) const;
|
||||
DialogParticipantStatus get_chat_status(ChatId chat_id) const;
|
||||
DialogParticipantStatus get_chat_permissions(ChatId chat_id) const;
|
||||
bool is_appointed_chat_administrator(ChatId chat_id) const;
|
||||
|
@ -15404,6 +15404,9 @@ std::pair<int32, vector<DialogId>> MessagesManager::search_dialogs(const string
|
||||
}
|
||||
|
||||
promise.set_value(Unit());
|
||||
|
||||
update_recently_found_dialogs();
|
||||
|
||||
size_t result_size = min(static_cast<size_t>(limit), recently_found_dialog_ids_.size());
|
||||
return {narrow_cast<int32>(recently_found_dialog_ids_.size()),
|
||||
vector<DialogId>(recently_found_dialog_ids_.begin(), recently_found_dialog_ids_.begin() + result_size)};
|
||||
@ -35219,6 +35222,7 @@ void MessagesManager::save_recently_found_dialogs() {
|
||||
}
|
||||
value += to_string(dialog_id.get());
|
||||
}
|
||||
LOG(DEBUG) << "Save recently found chats " << value;
|
||||
G()->td_db()->get_binlog_pmc()->set("recently_found_dialog_usernames_and_ids", value);
|
||||
}
|
||||
|
||||
@ -35237,6 +35241,7 @@ bool MessagesManager::load_recently_found_dialogs(Promise<Unit> &promise) {
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG(DEBUG) << "Loaded recently found chats " << found_dialogs_str;
|
||||
auto found_dialogs = full_split(found_dialogs_str, ',');
|
||||
if (recently_found_dialogs_loaded_ == 1 && resolve_recently_found_dialogs_multipromise_.promise_count() == 0) {
|
||||
// queries was sent and have already been finished
|
||||
@ -35342,7 +35347,7 @@ bool MessagesManager::add_recently_found_dialog_internal(DialogId dialog_id) {
|
||||
// TODO create function
|
||||
auto it = std::find(recently_found_dialog_ids_.begin(), recently_found_dialog_ids_.end(), dialog_id);
|
||||
if (it == recently_found_dialog_ids_.end()) {
|
||||
if (narrow_cast<int32>(recently_found_dialog_ids_.size()) == MAX_RECENT_FOUND_DIALOGS) {
|
||||
if (narrow_cast<int32>(recently_found_dialog_ids_.size()) == MAX_RECENTLY_FOUND_DIALOGS) {
|
||||
CHECK(!recently_found_dialog_ids_.empty());
|
||||
recently_found_dialog_ids_.back() = dialog_id;
|
||||
} else {
|
||||
@ -35359,6 +35364,48 @@ bool MessagesManager::remove_recently_found_dialog_internal(DialogId dialog_id)
|
||||
return td::remove(recently_found_dialog_ids_, dialog_id);
|
||||
}
|
||||
|
||||
void MessagesManager::update_recently_found_dialogs() {
|
||||
vector<DialogId> dialog_ids;
|
||||
for (auto dialog_id : recently_found_dialog_ids_) {
|
||||
const Dialog *d = get_dialog(dialog_id);
|
||||
if (d == nullptr) {
|
||||
continue;
|
||||
}
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
// always keep
|
||||
break;
|
||||
case DialogType::Chat: {
|
||||
auto channel_id = td_->contacts_manager_->get_chat_migrated_to_channel_id(dialog_id.get_chat_id());
|
||||
if (channel_id.is_valid() && get_dialog(DialogId(channel_id)) != nullptr) {
|
||||
dialog_id = DialogId(channel_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DialogType::Channel:
|
||||
// always keep
|
||||
break;
|
||||
case DialogType::SecretChat:
|
||||
if (is_deleted_secret_chat(d)) {
|
||||
dialog_id = DialogId();
|
||||
}
|
||||
break;
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
if (dialog_id.is_valid()) {
|
||||
dialog_ids.push_back(dialog_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (dialog_ids != recently_found_dialog_ids_) {
|
||||
recently_found_dialog_ids_ = std::move(dialog_ids);
|
||||
save_recently_found_dialogs();
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesManager::suffix_load_loop(Dialog *d) {
|
||||
if (d->suffix_load_has_query_) {
|
||||
return;
|
||||
|
@ -1644,7 +1644,7 @@ class MessagesManager : public Actor {
|
||||
static constexpr int32 MIN_CHANNEL_DIFFERENCE = 10;
|
||||
static constexpr int32 MAX_CHANNEL_DIFFERENCE = 100;
|
||||
static constexpr int32 MAX_BOT_CHANNEL_DIFFERENCE = 100000; // server side limit
|
||||
static constexpr int32 MAX_RECENT_FOUND_DIALOGS = 20; // some reasonable value
|
||||
static constexpr int32 MAX_RECENTLY_FOUND_DIALOGS = 30; // some reasonable value
|
||||
static constexpr size_t MAX_TITLE_LENGTH = 128; // server side limit for chat title
|
||||
static constexpr size_t MAX_DESCRIPTION_LENGTH = 255; // server side limit for chat description
|
||||
static constexpr size_t MAX_DIALOG_FILTER_TITLE_LENGTH = 12; // server side limit for dialog filter title
|
||||
@ -2831,7 +2831,10 @@ class MessagesManager : public Actor {
|
||||
|
||||
bool remove_recently_found_dialog_internal(DialogId dialog_id);
|
||||
|
||||
void update_recently_found_dialogs();
|
||||
|
||||
void save_recently_found_dialogs();
|
||||
|
||||
bool load_recently_found_dialogs(Promise<Unit> &promise);
|
||||
|
||||
void reget_message_from_server_if_needed(DialogId dialog_id, const Message *m);
|
||||
|
Loading…
Reference in New Issue
Block a user