Add source to on_update_dialog_notify_settings.

GitOrigin-RevId: a3b6d44d6e4b07ab05f564180ad071c15a6c49b6
This commit is contained in:
levlam 2019-02-20 04:30:22 +03:00
parent eeceb2c1aa
commit 9d3bfaa979
4 changed files with 19 additions and 14 deletions

View File

@ -6410,7 +6410,8 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
}
on_update_user_links(user_id, std::move(user_full->link_->my_link_), std::move(user_full->link_->foreign_link_));
td_->messages_manager_->on_update_dialog_notify_settings(DialogId(user_id), std::move(user_full->notify_settings_));
td_->messages_manager_->on_update_dialog_notify_settings(DialogId(user_id), std::move(user_full->notify_settings_),
"on_get_user_full");
MessageId pinned_message_id;
if ((user_full->flags_ & USER_FULL_FLAG_HAS_PINNED_MESSAGE) != 0) {
@ -6624,7 +6625,8 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
}
on_get_chat_participants(std::move(chat_full->participants_));
td_->messages_manager_->on_update_dialog_notify_settings(DialogId(chat_id), std::move(chat_full->notify_settings_));
td_->messages_manager_->on_update_dialog_notify_settings(DialogId(chat_id), std::move(chat_full->notify_settings_),
"on_get_chat_full");
update_chat_full(chat, chat_id);
} else {
@ -6636,8 +6638,8 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
return;
}
td_->messages_manager_->on_update_dialog_notify_settings(DialogId(channel_id),
std::move(channel_full->notify_settings_));
td_->messages_manager_->on_update_dialog_notify_settings(
DialogId(channel_id), std::move(channel_full->notify_settings_), "on_get_channel_full");
// Ignoring channel_full->photo

View File

@ -2828,7 +2828,7 @@ class GetDialogNotifySettingsQuery : public Td::ResultHandler {
}
auto ptr = result_ptr.move_as_ok();
td->messages_manager_->on_update_dialog_notify_settings(dialog_id_, std::move(ptr));
td->messages_manager_->on_update_dialog_notify_settings(dialog_id_, std::move(ptr), "GetDialogNotifySettingsQuery");
td->messages_manager_->on_get_dialog_notification_settings_query_finished(dialog_id_, Status::OK());
}
@ -5846,12 +5846,13 @@ void MessagesManager::on_scope_unmute(NotificationSettingsScope scope) {
}
void MessagesManager::on_update_dialog_notify_settings(
DialogId dialog_id, tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings) {
DialogId dialog_id, tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings, const char *source) {
if (td_->auth_manager_->is_bot()) {
return;
}
VLOG(notifications) << "Receive notification settings for " << dialog_id << ": " << to_string(peer_notify_settings);
VLOG(notifications) << "Receive notification settings for " << dialog_id << " from " << source << ": "
<< to_string(peer_notify_settings);
DialogNotificationSettings *current_settings = get_dialog_notification_settings(dialog_id, true);
if (current_settings == nullptr) {
@ -10275,7 +10276,7 @@ void MessagesManager::on_get_dialogs(vector<tl_object_ptr<telegram_api::dialog>>
}
bool is_new = d->last_new_message_id == MessageId();
on_update_dialog_notify_settings(dialog_id, std::move(dialog->notify_settings_));
on_update_dialog_notify_settings(dialog_id, std::move(dialog->notify_settings_), "on_get_dialogs");
if (!d->notification_settings.is_synchronized) {
LOG(ERROR) << "Failed to synchronize settings in " << dialog_id;
d->notification_settings.is_synchronized = true;
@ -12422,8 +12423,8 @@ DialogId MessagesManager::create_new_group_chat(const vector<UserId> &user_ids,
created_dialogs_.erase(it);
// set default notification settings to newly created chat
on_update_dialog_notify_settings(dialog_id,
make_tl_object<telegram_api::peerNotifySettings>(0, false, false, 0, ""));
on_update_dialog_notify_settings(
dialog_id, make_tl_object<telegram_api::peerNotifySettings>(0, false, false, 0, ""), "create_new_group_chat");
promise.set_value(Unit());
return dialog_id;
@ -12475,8 +12476,8 @@ DialogId MessagesManager::create_new_channel_chat(const string &title, bool is_m
created_dialogs_.erase(it);
// set default notification settings to newly created chat
on_update_dialog_notify_settings(dialog_id,
make_tl_object<telegram_api::peerNotifySettings>(0, false, false, 0, ""));
on_update_dialog_notify_settings(
dialog_id, make_tl_object<telegram_api::peerNotifySettings>(0, false, false, 0, ""), "create_new_channel_chat");
promise.set_value(Unit());
return dialog_id;

View File

@ -608,7 +608,8 @@ class MessagesManager : public Actor {
tl_object_ptr<telegram_api::InputNotifyPeer> get_input_notify_peer(DialogId dialogId) const;
void on_update_dialog_notify_settings(DialogId dialog_id,
tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings);
tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings,
const char *source);
void on_update_scope_notify_settings(NotificationSettingsScope scope,
tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings);

View File

@ -1524,7 +1524,8 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateNotifySettings>
case telegram_api::notifyPeer::ID: {
DialogId dialog_id(static_cast<const telegram_api::notifyPeer *>(update->peer_.get())->peer_);
if (dialog_id.is_valid()) {
td_->messages_manager_->on_update_dialog_notify_settings(dialog_id, std::move(update->notify_settings_));
td_->messages_manager_->on_update_dialog_notify_settings(dialog_id, std::move(update->notify_settings_),
"updateNotifySettings");
} else {
LOG(ERROR) << "Receive wrong " << to_string(update);
}