diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 9596343c3..251d69203 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1307,16 +1307,20 @@ notificationSettingsScopeChannelChats = NotificationSettingsScope; //@use_default_mute_for If true, mute_for is ignored and the value for the relevant type of chat or the forum chat is used instead //@mute_for Time left before notifications will be unmuted, in seconds //@use_default_sound If true, the value for the relevant type of chat or the forum chat is used instead of sound_id -//@sound_id Identifier of the notification sound to be played; 0 if sound is disabled +//@sound_id Identifier of the notification sound to be played for messages; 0 if sound is disabled //@use_default_show_preview If true, show_preview is ignored and the value for the relevant type of chat or the forum chat is used instead //@show_preview True, if message content must be displayed in notifications //@use_default_mute_stories If true, mute_stories is ignored and the value for the relevant type of chat is used instead //@mute_stories True, if story notifications are received without sound +//@use_default_story_sound If true, the value for the relevant type of chat is used instead of story_sound_id +//@story_sound_id Identifier of the notification sound to be played for stories; 0 if sound is disabled +//@use_default_show_story_sender If true, show_story_sender is ignored and the value for the relevant type of chat is used instead +//@show_story_sender True, if the sender of stories must be displayed in notifications //@use_default_disable_pinned_message_notifications If true, disable_pinned_message_notifications is ignored and the value for the relevant type of chat or the forum chat is used instead //@disable_pinned_message_notifications If true, notifications for incoming pinned messages will be created as for an ordinary unread message //@use_default_disable_mention_notifications If true, disable_mention_notifications is ignored and the value for the relevant type of chat or the forum chat is used instead //@disable_mention_notifications If true, notifications for messages with mentions will be created as for an ordinary unread message -chatNotificationSettings use_default_mute_for:Bool mute_for:int32 use_default_sound:Bool sound_id:int64 use_default_show_preview:Bool show_preview:Bool use_default_mute_stories:Bool mute_stories:Bool use_default_disable_pinned_message_notifications:Bool disable_pinned_message_notifications:Bool use_default_disable_mention_notifications:Bool disable_mention_notifications:Bool = ChatNotificationSettings; +chatNotificationSettings use_default_mute_for:Bool mute_for:int32 use_default_sound:Bool sound_id:int64 use_default_show_preview:Bool show_preview:Bool use_default_mute_stories:Bool mute_stories:Bool use_default_story_sound:Bool story_sound_id:int64 use_default_show_story_sender:Bool show_story_sender:Bool use_default_disable_pinned_message_notifications:Bool disable_pinned_message_notifications:Bool use_default_disable_mention_notifications:Bool disable_mention_notifications:Bool = ChatNotificationSettings; //@description Contains information about notification settings for several chats //@mute_for Time left before notifications will be unmuted, in seconds @@ -1324,7 +1328,7 @@ chatNotificationSettings use_default_mute_for:Bool mute_for:int32 use_default_so //@show_preview True, if message content must be displayed in notifications //@mute_stories True, if story notifications are received without sound //@story_sound_id Identifier of the notification sound to be played for stories; 0 if sound is disabled -//@show_story_sender True, if the sender of the story must be displayed in notifications +//@show_story_sender True, if the sender of stories must be displayed in notifications //@disable_pinned_message_notifications True, if notifications for incoming pinned messages will be created as for an ordinary unread message //@disable_mention_notifications True, if notifications for messages with mentions will be created as for an ordinary unread message scopeNotificationSettings mute_for:int32 sound_id:int64 show_preview:Bool mute_stories:Bool story_sound_id:int64 show_story_sender:Bool disable_pinned_message_notifications:Bool disable_mention_notifications:Bool = ScopeNotificationSettings; diff --git a/td/telegram/DialogNotificationSettings.cpp b/td/telegram/DialogNotificationSettings.cpp index 508036313..359220e5b 100644 --- a/td/telegram/DialogNotificationSettings.cpp +++ b/td/telegram/DialogNotificationSettings.cpp @@ -27,23 +27,31 @@ DialogNotificationSettings::get_input_peer_notify_settings() const { if (!use_default_mute_stories) { flags |= telegram_api::inputPeerNotifySettings::STORIES_MUTED_MASK; } + if (story_sound != nullptr) { + flags |= telegram_api::inputPeerNotifySettings::STORIES_SOUND_MASK; + } + if (!use_default_hide_story_sender) { + flags |= telegram_api::inputPeerNotifySettings::STORIES_HIDE_SENDER_MASK; + } if (silent_send_message) { flags |= telegram_api::inputPeerNotifySettings::SILENT_MASK; } return telegram_api::make_object( - flags, show_preview, silent_send_message, mute_until, get_input_notification_sound(sound), mute_stories, false, - nullptr); + flags, show_preview, silent_send_message, mute_until, get_input_notification_sound(sound), mute_stories, + hide_story_sender, get_input_notification_sound(story_sound)); } StringBuilder &operator<<(StringBuilder &string_builder, const DialogNotificationSettings ¬ification_settings) { return string_builder << "[" << notification_settings.mute_until << ", " << notification_settings.sound << ", " << notification_settings.show_preview << ", " << notification_settings.mute_stories << ", " + << notification_settings.story_sound << ", " << notification_settings.hide_story_sender << ", " << notification_settings.silent_send_message << ", " << notification_settings.disable_pinned_message_notifications << ", " << notification_settings.disable_mention_notifications << ", " << notification_settings.use_default_mute_until << ", " << notification_settings.use_default_show_preview << ", " << notification_settings.use_default_mute_stories << ", " + << notification_settings.use_default_hide_story_sender << ", " << notification_settings.use_default_disable_pinned_message_notifications << ", " << notification_settings.use_default_disable_mention_notifications << ", " << notification_settings.is_synchronized << "]"; @@ -57,7 +65,10 @@ td_api::object_ptr get_chat_notification_setti is_notification_sound_default(notification_settings->sound), get_notification_sound_ringtone_id(notification_settings->sound), notification_settings->use_default_show_preview, notification_settings->show_preview, notification_settings->use_default_mute_stories, - notification_settings->mute_stories, notification_settings->use_default_disable_pinned_message_notifications, + notification_settings->mute_stories, is_notification_sound_default(notification_settings->story_sound), + get_notification_sound_ringtone_id(notification_settings->story_sound), + notification_settings->use_default_hide_story_sender, !notification_settings->hide_story_sender, + notification_settings->use_default_disable_pinned_message_notifications, notification_settings->disable_pinned_message_notifications, notification_settings->use_default_disable_mention_notifications, notification_settings->disable_mention_notifications); @@ -92,11 +103,19 @@ Result get_dialog_notification_settings( if (is_notification_sound_default(old_settings->sound) && is_notification_sound_default(notification_sound)) { notification_sound = dup_notification_sound(old_settings->sound); } + auto story_notification_sound = + get_notification_sound(notification_settings->use_default_story_sound_, notification_settings->story_sound_id_); + if (is_notification_sound_default(old_settings->story_sound) && + is_notification_sound_default(story_notification_sound)) { + story_notification_sound = dup_notification_sound(old_settings->story_sound); + } return DialogNotificationSettings( notification_settings->use_default_mute_for_, mute_until, std::move(notification_sound), notification_settings->use_default_show_preview_, notification_settings->show_preview_, notification_settings->use_default_mute_stories_, notification_settings->mute_stories_, - old_settings->silent_send_message, notification_settings->use_default_disable_pinned_message_notifications_, + std::move(story_notification_sound), notification_settings->use_default_show_story_sender_, + !notification_settings->show_story_sender_, old_settings->silent_send_message, + notification_settings->use_default_disable_pinned_message_notifications_, notification_settings->disable_pinned_message_notifications_, notification_settings->use_default_disable_mention_notifications_, notification_settings->disable_mention_notifications_); @@ -128,6 +147,8 @@ DialogNotificationSettings get_dialog_notification_settings(tl_object_ptrflags_ & telegram_api::peerNotifySettings::MUTE_UNTIL_MASK) == 0; bool use_default_show_preview = (settings->flags_ & telegram_api::peerNotifySettings::SHOW_PREVIEWS_MASK) == 0; bool use_default_mute_stories = (settings->flags_ & telegram_api::peerNotifySettings::STORIES_MUTED_MASK) == 0; + bool use_default_hide_story_sender = + (settings->flags_ & telegram_api::peerNotifySettings::STORIES_HIDE_SENDER_MASK) == 0; auto mute_until = use_default_mute_until || settings->mute_until_ <= G()->unix_time() ? 0 : settings->mute_until_; bool silent_send_message = settings->silent_; return {use_default_mute_until, @@ -137,6 +158,9 @@ DialogNotificationSettings get_dialog_notification_settings(tl_object_ptrshow_previews_, use_default_mute_stories, settings->stories_muted_, + get_notification_sound(settings.get(), true), + use_default_hide_story_sender, + settings->stories_hide_sender_, silent_send_message, old_use_default_disable_pinned_message_notifications, old_disable_pinned_message_notifications, @@ -147,20 +171,25 @@ DialogNotificationSettings get_dialog_notification_settings(tl_object_ptrmute_until != new_settings.mute_until || - !are_equivalent_notification_sounds(current_settings->sound, new_settings.sound) || - current_settings->show_preview != new_settings.show_preview || - current_settings->mute_stories != new_settings.mute_stories || - current_settings->use_default_mute_until != new_settings.use_default_mute_until || - current_settings->use_default_show_preview != new_settings.use_default_show_preview || - current_settings->use_default_mute_stories != new_settings.use_default_mute_stories; + result.need_update_server = + current_settings->mute_until != new_settings.mute_until || + !are_equivalent_notification_sounds(current_settings->sound, new_settings.sound) || + !are_equivalent_notification_sounds(current_settings->story_sound, new_settings.story_sound) || + current_settings->show_preview != new_settings.show_preview || + current_settings->mute_stories != new_settings.mute_stories || + current_settings->hide_story_sender != new_settings.hide_story_sender || + current_settings->use_default_mute_until != new_settings.use_default_mute_until || + current_settings->use_default_show_preview != new_settings.use_default_show_preview || + current_settings->use_default_mute_stories != new_settings.use_default_mute_stories || + current_settings->use_default_hide_story_sender != new_settings.use_default_hide_story_sender; result.need_update_local = current_settings->use_default_disable_pinned_message_notifications != new_settings.use_default_disable_pinned_message_notifications || @@ -168,10 +197,12 @@ NeedUpdateDialogNotificationSettings need_update_dialog_notification_settings( current_settings->use_default_disable_mention_notifications != new_settings.use_default_disable_mention_notifications || current_settings->disable_mention_notifications != new_settings.disable_mention_notifications; - result.are_changed = result.need_update_server || result.need_update_local || - current_settings->is_synchronized != new_settings.is_synchronized || - current_settings->is_use_default_fixed != new_settings.is_use_default_fixed || - are_different_equivalent_notification_sounds(current_settings->sound, new_settings.sound); + result.are_changed = + result.need_update_server || result.need_update_local || + current_settings->is_synchronized != new_settings.is_synchronized || + current_settings->is_use_default_fixed != new_settings.is_use_default_fixed || + are_different_equivalent_notification_sounds(current_settings->sound, new_settings.sound) || + are_different_equivalent_notification_sounds(current_settings->story_sound, new_settings.story_sound); return result; } diff --git a/td/telegram/DialogNotificationSettings.h b/td/telegram/DialogNotificationSettings.h index e2d6d6da9..dd1f135ff 100644 --- a/td/telegram/DialogNotificationSettings.h +++ b/td/telegram/DialogNotificationSettings.h @@ -20,12 +20,15 @@ class DialogNotificationSettings { public: int32 mute_until = 0; unique_ptr sound; + unique_ptr story_sound; bool show_preview = true; bool mute_stories = false; + bool hide_story_sender = false; bool silent_send_message = false; bool use_default_mute_until = true; bool use_default_show_preview = true; bool use_default_mute_stories = true; + bool use_default_hide_story_sender = true; bool is_use_default_fixed = true; bool is_secret_chat_show_preview_fixed = false; bool is_synchronized = false; @@ -40,18 +43,22 @@ class DialogNotificationSettings { DialogNotificationSettings(bool use_default_mute_until, int32 mute_until, unique_ptr &&sound, bool use_default_show_preview, bool show_preview, bool use_default_mute_stories, - bool mute_stories, bool silent_send_message, + bool mute_stories, unique_ptr &&story_sound, + bool use_default_hide_story_sender, bool hide_story_sender, bool silent_send_message, bool use_default_disable_pinned_message_notifications, bool disable_pinned_message_notifications, bool use_default_disable_mention_notifications, bool disable_mention_notifications) : mute_until(mute_until) , sound(std::move(sound)) + , story_sound(std::move(story_sound)) , show_preview(show_preview) , mute_stories(mute_stories) + , hide_story_sender(hide_story_sender) , silent_send_message(silent_send_message) , use_default_mute_until(use_default_mute_until) , use_default_show_preview(use_default_show_preview) , use_default_mute_stories(use_default_mute_stories) + , use_default_hide_story_sender(use_default_hide_story_sender) , is_synchronized(true) , use_default_disable_pinned_message_notifications(use_default_disable_pinned_message_notifications) , disable_pinned_message_notifications(disable_pinned_message_notifications) diff --git a/td/telegram/DialogNotificationSettings.hpp b/td/telegram/DialogNotificationSettings.hpp index 722ac06ec..2ed6d70a6 100644 --- a/td/telegram/DialogNotificationSettings.hpp +++ b/td/telegram/DialogNotificationSettings.hpp @@ -21,6 +21,8 @@ void store(const DialogNotificationSettings ¬ification_settings, StorerT &sto bool has_sound = notification_settings.sound != nullptr; bool has_ringtone_support = true; bool use_mute_stories = !notification_settings.use_default_mute_stories; + bool has_story_sound = notification_settings.story_sound != nullptr; + bool use_hide_story_sender = !notification_settings.use_default_hide_story_sender; BEGIN_STORE_FLAGS(); STORE_FLAG(is_muted); STORE_FLAG(has_sound); @@ -39,6 +41,9 @@ void store(const DialogNotificationSettings ¬ification_settings, StorerT &sto STORE_FLAG(has_ringtone_support); STORE_FLAG(notification_settings.mute_stories); STORE_FLAG(use_mute_stories); + STORE_FLAG(has_story_sound); + STORE_FLAG(notification_settings.hide_story_sender); + STORE_FLAG(use_hide_story_sender); END_STORE_FLAGS(); if (is_muted) { store(notification_settings.mute_until, storer); @@ -46,6 +51,9 @@ void store(const DialogNotificationSettings ¬ification_settings, StorerT &sto if (has_sound) { store(notification_settings.sound, storer); } + if (has_story_sound) { + store(notification_settings.story_sound, storer); + } } template @@ -57,6 +65,8 @@ void parse(DialogNotificationSettings ¬ification_settings, ParserT &parser) { bool use_disable_mention_notifications; bool has_ringtone_support; bool use_mute_stories; + bool has_story_sound; + bool use_hide_story_sender; BEGIN_PARSE_FLAGS(); PARSE_FLAG(is_muted); PARSE_FLAG(has_sound); @@ -75,10 +85,14 @@ void parse(DialogNotificationSettings ¬ification_settings, ParserT &parser) { PARSE_FLAG(has_ringtone_support); PARSE_FLAG(notification_settings.mute_stories); PARSE_FLAG(use_mute_stories); + PARSE_FLAG(has_story_sound); + PARSE_FLAG(notification_settings.hide_story_sender); + PARSE_FLAG(use_hide_story_sender); END_PARSE_FLAGS(); notification_settings.use_default_disable_pinned_message_notifications = !use_disable_pinned_message_notifications; notification_settings.use_default_disable_mention_notifications = !use_disable_mention_notifications; notification_settings.use_default_mute_stories = !use_mute_stories; + notification_settings.use_default_hide_story_sender = !use_hide_story_sender; if (is_muted) { parse(notification_settings.mute_until, parser); } @@ -91,6 +105,9 @@ void parse(DialogNotificationSettings ¬ification_settings, ParserT &parser) { notification_settings.sound = use_default_sound ? nullptr : get_legacy_notification_sound(sound); } } + if (has_story_sound) { + parse_notification_sound(notification_settings.story_sound, parser); + } } } // namespace td diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 65041b723..784aca478 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -36378,8 +36378,9 @@ void MessagesManager::force_create_dialog(DialogId dialog_id, const char *source auto new_notification_settings = DialogNotificationSettings( user_settings->use_default_mute_until, user_settings->mute_until, dup_notification_sound(user_settings->sound), true /*use_default_show_preview*/, false /*show_preview*/, - user_settings->use_default_mute_stories, user_settings->mute_stories, user_settings->silent_send_message, - true, false, true, false); + user_settings->use_default_mute_stories, user_settings->mute_stories, + dup_notification_sound(user_settings->story_sound), user_settings->use_default_hide_story_sender, + user_settings->hide_story_sender, user_settings->silent_send_message, true, false, true, false); new_notification_settings.is_secret_chat_show_preview_fixed = true; update_dialog_notification_settings(dialog_id, &d->notification_settings, std::move(new_notification_settings)); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 57bfc15a7..0ec33a58b 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -5520,8 +5520,8 @@ class CliClient final : public Actor { string hide_story_sender; string disable_pinned_message_notifications; string disable_mention_notifications; - get_args(args, scope, mute_for, sound_id, show_preview, mute_stories, disable_pinned_message_notifications, - disable_mention_notifications); + get_args(args, scope, mute_for, sound_id, show_preview, mute_stories, story_sound_id, hide_story_sender, + disable_pinned_message_notifications, disable_mention_notifications); if (op == "ssns") { send_request(td_api::make_object( as_notification_settings_scope(scope), @@ -5532,9 +5532,10 @@ class CliClient final : public Actor { } else { auto settings = td_api::make_object( mute_for.empty(), to_integer(mute_for), sound_id == -1, sound_id, show_preview.empty(), - as_bool(show_preview), mute_stories.empty(), as_bool(mute_stories), - disable_pinned_message_notifications.empty(), as_bool(disable_pinned_message_notifications), - disable_mention_notifications.empty(), as_bool(disable_mention_notifications)); + as_bool(show_preview), mute_stories.empty(), as_bool(mute_stories), story_sound_id == -1, story_sound_id, + hide_story_sender.empty(), as_bool(hide_story_sender), disable_pinned_message_notifications.empty(), + as_bool(disable_pinned_message_notifications), disable_mention_notifications.empty(), + as_bool(disable_mention_notifications)); if (op == "scns") { send_request( td_api::make_object(as_chat_id(scope), std::move(settings)));