Move get_input_notify_peer to NotificationSettingsManager.
This commit is contained in:
parent
32ed470417
commit
80d57a493f
@ -20110,7 +20110,7 @@ void MessagesManager::update_dialog_notification_settings_on_server(DialogId dia
|
||||
return;
|
||||
}
|
||||
|
||||
if (!from_binlog && get_input_notify_peer(dialog_id) == nullptr) {
|
||||
if (!from_binlog && td_->notification_settings_manager_->get_input_notify_peer(dialog_id) == nullptr) {
|
||||
// don't even create new binlog events
|
||||
return;
|
||||
}
|
||||
@ -21249,17 +21249,6 @@ DialogNotificationSettings *MessagesManager::get_dialog_notification_settings(Di
|
||||
return &d->notification_settings;
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::InputNotifyPeer> MessagesManager::get_input_notify_peer(DialogId dialog_id) const {
|
||||
if (get_dialog(dialog_id) == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
auto input_peer = get_input_peer(dialog_id, AccessRights::Read);
|
||||
if (input_peer == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<telegram_api::inputNotifyPeer>(std::move(input_peer));
|
||||
}
|
||||
|
||||
Status MessagesManager::set_dialog_notification_settings(
|
||||
DialogId dialog_id, tl_object_ptr<td_api::chatNotificationSettings> &¬ification_settings) {
|
||||
CHECK(!td_->auth_manager_->is_bot());
|
||||
|
@ -846,8 +846,6 @@ class MessagesManager final : public Actor {
|
||||
void on_resolved_username(const string &username, DialogId dialog_id);
|
||||
void drop_username(const string &username);
|
||||
|
||||
tl_object_ptr<telegram_api::InputNotifyPeer> get_input_notify_peer(DialogId dialog_id) const;
|
||||
|
||||
void on_update_notification_scope_is_muted(NotificationSettingsScope scope, bool is_muted);
|
||||
|
||||
void on_update_dialog_notify_settings(DialogId dialog_id,
|
||||
|
@ -35,7 +35,7 @@ class GetDialogNotifySettingsQuery final : public Td::ResultHandler {
|
||||
public:
|
||||
void send(DialogId dialog_id) {
|
||||
dialog_id_ = dialog_id;
|
||||
auto input_notify_peer = td_->messages_manager_->get_input_notify_peer(dialog_id);
|
||||
auto input_notify_peer = td_->notification_settings_manager_->get_input_notify_peer(dialog_id);
|
||||
CHECK(input_notify_peer != nullptr);
|
||||
send_query(G()->net_query_creator().create(telegram_api::account_getNotifySettings(std::move(input_notify_peer))));
|
||||
}
|
||||
@ -164,7 +164,7 @@ class UpdateDialogNotifySettingsQuery final : public Td::ResultHandler {
|
||||
void send(DialogId dialog_id, const DialogNotificationSettings &new_settings) {
|
||||
dialog_id_ = dialog_id;
|
||||
|
||||
auto input_notify_peer = td_->messages_manager_->get_input_notify_peer(dialog_id);
|
||||
auto input_notify_peer = td_->notification_settings_manager_->get_input_notify_peer(dialog_id);
|
||||
if (input_notify_peer == nullptr) {
|
||||
return on_error(Status::Error(500, "Can't update chat notification settings"));
|
||||
}
|
||||
@ -208,7 +208,8 @@ class UpdateDialogNotifySettingsQuery final : public Td::ResultHandler {
|
||||
LOG(INFO) << "Receive error for set chat notification settings: " << status;
|
||||
}
|
||||
|
||||
if (!td_->auth_manager_->is_bot() && td_->messages_manager_->get_input_notify_peer(dialog_id_) != nullptr) {
|
||||
if (!td_->auth_manager_->is_bot() &&
|
||||
td_->notification_settings_manager_->get_input_notify_peer(dialog_id_) != nullptr) {
|
||||
// trying to repair notification settings for this dialog
|
||||
td_->notification_settings_manager_->send_get_dialog_notification_settings_query(dialog_id_, Promise<>());
|
||||
}
|
||||
@ -375,6 +376,18 @@ bool NotificationSettingsManager::get_scope_disable_mention_notifications(Notifi
|
||||
return get_scope_notification_settings(scope)->disable_mention_notifications;
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::InputNotifyPeer> NotificationSettingsManager::get_input_notify_peer(
|
||||
DialogId dialog_id) const {
|
||||
if (!td_->messages_manager_->have_dialog(dialog_id)) {
|
||||
return nullptr;
|
||||
}
|
||||
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
|
||||
if (input_peer == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return make_tl_object<telegram_api::inputNotifyPeer>(std::move(input_peer));
|
||||
}
|
||||
|
||||
ScopeNotificationSettings *NotificationSettingsManager::get_scope_notification_settings(
|
||||
NotificationSettingsScope scope) {
|
||||
switch (scope) {
|
||||
|
@ -40,6 +40,8 @@ class NotificationSettingsManager final : public Actor {
|
||||
|
||||
bool get_scope_disable_mention_notifications(NotificationSettingsScope scope) const;
|
||||
|
||||
tl_object_ptr<telegram_api::InputNotifyPeer> get_input_notify_peer(DialogId dialog_id) const;
|
||||
|
||||
void on_update_scope_notify_settings(NotificationSettingsScope scope,
|
||||
tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user