From bd4004e0be0218dcfa89945dd26f32d6814e3e80 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 9 Jun 2023 15:08:00 +0300 Subject: [PATCH] Add and use ScopeNotificationSettings::get_input_peer_notify_settings. --- td/telegram/NotificationSettingsManager.cpp | 9 +-------- td/telegram/ScopeNotificationSettings.cpp | 11 +++++++++++ td/telegram/ScopeNotificationSettings.h | 2 ++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/td/telegram/NotificationSettingsManager.cpp b/td/telegram/NotificationSettingsManager.cpp index e304be3a3..e15490635 100644 --- a/td/telegram/NotificationSettingsManager.cpp +++ b/td/telegram/NotificationSettingsManager.cpp @@ -395,15 +395,8 @@ class UpdateScopeNotifySettingsQuery final : public Td::ResultHandler { void send(NotificationSettingsScope scope, const ScopeNotificationSettings &new_settings) { auto input_notify_peer = get_input_notify_peer(scope); CHECK(input_notify_peer != nullptr); - int32 flags = telegram_api::inputPeerNotifySettings::MUTE_UNTIL_MASK | - telegram_api::inputPeerNotifySettings::SHOW_PREVIEWS_MASK; - if (new_settings.sound != nullptr) { - flags |= telegram_api::inputPeerNotifySettings::SOUND_MASK; - } send_query(G()->net_query_creator().create(telegram_api::account_updateNotifySettings( - std::move(input_notify_peer), make_tl_object( - flags, new_settings.show_preview, false, new_settings.mute_until, - get_input_notification_sound(new_settings.sound), false, false, nullptr)))); + std::move(input_notify_peer), new_settings.get_input_peer_notify_settings()))); scope_ = scope; } diff --git a/td/telegram/ScopeNotificationSettings.cpp b/td/telegram/ScopeNotificationSettings.cpp index 2e1216133..e664ab7aa 100644 --- a/td/telegram/ScopeNotificationSettings.cpp +++ b/td/telegram/ScopeNotificationSettings.cpp @@ -12,6 +12,17 @@ namespace td { +telegram_api::object_ptr +ScopeNotificationSettings::get_input_peer_notify_settings() const { + int32 flags = telegram_api::inputPeerNotifySettings::MUTE_UNTIL_MASK | + telegram_api::inputPeerNotifySettings::SHOW_PREVIEWS_MASK; + if (sound != nullptr) { + flags |= telegram_api::inputPeerNotifySettings::SOUND_MASK; + } + return telegram_api::make_object( + flags, show_preview, false, mute_until, get_input_notification_sound(sound), false, false, nullptr); +} + StringBuilder &operator<<(StringBuilder &string_builder, const ScopeNotificationSettings ¬ification_settings) { return string_builder << "[" << notification_settings.mute_until << ", " << notification_settings.sound << ", " << notification_settings.show_preview << ", " << notification_settings.is_synchronized << ", " diff --git a/td/telegram/ScopeNotificationSettings.h b/td/telegram/ScopeNotificationSettings.h index f6a59caea..74eecde6e 100644 --- a/td/telegram/ScopeNotificationSettings.h +++ b/td/telegram/ScopeNotificationSettings.h @@ -38,6 +38,8 @@ class ScopeNotificationSettings { , disable_pinned_message_notifications(disable_pinned_message_notifications) , disable_mention_notifications(disable_mention_notifications) { } + + telegram_api::object_ptr get_input_peer_notify_settings() const; }; StringBuilder &operator<<(StringBuilder &string_builder, const ScopeNotificationSettings ¬ification_settings);