Add PublicDialogType::ForPersonalDialog.

This commit is contained in:
levlam 2024-03-28 23:39:26 +03:00
parent 6121755719
commit d7f7a6d87b
4 changed files with 13 additions and 5 deletions

View File

@ -2260,6 +2260,10 @@ class GetCreatedPublicChannelsQuery final : public Td::ResultHandler {
if (type_ == PublicDialogType::IsLocationBased) { if (type_ == PublicDialogType::IsLocationBased) {
flags |= telegram_api::channels_getAdminedPublicChannels::BY_LOCATION_MASK; flags |= telegram_api::channels_getAdminedPublicChannels::BY_LOCATION_MASK;
} }
if (type_ == PublicDialogType::ForPersonalDialog) {
CHECK(!check_limit);
flags |= telegram_api::channels_getAdminedPublicChannels::FOR_PERSONAL_MASK;
}
if (check_limit) { if (check_limit) {
flags |= telegram_api::channels_getAdminedPublicChannels::CHECK_LIMIT_MASK; flags |= telegram_api::channels_getAdminedPublicChannels::CHECK_LIMIT_MASK;
} }
@ -7232,6 +7236,8 @@ bool ContactsManager::is_suitable_created_public_channel(PublicDialogType type,
return c->usernames.has_editable_username(); return c->usernames.has_editable_username();
case PublicDialogType::IsLocationBased: case PublicDialogType::IsLocationBased:
return c->has_location; return c->has_location;
case PublicDialogType::ForPersonalDialog:
return !c->is_megagroup && c->usernames.has_first_username();
default: default:
UNREACHABLE(); UNREACHABLE();
return false; return false;
@ -7324,7 +7330,8 @@ void ContactsManager::finish_get_created_public_dialogs(PublicDialogType type, R
} }
void ContactsManager::update_created_public_channels(Channel *c, ChannelId channel_id) { void ContactsManager::update_created_public_channels(Channel *c, ChannelId channel_id) {
for (auto type : {PublicDialogType::HasUsername, PublicDialogType::IsLocationBased}) { for (auto type :
{PublicDialogType::HasUsername, PublicDialogType::IsLocationBased, PublicDialogType::ForPersonalDialog}) {
auto index = static_cast<int32>(type); auto index = static_cast<int32>(type);
if (!created_public_channels_inited_[index]) { if (!created_public_channels_inited_[index]) {
continue; continue;

View File

@ -1710,9 +1710,9 @@ class ContactsManager final : public Actor {
FlatHashMap<UserId, vector<SecretChatId>, UserIdHash> secret_chats_with_user_; FlatHashMap<UserId, vector<SecretChatId>, UserIdHash> secret_chats_with_user_;
bool created_public_channels_inited_[2] = {false, false}; bool created_public_channels_inited_[3] = {false, false, false};
vector<ChannelId> created_public_channels_[2]; vector<ChannelId> created_public_channels_[3];
vector<Promise<td_api::object_ptr<td_api::chats>>> get_created_public_channels_queries_[2]; vector<Promise<td_api::object_ptr<td_api::chats>>> get_created_public_channels_queries_[3];
bool dialogs_for_discussion_inited_ = false; bool dialogs_for_discussion_inited_ = false;
vector<DialogId> dialogs_for_discussion_; vector<DialogId> dialogs_for_discussion_;

View File

@ -10,7 +10,7 @@
namespace td { namespace td {
enum class PublicDialogType : int32 { HasUsername, IsLocationBased }; enum class PublicDialogType : int32 { HasUsername, IsLocationBased, ForPersonalDialog };
inline PublicDialogType get_public_dialog_type(const td_api::object_ptr<td_api::PublicChatType> &type) { inline PublicDialogType get_public_dialog_type(const td_api::object_ptr<td_api::PublicChatType> &type) {
if (type == nullptr || type->get_id() == td_api::publicChatTypeHasUsername::ID) { if (type == nullptr || type->get_id() == td_api::publicChatTypeHasUsername::ID) {

View File

@ -2267,6 +2267,7 @@ void UpdatesManager::try_reload_data() {
td_->autosave_manager_->reload_autosave_settings(); td_->autosave_manager_->reload_autosave_settings();
td_->contacts_manager_->reload_created_public_dialogs(PublicDialogType::HasUsername, std::move(promise)); td_->contacts_manager_->reload_created_public_dialogs(PublicDialogType::HasUsername, std::move(promise));
td_->contacts_manager_->reload_created_public_dialogs(PublicDialogType::IsLocationBased, Auto()); td_->contacts_manager_->reload_created_public_dialogs(PublicDialogType::IsLocationBased, Auto());
td_->contacts_manager_->reload_created_public_dialogs(PublicDialogType::ForPersonalDialog, Auto());
get_default_emoji_statuses(td_, Auto()); get_default_emoji_statuses(td_, Auto());
get_default_channel_emoji_statuses(td_, Auto()); get_default_channel_emoji_statuses(td_, Auto());
td_->notification_settings_manager_->reload_saved_ringtones(Auto()); td_->notification_settings_manager_->reload_saved_ringtones(Auto());