Add and use ScopeNotificationSettings::get_input_peer_notify_settings.

This commit is contained in:
levlam 2023-06-09 15:08:00 +03:00
parent d51ad4f4e9
commit bd4004e0be
3 changed files with 14 additions and 8 deletions

View File

@ -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<telegram_api::inputPeerNotifySettings>(
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;
}

View File

@ -12,6 +12,17 @@
namespace td {
telegram_api::object_ptr<telegram_api::inputPeerNotifySettings>
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<telegram_api::inputPeerNotifySettings>(
flags, show_preview, false, mute_until, get_input_notification_sound(sound), false, false, nullptr);
}
StringBuilder &operator<<(StringBuilder &string_builder, const ScopeNotificationSettings &notification_settings) {
return string_builder << "[" << notification_settings.mute_until << ", " << notification_settings.sound << ", "
<< notification_settings.show_preview << ", " << notification_settings.is_synchronized << ", "

View File

@ -38,6 +38,8 @@ class ScopeNotificationSettings {
, disable_pinned_message_notifications(disable_pinned_message_notifications)
, disable_mention_notifications(disable_mention_notifications) {
}
telegram_api::object_ptr<telegram_api::inputPeerNotifySettings> get_input_peer_notify_settings() const;
};
StringBuilder &operator<<(StringBuilder &string_builder, const ScopeNotificationSettings &notification_settings);