Automatically update list of suitable discussion chats.
GitOrigin-RevId: e1ef89b9c0dcf76bf63f508c9806d5764e2b972e
This commit is contained in:
parent
3846d56680
commit
1021269634
@ -4924,6 +4924,26 @@ void ContactsManager::on_get_dialogs_for_discussion(vector<tl_object_ptr<telegra
|
|||||||
dialogs_for_discussion_ = get_dialog_ids(std::move(chats), "on_get_dialogs_for_discussion");
|
dialogs_for_discussion_ = get_dialog_ids(std::move(chats), "on_get_dialogs_for_discussion");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContactsManager::update_dialogs_for_discussion(DialogId dialog_id, bool is_suitable) {
|
||||||
|
if (!dialogs_for_discussion_inited_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto it = std::find(dialogs_for_discussion_.begin(), dialogs_for_discussion_.end(), dialog_id);
|
||||||
|
bool is_found = it != dialogs_for_discussion_.end();
|
||||||
|
if (is_suitable == is_found) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_suitable) {
|
||||||
|
LOG(DEBUG) << "Add " << dialog_id << " to list of suitable discussion chats";
|
||||||
|
dialogs_for_discussion_.insert(dialogs_for_discussion_.begin(), dialog_id);
|
||||||
|
} else {
|
||||||
|
LOG(DEBUG) << "Remove " << dialog_id << " from list of suitable discussion chats";
|
||||||
|
dialogs_for_discussion_.erase(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ContactsManager::on_imported_contacts(int64 random_id, vector<UserId> imported_contact_user_ids,
|
void ContactsManager::on_imported_contacts(int64 random_id, vector<UserId> imported_contact_user_ids,
|
||||||
vector<int32> unimported_contact_invites) {
|
vector<int32> unimported_contact_invites) {
|
||||||
LOG(INFO) << "Contacts import with random_id " << random_id
|
LOG(INFO) << "Contacts import with random_id " << random_id
|
||||||
@ -6446,9 +6466,13 @@ void ContactsManager::update_chat(Chat *c, ChatId chat_id, bool from_binlog, boo
|
|||||||
if (c->is_default_permissions_changed) {
|
if (c->is_default_permissions_changed) {
|
||||||
td_->messages_manager_->on_dialog_permissions_updated(DialogId(chat_id));
|
td_->messages_manager_->on_dialog_permissions_updated(DialogId(chat_id));
|
||||||
}
|
}
|
||||||
|
if (c->is_is_active_changed) {
|
||||||
|
update_dialogs_for_discussion(DialogId(chat_id), c->is_active && c->status.is_creator());
|
||||||
|
}
|
||||||
c->is_photo_changed = false;
|
c->is_photo_changed = false;
|
||||||
c->is_title_changed = false;
|
c->is_title_changed = false;
|
||||||
c->is_default_permissions_changed = false;
|
c->is_default_permissions_changed = false;
|
||||||
|
c->is_is_active_changed = false;
|
||||||
|
|
||||||
LOG(DEBUG) << "Update " << chat_id << ": is_changed = " << c->is_changed
|
LOG(DEBUG) << "Update " << chat_id << ": is_changed = " << c->is_changed
|
||||||
<< ", need_send_update = " << c->need_send_update;
|
<< ", need_send_update = " << c->need_send_update;
|
||||||
@ -6507,6 +6531,10 @@ void ContactsManager::update_channel(Channel *c, ChannelId channel_id, bool from
|
|||||||
} else {
|
} else {
|
||||||
channel_unban_timeout_.cancel_timeout(channel_id.get());
|
channel_unban_timeout_.cancel_timeout(channel_id.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c->is_megagroup) {
|
||||||
|
update_dialogs_for_discussion(DialogId(channel_id), c->status.is_administrator() && c->status.can_pin_messages());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (c->is_username_changed) {
|
if (c->is_username_changed) {
|
||||||
if (c->status.is_creator() && created_public_channels_inited_) {
|
if (c->status.is_creator() && created_public_channels_inited_) {
|
||||||
@ -8732,6 +8760,7 @@ void ContactsManager::on_update_chat_title(Chat *c, ChatId chat_id, string &&tit
|
|||||||
void ContactsManager::on_update_chat_active(Chat *c, ChatId chat_id, bool is_active) {
|
void ContactsManager::on_update_chat_active(Chat *c, ChatId chat_id, bool is_active) {
|
||||||
if (c->is_active != is_active) {
|
if (c->is_active != is_active) {
|
||||||
c->is_active = is_active;
|
c->is_active = is_active;
|
||||||
|
c->is_is_active_changed = true;
|
||||||
c->need_send_update = true;
|
c->need_send_update = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -602,6 +602,7 @@ class ContactsManager : public Actor {
|
|||||||
bool is_title_changed = true;
|
bool is_title_changed = true;
|
||||||
bool is_photo_changed = true;
|
bool is_photo_changed = true;
|
||||||
bool is_default_permissions_changed = true;
|
bool is_default_permissions_changed = true;
|
||||||
|
bool is_is_active_changed = true;
|
||||||
bool is_changed = true; // have new changes not sent to the database except changes visible to the client
|
bool is_changed = true; // have new changes not sent to the database except changes visible to the client
|
||||||
bool need_send_update = true; // have new changes not sent to the client
|
bool need_send_update = true; // have new changes not sent to the client
|
||||||
|
|
||||||
@ -1105,6 +1106,8 @@ class ContactsManager : public Actor {
|
|||||||
|
|
||||||
vector<DialogId> get_dialog_ids(vector<tl_object_ptr<telegram_api::Chat>> &&chats, const char *source);
|
vector<DialogId> get_dialog_ids(vector<tl_object_ptr<telegram_api::Chat>> &&chats, const char *source);
|
||||||
|
|
||||||
|
void update_dialogs_for_discussion(DialogId dialog_id, bool is_suitable);
|
||||||
|
|
||||||
void delete_chat_participant(ChatId chat_id, UserId user_id, Promise<Unit> &&promise);
|
void delete_chat_participant(ChatId chat_id, UserId user_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void change_channel_participant_status_impl(ChannelId channel_id, UserId user_id, DialogParticipantStatus status,
|
void change_channel_participant_status_impl(ChannelId channel_id, UserId user_id, DialogParticipantStatus status,
|
||||||
|
Reference in New Issue
Block a user