Add scopeNotificationSettings.mute_stories.

This commit is contained in:
levlam 2023-06-12 19:41:18 +03:00
parent 686f0eabe6
commit 0791baa6c1
6 changed files with 22 additions and 12 deletions

View File

@ -1319,9 +1319,10 @@ chatNotificationSettings use_default_mute_for:Bool mute_for:int32 use_default_so
//@mute_for Time left before notifications will be unmuted, in seconds
//@sound_id Identifier of the notification sound to be played; 0 if sound is disabled
//@show_preview True, if message content must be displayed in notifications
//@mute_stories True, if story notifications are received without sound
//@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 disable_pinned_message_notifications:Bool disable_mention_notifications:Bool = ScopeNotificationSettings;
scopeNotificationSettings mute_for:int32 sound_id:int64 show_preview:Bool mute_stories:Bool disable_pinned_message_notifications:Bool disable_mention_notifications:Bool = ScopeNotificationSettings;
//@description Contains information about a message draft

View File

@ -540,7 +540,7 @@ void NotificationSettingsManager::init() {
if (!channels_notification_settings_.is_synchronized && is_authorized) {
channels_notification_settings_ = ScopeNotificationSettings(
chats_notification_settings_.mute_until, dup_notification_sound(chats_notification_settings_.sound),
chats_notification_settings_.show_preview, false, false);
chats_notification_settings_.show_preview, chats_notification_settings_.mute_stories, false, false);
channels_notification_settings_.is_synchronized = false;
send_get_scope_notification_settings_query(NotificationSettingsScope::Channel, Promise<>());
}

View File

@ -15,17 +15,19 @@ 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;
telegram_api::inputPeerNotifySettings::SHOW_PREVIEWS_MASK |
telegram_api::inputPeerNotifySettings::STORIES_MUTED_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);
flags, show_preview, false, mute_until, get_input_notification_sound(sound), mute_stories, 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 << ", "
<< notification_settings.show_preview << ", " << notification_settings.mute_stories << ", "
<< notification_settings.is_synchronized << ", "
<< notification_settings.disable_pinned_message_notifications << ", "
<< notification_settings.disable_mention_notifications << "]";
}
@ -36,7 +38,7 @@ td_api::object_ptr<td_api::scopeNotificationSettings> get_scope_notification_set
return td_api::make_object<td_api::scopeNotificationSettings>(
max(0, notification_settings->mute_until - G()->unix_time()),
get_notification_sound_ringtone_id(notification_settings->sound), notification_settings->show_preview,
notification_settings->disable_pinned_message_notifications,
notification_settings->mute_stories, notification_settings->disable_pinned_message_notifications,
notification_settings->disable_mention_notifications);
}
@ -61,7 +63,7 @@ Result<ScopeNotificationSettings> get_scope_notification_settings(
auto mute_until = get_mute_until(notification_settings->mute_for_);
return ScopeNotificationSettings(mute_until, get_notification_sound(false, notification_settings->sound_id_),
notification_settings->show_preview_,
notification_settings->show_preview_, notification_settings->mute_stories_,
notification_settings->disable_pinned_message_notifications_,
notification_settings->disable_mention_notifications_);
}
@ -77,8 +79,9 @@ ScopeNotificationSettings get_scope_notification_settings(tl_object_ptr<telegram
mute_until = 0;
}
auto show_preview = settings->show_previews_;
return {mute_until, get_notification_sound(settings.get()), show_preview, old_disable_pinned_message_notifications,
old_disable_mention_notifications};
auto mute_stories = settings->stories_muted_;
return {mute_until, get_notification_sound(settings.get()), show_preview,
mute_stories, old_disable_pinned_message_notifications, old_disable_mention_notifications};
}
} // namespace td

View File

@ -21,6 +21,7 @@ class ScopeNotificationSettings {
int32 mute_until = 0;
unique_ptr<NotificationSound> sound;
bool show_preview = true;
bool mute_stories = false;
bool is_synchronized = false;
// local settings
@ -30,10 +31,12 @@ class ScopeNotificationSettings {
ScopeNotificationSettings() = default;
ScopeNotificationSettings(int32 mute_until, unique_ptr<NotificationSound> &&sound, bool show_preview,
bool disable_pinned_message_notifications, bool disable_mention_notifications)
bool mute_stories, bool disable_pinned_message_notifications,
bool disable_mention_notifications)
: mute_until(mute_until)
, sound(std::move(sound))
, show_preview(show_preview)
, mute_stories(mute_stories)
, is_synchronized(true)
, disable_pinned_message_notifications(disable_pinned_message_notifications)
, disable_mention_notifications(disable_mention_notifications) {

View File

@ -28,6 +28,7 @@ void store(const ScopeNotificationSettings &notification_settings, StorerT &stor
STORE_FLAG(notification_settings.disable_pinned_message_notifications);
STORE_FLAG(notification_settings.disable_mention_notifications);
STORE_FLAG(has_ringtone_support);
STORE_FLAG(notification_settings.mute_stories);
END_STORE_FLAGS();
if (is_muted) {
store(notification_settings.mute_until, storer);
@ -52,6 +53,7 @@ void parse(ScopeNotificationSettings &notification_settings, ParserT &parser) {
PARSE_FLAG(notification_settings.disable_pinned_message_notifications);
PARSE_FLAG(notification_settings.disable_mention_notifications);
PARSE_FLAG(has_ringtone_support);
PARSE_FLAG(notification_settings.mute_stories);
END_PARSE_FLAGS();
(void)silent_send_message_ignored;
if (is_muted) {

View File

@ -5487,15 +5487,16 @@ class CliClient final : public Actor {
string mute_for;
int64 sound_id;
string show_preview;
string mute_stories;
string disable_pinned_message_notifications;
string disable_mention_notifications;
get_args(args, scope, mute_for, sound_id, show_preview, disable_pinned_message_notifications,
get_args(args, scope, mute_for, sound_id, show_preview, mute_stories, disable_pinned_message_notifications,
disable_mention_notifications);
if (op == "ssns") {
send_request(td_api::make_object<td_api::setScopeNotificationSettings>(
as_notification_settings_scope(scope),
td_api::make_object<td_api::scopeNotificationSettings>(
to_integer<int32>(mute_for), sound_id, as_bool(show_preview),
to_integer<int32>(mute_for), sound_id, as_bool(show_preview), as_bool(mute_stories),
as_bool(disable_pinned_message_notifications), as_bool(disable_mention_notifications))));
} else {
auto settings = td_api::make_object<td_api::chatNotificationSettings>(