Move on_get_permanent_dialog_invite_link to DialogInviteLinkManager.
This commit is contained in:
parent
33ad5964ef
commit
4227491ef4
@ -12719,34 +12719,6 @@ void ContactsManager::on_update_channel_full_photo(ChannelFull *channel_full, Ch
|
||||
channel_full->registered_photo_file_ids = std::move(photo_file_ids);
|
||||
}
|
||||
|
||||
void ContactsManager::on_get_permanent_dialog_invite_link(DialogId dialog_id, const DialogInviteLink &invite_link) {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::Chat: {
|
||||
auto chat_id = dialog_id.get_chat_id();
|
||||
auto chat_full = get_chat_full_force(chat_id, "on_get_permanent_dialog_invite_link");
|
||||
if (chat_full != nullptr && update_permanent_invite_link(chat_full->invite_link, invite_link)) {
|
||||
chat_full->is_changed = true;
|
||||
update_chat_full(chat_full, chat_id, "on_get_permanent_dialog_invite_link");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DialogType::Channel: {
|
||||
auto channel_id = dialog_id.get_channel_id();
|
||||
auto channel_full = get_channel_full_force(channel_id, true, "on_get_permanent_dialog_invite_link");
|
||||
if (channel_full != nullptr && update_permanent_invite_link(channel_full->invite_link, invite_link)) {
|
||||
channel_full->is_changed = true;
|
||||
update_channel_full(channel_full, channel_id, "on_get_permanent_dialog_invite_link");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DialogType::User:
|
||||
case DialogType::SecretChat:
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_chat_full_invite_link(ChatFull *chat_full,
|
||||
tl_object_ptr<telegram_api::ExportedChatInvite> &&invite_link) {
|
||||
CHECK(chat_full != nullptr);
|
||||
@ -13506,6 +13478,14 @@ void ContactsManager::on_update_chat_bot_commands(ChatId chat_id, BotCommands &&
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_chat_permanent_invite_link(ChatId chat_id, const DialogInviteLink &invite_link) {
|
||||
auto chat_full = get_chat_full_force(chat_id, "on_update_chat_permanent_invite_link");
|
||||
if (chat_full != nullptr && update_permanent_invite_link(chat_full->invite_link, invite_link)) {
|
||||
chat_full->is_changed = true;
|
||||
update_chat_full(chat_full, chat_id, "on_update_chat_permanent_invite_link");
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_channel_photo(Channel *c, ChannelId channel_id, DialogPhoto &&photo,
|
||||
bool invalidate_photo_cache) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
@ -15455,6 +15435,15 @@ void ContactsManager::on_update_channel_bot_commands(ChannelId channel_id, BotCo
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_channel_permanent_invite_link(ChannelId channel_id,
|
||||
const DialogInviteLink &invite_link) {
|
||||
auto channel_full = get_channel_full_force(channel_id, true, "on_update_channel_permanent_invite_link");
|
||||
if (channel_full != nullptr && update_permanent_invite_link(channel_full->invite_link, invite_link)) {
|
||||
channel_full->is_changed = true;
|
||||
update_channel_full(channel_full, channel_id, "on_update_channel_permanent_invite_link");
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_get_chat_empty(telegram_api::chatEmpty &chat, const char *source) {
|
||||
ChatId chat_id(chat.id_);
|
||||
if (!chat_id.is_valid()) {
|
||||
|
@ -279,6 +279,7 @@ class ContactsManager final : public Actor {
|
||||
void on_update_chat_default_permissions(ChatId chat_id, RestrictedRights default_permissions, int32 version);
|
||||
void on_update_chat_pinned_message(ChatId chat_id, MessageId pinned_message_id, int32 version);
|
||||
void on_update_chat_bot_commands(ChatId chat_id, BotCommands &&bot_commands);
|
||||
void on_update_chat_permanent_invite_link(ChatId chat_id, const DialogInviteLink &invite_link);
|
||||
|
||||
void on_update_channel_participant_count(ChannelId channel_id, int32 participant_count);
|
||||
void on_update_channel_editable_username(ChannelId channel_id, string &&username);
|
||||
@ -304,6 +305,7 @@ class ContactsManager final : public Actor {
|
||||
void on_update_channel_default_permissions(ChannelId channel_id, RestrictedRights default_permissions);
|
||||
void on_update_channel_administrator_count(ChannelId channel_id, int32 administrator_count);
|
||||
void on_update_channel_bot_commands(ChannelId channel_id, BotCommands &&bot_commands);
|
||||
void on_update_channel_permanent_invite_link(ChannelId channel_id, const DialogInviteLink &invite_link);
|
||||
|
||||
void on_update_bot_menu_button(UserId bot_user_id, tl_object_ptr<telegram_api::BotMenuButton> &&bot_menu_button);
|
||||
|
||||
@ -316,8 +318,6 @@ class ContactsManager final : public Actor {
|
||||
|
||||
bool on_get_channel_error(ChannelId channel_id, const Status &status, const char *source);
|
||||
|
||||
void on_get_permanent_dialog_invite_link(DialogId dialog_id, const DialogInviteLink &invite_link);
|
||||
|
||||
void on_get_created_public_channels(PublicDialogType type, vector<tl_object_ptr<telegram_api::Chat>> &&chats);
|
||||
|
||||
void on_get_dialogs_for_discussion(vector<tl_object_ptr<telegram_api::Chat>> &&chats);
|
||||
|
@ -155,7 +155,7 @@ class ExportChatInviteQuery final : public Td::ResultHandler {
|
||||
return on_error(Status::Error(500, "Receive invalid invite link creator"));
|
||||
}
|
||||
if (invite_link.is_permanent()) {
|
||||
td_->contacts_manager_->on_get_permanent_dialog_invite_link(dialog_id_, invite_link);
|
||||
td_->dialog_invite_link_manager_->on_get_permanent_dialog_invite_link(dialog_id_, invite_link);
|
||||
}
|
||||
promise_.set_value(invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
}
|
||||
@ -511,7 +511,7 @@ class RevokeChatInviteLinkQuery final : public Td::ResultHandler {
|
||||
}
|
||||
if (new_invite_link.get_creator_user_id() == td_->contacts_manager_->get_my_id() &&
|
||||
new_invite_link.is_permanent()) {
|
||||
td_->contacts_manager_->on_get_permanent_dialog_invite_link(dialog_id_, new_invite_link);
|
||||
td_->dialog_invite_link_manager_->on_get_permanent_dialog_invite_link(dialog_id_, new_invite_link);
|
||||
}
|
||||
links.push_back(invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
links.push_back(new_invite_link.get_chat_invite_link_object(td_->contacts_manager_.get()));
|
||||
@ -960,6 +960,21 @@ Status DialogInviteLinkManager::can_manage_dialog_invite_links(DialogId dialog_i
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
void DialogInviteLinkManager::on_get_permanent_dialog_invite_link(DialogId dialog_id,
|
||||
const DialogInviteLink &invite_link) {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::Chat:
|
||||
return td_->contacts_manager_->on_update_chat_permanent_invite_link(dialog_id.get_chat_id(), invite_link);
|
||||
case DialogType::Channel:
|
||||
return td_->contacts_manager_->on_update_channel_permanent_invite_link(dialog_id.get_channel_id(), invite_link);
|
||||
case DialogType::User:
|
||||
case DialogType::SecretChat:
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
void DialogInviteLinkManager::export_dialog_invite_link(DialogId dialog_id, string title, int32 expire_date,
|
||||
int32 usage_limit, bool creates_join_request, bool is_permanent,
|
||||
Promise<td_api::object_ptr<td_api::chatInviteLink>> &&promise) {
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class DialogInviteLink;
|
||||
class Td;
|
||||
|
||||
class DialogInviteLinkManager final : public Actor {
|
||||
@ -47,6 +48,8 @@ class DialogInviteLinkManager final : public Actor {
|
||||
|
||||
td_api::object_ptr<td_api::chatInviteLinkInfo> get_chat_invite_link_info_object(const string &invite_link);
|
||||
|
||||
void on_get_permanent_dialog_invite_link(DialogId dialog_id, const DialogInviteLink &invite_link);
|
||||
|
||||
bool have_dialog_access_by_invite_link(DialogId dialog_id) const;
|
||||
|
||||
void remove_dialog_access_by_invite_link(DialogId dialog_id);
|
||||
|
Loading…
Reference in New Issue
Block a user