Update created public channels after has_location is changed.
This commit is contained in:
parent
5512700b77
commit
b3bc208d63
@ -7634,6 +7634,37 @@ vector<DialogId> ContactsManager::get_created_public_dialogs(PublicDialogType ty
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContactsManager::update_created_public_channels(Channel *c, ChannelId channel_id) {
|
||||||
|
if (created_public_channels_inited_[0]) {
|
||||||
|
bool was_changed = false;
|
||||||
|
if (c->username.empty() || !c->status.is_creator()) {
|
||||||
|
was_changed = td::remove(created_public_channels_[0], channel_id);
|
||||||
|
} else {
|
||||||
|
if (!td::contains(created_public_channels_[0], channel_id)) {
|
||||||
|
created_public_channels_[0].push_back(channel_id);
|
||||||
|
was_changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (was_changed) {
|
||||||
|
// TODO reload the list
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (created_public_channels_inited_[1]) {
|
||||||
|
bool was_changed = false;
|
||||||
|
if (!c->has_location || !c->status.is_creator()) {
|
||||||
|
was_changed = td::remove(created_public_channels_[1], channel_id);
|
||||||
|
} else {
|
||||||
|
if (!td::contains(created_public_channels_[1], channel_id)) {
|
||||||
|
created_public_channels_[1].push_back(channel_id);
|
||||||
|
was_changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (was_changed) {
|
||||||
|
// TODO reload the list
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ContactsManager::on_get_created_public_channels(PublicDialogType type,
|
void ContactsManager::on_get_created_public_channels(PublicDialogType type,
|
||||||
vector<tl_object_ptr<telegram_api::Chat>> &&chats) {
|
vector<tl_object_ptr<telegram_api::Chat>> &&chats) {
|
||||||
auto index = static_cast<int32>(type);
|
auto index = static_cast<int32>(type);
|
||||||
@ -9847,14 +9878,8 @@ void ContactsManager::update_channel(Channel *c, ChannelId channel_id, bool from
|
|||||||
c->is_status_changed = false;
|
c->is_status_changed = false;
|
||||||
}
|
}
|
||||||
if (c->is_username_changed) {
|
if (c->is_username_changed) {
|
||||||
if (c->status.is_creator() && created_public_channels_inited_[0]) {
|
if (c->status.is_creator()) {
|
||||||
if (c->username.empty()) {
|
update_created_public_channels(c, channel_id);
|
||||||
td::remove(created_public_channels_[0], channel_id);
|
|
||||||
} else {
|
|
||||||
if (!td::contains(created_public_channels_[0], channel_id)) {
|
|
||||||
created_public_channels_[0].push_back(channel_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
c->is_username_changed = false;
|
c->is_username_changed = false;
|
||||||
}
|
}
|
||||||
@ -9866,6 +9891,12 @@ void ContactsManager::update_channel(Channel *c, ChannelId channel_id, bool from
|
|||||||
}
|
}
|
||||||
c->is_default_permissions_changed = false;
|
c->is_default_permissions_changed = false;
|
||||||
}
|
}
|
||||||
|
if (c->is_has_location_changed) {
|
||||||
|
if (c->status.is_creator()) {
|
||||||
|
update_created_public_channels(c, channel_id);
|
||||||
|
}
|
||||||
|
c->is_has_location_changed = false;
|
||||||
|
}
|
||||||
if (c->is_noforwards_changed) {
|
if (c->is_noforwards_changed) {
|
||||||
td_->messages_manager_->on_dialog_allow_saving_content_updated(DialogId(channel_id));
|
td_->messages_manager_->on_dialog_allow_saving_content_updated(DialogId(channel_id));
|
||||||
c->is_noforwards_changed = false;
|
c->is_noforwards_changed = false;
|
||||||
@ -11670,16 +11701,14 @@ bool ContactsManager::on_get_channel_error(ChannelId channel_id, const Status &s
|
|||||||
if (!c->username.empty()) {
|
if (!c->username.empty()) {
|
||||||
LOG(INFO) << "Drop username of " << channel_id;
|
LOG(INFO) << "Drop username of " << channel_id;
|
||||||
on_update_channel_username(c, channel_id, "");
|
on_update_channel_username(c, channel_id, "");
|
||||||
update_channel(c, channel_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->has_location) {
|
on_update_channel_has_location(c, channel_id, false);
|
||||||
LOG(INFO) << "Drop location of " << channel_id;
|
|
||||||
c->has_location = false;
|
|
||||||
update_channel(c, channel_id);
|
|
||||||
}
|
|
||||||
on_update_channel_linked_channel_id(channel_id, ChannelId());
|
on_update_channel_linked_channel_id(channel_id, ChannelId());
|
||||||
|
|
||||||
|
update_channel(c, channel_id);
|
||||||
|
|
||||||
remove_dialog_access_by_invite_link(DialogId(channel_id));
|
remove_dialog_access_by_invite_link(DialogId(channel_id));
|
||||||
}
|
}
|
||||||
invalidate_channel_full(channel_id, !c->is_slow_mode_enabled);
|
invalidate_channel_full(channel_id, !c->is_slow_mode_enabled);
|
||||||
@ -12432,12 +12461,9 @@ void ContactsManager::on_update_channel_full_location(ChannelFull *channel_full,
|
|||||||
|
|
||||||
Channel *c = get_channel(channel_id);
|
Channel *c = get_channel(channel_id);
|
||||||
CHECK(c != nullptr);
|
CHECK(c != nullptr);
|
||||||
if (location.empty() == c->has_location) {
|
on_update_channel_has_location(c, channel_id, !location.empty());
|
||||||
c->has_location = !location.empty();
|
|
||||||
c->is_changed = true;
|
|
||||||
update_channel(c, channel_id);
|
update_channel(c, channel_id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ContactsManager::on_update_channel_full_slow_mode_delay(ChannelFull *channel_full, ChannelId channel_id,
|
void ContactsManager::on_update_channel_full_slow_mode_delay(ChannelFull *channel_full, ChannelId channel_id,
|
||||||
int32 slow_mode_delay, int32 slow_mode_next_send_date) {
|
int32 slow_mode_delay, int32 slow_mode_next_send_date) {
|
||||||
@ -13254,6 +13280,15 @@ void ContactsManager::on_update_channel_default_permissions(Channel *c, ChannelI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContactsManager::on_update_channel_has_location(Channel *c, ChannelId channel_id, bool has_location) {
|
||||||
|
if (c->has_location != has_location) {
|
||||||
|
LOG(INFO) << "Update " << channel_id << " has_location from " << c->has_location << " to " << has_location;
|
||||||
|
c->has_location = has_location;
|
||||||
|
c->is_has_location_changed = true;
|
||||||
|
c->is_changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ContactsManager::on_update_channel_noforwards(Channel *c, ChannelId channel_id, bool noforwards) {
|
void ContactsManager::on_update_channel_noforwards(Channel *c, ChannelId channel_id, bool noforwards) {
|
||||||
if (c->noforwards != noforwards) {
|
if (c->noforwards != noforwards) {
|
||||||
LOG(INFO) << "Update " << channel_id << " noforwards from " << c->noforwards << " to " << noforwards;
|
LOG(INFO) << "Update " << channel_id << " noforwards from " << c->noforwards << " to " << noforwards;
|
||||||
@ -15379,7 +15414,6 @@ void ContactsManager::on_chat_update(telegram_api::channel &channel, const char
|
|||||||
auto access_hash = has_access_hash ? channel.access_hash_ : 0;
|
auto access_hash = has_access_hash ? channel.access_hash_ : 0;
|
||||||
|
|
||||||
bool has_linked_channel = (channel.flags_ & CHANNEL_FLAG_HAS_LINKED_CHAT) != 0;
|
bool has_linked_channel = (channel.flags_ & CHANNEL_FLAG_HAS_LINKED_CHAT) != 0;
|
||||||
bool has_location = (channel.flags_ & CHANNEL_FLAG_HAS_LOCATION) != 0;
|
|
||||||
bool sign_messages = (channel.flags_ & CHANNEL_FLAG_SIGN_MESSAGES) != 0;
|
bool sign_messages = (channel.flags_ & CHANNEL_FLAG_SIGN_MESSAGES) != 0;
|
||||||
bool is_slow_mode_enabled = (channel.flags_ & CHANNEL_FLAG_IS_SLOW_MODE_ENABLED) != 0;
|
bool is_slow_mode_enabled = (channel.flags_ & CHANNEL_FLAG_IS_SLOW_MODE_ENABLED) != 0;
|
||||||
bool is_megagroup = (channel.flags_ & CHANNEL_FLAG_IS_MEGAGROUP) != 0;
|
bool is_megagroup = (channel.flags_ & CHANNEL_FLAG_IS_MEGAGROUP) != 0;
|
||||||
@ -15447,14 +15481,13 @@ void ContactsManager::on_chat_update(telegram_api::channel &channel, const char
|
|||||||
on_update_channel_photo(c, channel_id, std::move(channel.photo_));
|
on_update_channel_photo(c, channel_id, std::move(channel.photo_));
|
||||||
on_update_channel_default_permissions(c, channel_id,
|
on_update_channel_default_permissions(c, channel_id,
|
||||||
get_restricted_rights(std::move(channel.default_banned_rights_)));
|
get_restricted_rights(std::move(channel.default_banned_rights_)));
|
||||||
|
on_update_channel_has_location(c, channel_id, channel.has_geo_);
|
||||||
on_update_channel_noforwards(c, channel_id, channel.noforwards_);
|
on_update_channel_noforwards(c, channel_id, channel.noforwards_);
|
||||||
|
|
||||||
if (c->has_linked_channel != has_linked_channel || c->has_location != has_location ||
|
if (c->has_linked_channel != has_linked_channel || c->is_slow_mode_enabled != is_slow_mode_enabled ||
|
||||||
c->is_slow_mode_enabled != is_slow_mode_enabled || c->is_megagroup != is_megagroup ||
|
c->is_megagroup != is_megagroup || c->restriction_reasons != restriction_reasons || c->is_scam != is_scam ||
|
||||||
c->restriction_reasons != restriction_reasons || c->is_scam != is_scam || c->is_fake != is_fake ||
|
c->is_fake != is_fake || c->is_gigagroup != is_gigagroup) {
|
||||||
c->is_gigagroup != is_gigagroup) {
|
|
||||||
c->has_linked_channel = has_linked_channel;
|
c->has_linked_channel = has_linked_channel;
|
||||||
c->has_location = has_location;
|
|
||||||
c->is_slow_mode_enabled = is_slow_mode_enabled;
|
c->is_slow_mode_enabled = is_slow_mode_enabled;
|
||||||
c->is_megagroup = is_megagroup;
|
c->is_megagroup = is_megagroup;
|
||||||
c->restriction_reasons = std::move(restriction_reasons);
|
c->restriction_reasons = std::move(restriction_reasons);
|
||||||
@ -15506,6 +15539,7 @@ void ContactsManager::on_chat_update(telegram_api::channel &channel, const char
|
|||||||
on_update_channel_username(c, channel_id, std::move(channel.username_)); // uses status, must be called after
|
on_update_channel_username(c, channel_id, std::move(channel.username_)); // uses status, must be called after
|
||||||
on_update_channel_default_permissions(c, channel_id,
|
on_update_channel_default_permissions(c, channel_id,
|
||||||
get_restricted_rights(std::move(channel.default_banned_rights_)));
|
get_restricted_rights(std::move(channel.default_banned_rights_)));
|
||||||
|
on_update_channel_has_location(c, channel_id, channel.has_geo_);
|
||||||
on_update_channel_noforwards(c, channel_id, channel.noforwards_);
|
on_update_channel_noforwards(c, channel_id, channel.noforwards_);
|
||||||
|
|
||||||
bool need_update_participant_count = have_participant_count && participant_count != c->participant_count;
|
bool need_update_participant_count = have_participant_count && participant_count != c->participant_count;
|
||||||
@ -15515,12 +15549,10 @@ void ContactsManager::on_chat_update(telegram_api::channel &channel, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool need_invalidate_channel_full = false;
|
bool need_invalidate_channel_full = false;
|
||||||
if (c->has_linked_channel != has_linked_channel || c->has_location != has_location ||
|
if (c->has_linked_channel != has_linked_channel || c->is_slow_mode_enabled != is_slow_mode_enabled ||
|
||||||
c->is_slow_mode_enabled != is_slow_mode_enabled || c->is_megagroup != is_megagroup ||
|
c->is_megagroup != is_megagroup || c->restriction_reasons != restriction_reasons || c->is_scam != is_scam ||
|
||||||
c->restriction_reasons != restriction_reasons || c->is_scam != is_scam || c->is_fake != is_fake ||
|
c->is_fake != is_fake || c->is_gigagroup != is_gigagroup) {
|
||||||
c->is_gigagroup != is_gigagroup) {
|
|
||||||
c->has_linked_channel = has_linked_channel;
|
c->has_linked_channel = has_linked_channel;
|
||||||
c->has_location = has_location;
|
|
||||||
c->is_slow_mode_enabled = is_slow_mode_enabled;
|
c->is_slow_mode_enabled = is_slow_mode_enabled;
|
||||||
c->is_megagroup = is_megagroup;
|
c->is_megagroup = is_megagroup;
|
||||||
c->restriction_reasons = std::move(restriction_reasons);
|
c->restriction_reasons = std::move(restriction_reasons);
|
||||||
@ -15600,6 +15632,7 @@ void ContactsManager::on_chat_update(telegram_api::channelForbidden &channel, co
|
|||||||
// on_update_channel_username(c, channel_id, ""); // don't know if channel username is empty, so don't update it
|
// on_update_channel_username(c, channel_id, ""); // don't know if channel username is empty, so don't update it
|
||||||
tl_object_ptr<telegram_api::chatBannedRights> banned_rights; // == nullptr
|
tl_object_ptr<telegram_api::chatBannedRights> banned_rights; // == nullptr
|
||||||
on_update_channel_default_permissions(c, channel_id, get_restricted_rights(std::move(banned_rights)));
|
on_update_channel_default_permissions(c, channel_id, get_restricted_rights(std::move(banned_rights)));
|
||||||
|
// on_update_channel_has_location(c, channel_id, false);
|
||||||
on_update_channel_noforwards(c, channel_id, false);
|
on_update_channel_noforwards(c, channel_id, false);
|
||||||
td_->messages_manager_->on_update_dialog_group_call(DialogId(channel_id), false, false, "receive channelForbidden");
|
td_->messages_manager_->on_update_dialog_group_call(DialogId(channel_id), false, false, "receive channelForbidden");
|
||||||
|
|
||||||
@ -15625,7 +15658,6 @@ void ContactsManager::on_chat_update(telegram_api::channelForbidden &channel, co
|
|||||||
if (c->is_slow_mode_enabled != is_slow_mode_enabled || c->is_megagroup != is_megagroup ||
|
if (c->is_slow_mode_enabled != is_slow_mode_enabled || c->is_megagroup != is_megagroup ||
|
||||||
!c->restriction_reasons.empty() || c->is_scam != is_scam || c->is_fake != is_fake) {
|
!c->restriction_reasons.empty() || c->is_scam != is_scam || c->is_fake != is_fake) {
|
||||||
// c->has_linked_channel = has_linked_channel;
|
// c->has_linked_channel = has_linked_channel;
|
||||||
// c->has_location = has_location;
|
|
||||||
c->is_slow_mode_enabled = is_slow_mode_enabled;
|
c->is_slow_mode_enabled = is_slow_mode_enabled;
|
||||||
c->is_megagroup = is_megagroup;
|
c->is_megagroup = is_megagroup;
|
||||||
c->restriction_reasons.clear();
|
c->restriction_reasons.clear();
|
||||||
|
@ -812,6 +812,7 @@ class ContactsManager final : public Actor {
|
|||||||
bool is_photo_changed = true;
|
bool is_photo_changed = true;
|
||||||
bool is_default_permissions_changed = true;
|
bool is_default_permissions_changed = true;
|
||||||
bool is_status_changed = true;
|
bool is_status_changed = true;
|
||||||
|
bool is_has_location_changed = true;
|
||||||
bool is_noforwards_changed = true;
|
bool is_noforwards_changed = true;
|
||||||
bool had_read_access = true;
|
bool had_read_access = true;
|
||||||
bool was_member = false;
|
bool was_member = false;
|
||||||
@ -1232,6 +1233,7 @@ class ContactsManager final : public Actor {
|
|||||||
void on_update_channel_status(Channel *c, ChannelId channel_id, DialogParticipantStatus &&status);
|
void on_update_channel_status(Channel *c, ChannelId channel_id, DialogParticipantStatus &&status);
|
||||||
static void on_update_channel_default_permissions(Channel *c, ChannelId channel_id,
|
static void on_update_channel_default_permissions(Channel *c, ChannelId channel_id,
|
||||||
RestrictedRights default_permissions);
|
RestrictedRights default_permissions);
|
||||||
|
static void on_update_channel_has_location(Channel *c, ChannelId channel_id, bool has_location);
|
||||||
static void on_update_channel_noforwards(Channel *c, ChannelId channel_id, bool noforwards);
|
static void on_update_channel_noforwards(Channel *c, ChannelId channel_id, bool noforwards);
|
||||||
|
|
||||||
void on_update_channel_bot_user_ids(ChannelId channel_id, vector<UserId> &&bot_user_ids);
|
void on_update_channel_bot_user_ids(ChannelId channel_id, vector<UserId> &&bot_user_ids);
|
||||||
@ -1407,6 +1409,8 @@ class ContactsManager final : public Actor {
|
|||||||
|
|
||||||
static bool is_channel_public(const Channel *c);
|
static bool is_channel_public(const Channel *c);
|
||||||
|
|
||||||
|
void update_created_public_channels(Channel *c, ChannelId channel_id);
|
||||||
|
|
||||||
void export_dialog_invite_link_impl(DialogId dialog_id, string title, int32 expire_date, int32 usage_limit,
|
void export_dialog_invite_link_impl(DialogId dialog_id, string title, int32 expire_date, int32 usage_limit,
|
||||||
bool creates_join_request, bool is_permanent,
|
bool creates_join_request, bool is_permanent,
|
||||||
Promise<td_api::object_ptr<td_api::chatInviteLink>> &&promise);
|
Promise<td_api::object_ptr<td_api::chatInviteLink>> &&promise);
|
||||||
|
Loading…
Reference in New Issue
Block a user