From bafb4f91b46bce0466d53502e7554a799fe563cc Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 9 Jun 2023 19:31:51 +0400 Subject: [PATCH] Update API scheme on layer 160. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/apiwrap.cpp | 3 +- .../data/notify/data_notify_settings.cpp | 29 ++++++--- .../data/notify/data_notify_settings.h | 9 ++- .../data/notify/data_peer_notify_settings.cpp | 61 +++++++++++++------ .../data/notify/data_peer_notify_settings.h | 3 +- .../dialogs/ui/dialogs_stories_content.cpp | 5 +- Telegram/SourceFiles/mtproto/scheme/api.tl | 6 +- 8 files changed, 82 insertions(+), 35 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 154400cb6..c29a21018 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3790,6 +3790,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_userpic_builder_color_subtitle" = "Choose background"; "lng_userpic_builder_emoji_subtitle" = "Choose sticker or emoji"; +"lng_stories_my_name" = "My Story"; "lng_stories_hide_to_contacts" = "Archive"; "lng_stories_show_in_chats" = "Unarchive"; "lng_stories_row_count#one" = "{count} Story"; diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 7840bdcfa..922407988 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -1804,7 +1804,8 @@ void ApiWrap::requestNotifySettings(const MTPInputNotifyPeer &peer) { MTPint(), MTPNotificationSound(), MTPNotificationSound(), - MTPNotificationSound())); + MTPNotificationSound(), + MTPBool())); _notifySettingRequests.erase(key); }).send(); _notifySettingRequests.emplace(key, requestId); diff --git a/Telegram/SourceFiles/data/notify/data_notify_settings.cpp b/Telegram/SourceFiles/data/notify/data_notify_settings.cpp index cee0afe8a..3beba423d 100644 --- a/Telegram/SourceFiles/data/notify/data_notify_settings.cpp +++ b/Telegram/SourceFiles/data/notify/data_notify_settings.cpp @@ -174,8 +174,13 @@ void NotifySettings::update( not_null thread, Data::MuteValue muteForSeconds, std::optional silentPosts, - std::optional sound) { - if (thread->notify().change(muteForSeconds, silentPosts, sound)) { + std::optional sound, + std::optional storiesMuted) { + if (thread->notify().change( + muteForSeconds, + silentPosts, + sound, + storiesMuted)) { updateLocal(thread); thread->session().api().updateNotifySettingsDelayed(thread); } @@ -189,7 +194,8 @@ void NotifySettings::resetToDefault(not_null thread) { MTPint(), MTPNotificationSound(), MTPNotificationSound(), - MTPNotificationSound()); + MTPNotificationSound(), + MTPBool()); if (thread->notify().change(empty)) { updateLocal(thread); thread->session().api().updateNotifySettingsDelayed(thread); @@ -200,8 +206,13 @@ void NotifySettings::update( not_null peer, Data::MuteValue muteForSeconds, std::optional silentPosts, - std::optional sound) { - if (peer->notify().change(muteForSeconds, silentPosts, sound)) { + std::optional sound, + std::optional storiesMuted) { + if (peer->notify().change( + muteForSeconds, + silentPosts, + sound, + storiesMuted)) { updateLocal(peer); peer->session().api().updateNotifySettingsDelayed(peer); } @@ -215,7 +226,8 @@ void NotifySettings::resetToDefault(not_null peer) { MTPint(), MTPNotificationSound(), MTPNotificationSound(), - MTPNotificationSound()); + MTPNotificationSound(), + MTPBool()); if (peer->notify().change(empty)) { updateLocal(peer); peer->session().api().updateNotifySettingsDelayed(peer); @@ -262,9 +274,10 @@ void NotifySettings::defaultUpdate( DefaultNotify type, Data::MuteValue muteForSeconds, std::optional silentPosts, - std::optional sound) { + std::optional sound, + std::optional storiesMuted) { auto &settings = defaultValue(type).settings; - if (settings.change(muteForSeconds, silentPosts, sound)) { + if (settings.change(muteForSeconds, silentPosts, sound, storiesMuted)) { updateLocal(type); _owner->session().api().updateNotifySettingsDelayed(type); } diff --git a/Telegram/SourceFiles/data/notify/data_notify_settings.h b/Telegram/SourceFiles/data/notify/data_notify_settings.h index be41ce8dc..6e51b87ac 100644 --- a/Telegram/SourceFiles/data/notify/data_notify_settings.h +++ b/Telegram/SourceFiles/data/notify/data_notify_settings.h @@ -57,13 +57,15 @@ public: not_null thread, Data::MuteValue muteForSeconds, std::optional silentPosts = std::nullopt, - std::optional sound = std::nullopt); + std::optional sound = std::nullopt, + std::optional storiesMuted = std::nullopt); void resetToDefault(not_null thread); void update( not_null peer, Data::MuteValue muteForSeconds, std::optional silentPosts = std::nullopt, - std::optional sound = std::nullopt); + std::optional sound = std::nullopt, + std::optional storiesMuted = std::nullopt); void resetToDefault(not_null peer); void forumParentMuteUpdated(not_null forum); @@ -84,7 +86,8 @@ public: DefaultNotify type, Data::MuteValue muteForSeconds, std::optional silentPosts = std::nullopt, - std::optional sound = std::nullopt); + std::optional sound = std::nullopt, + std::optional storiesMuted = std::nullopt); [[nodiscard]] bool isMuted(not_null thread) const; [[nodiscard]] NotifySound sound( diff --git a/Telegram/SourceFiles/data/notify/data_peer_notify_settings.cpp b/Telegram/SourceFiles/data/notify/data_peer_notify_settings.cpp index 6d5735624..da03d14f2 100644 --- a/Telegram/SourceFiles/data/notify/data_peer_notify_settings.cpp +++ b/Telegram/SourceFiles/data/notify/data_peer_notify_settings.cpp @@ -18,7 +18,8 @@ namespace { MTPBool(), MTPBool(), MTPint(), - MTPNotificationSound()); + MTPNotificationSound(), + MTPBool()); } [[nodiscard]] NotifySound ParseSound(const MTPNotificationSound &sound) { @@ -73,7 +74,8 @@ public: bool change( MuteValue muteForSeconds, std::optional silentPosts, - std::optional sound); + std::optional sound, + std::optional storiesMuted); std::optional muteUntil() const; std::optional silentPosts() const; @@ -85,12 +87,14 @@ private: std::optional mute, std::optional sound, std::optional showPreviews, - std::optional silentPosts); + std::optional silentPosts, + std::optional storiesMuted); std::optional _mute; std::optional _sound; std::optional _silent; std::optional _showPreviews; + std::optional _storiesMuted; }; @@ -104,19 +108,24 @@ bool NotifyPeerSettingsValue::change(const MTPDpeerNotifySettings &data) { const auto sound = data.vother_sound(); const auto showPreviews = data.vshow_previews(); const auto silent = data.vsilent(); + const auto storiesMuted = data.vstories_muted(); return change( mute ? std::make_optional(mute->v) : std::nullopt, sound ? std::make_optional(ParseSound(*sound)) : std::nullopt, (showPreviews ? std::make_optional(mtpIsTrue(*showPreviews)) : std::nullopt), - silent ? std::make_optional(mtpIsTrue(*silent)) : std::nullopt); + silent ? std::make_optional(mtpIsTrue(*silent)) : std::nullopt, + (storiesMuted + ? std::make_optional(mtpIsTrue(*storiesMuted)) + : std::nullopt)); } bool NotifyPeerSettingsValue::change( MuteValue muteForSeconds, std::optional silentPosts, - std::optional sound) { + std::optional sound, + std::optional storiesMuted) { const auto newMute = muteForSeconds ? base::make_optional(muteForSeconds.until()) : _mute; @@ -126,28 +135,35 @@ bool NotifyPeerSettingsValue::change( const auto newSound = sound ? base::make_optional(*sound) : _sound; + const auto newStoriesMuted = storiesMuted + ? base::make_optional(*storiesMuted) + : _storiesMuted; return change( newMute, newSound, _showPreviews, - newSilentPosts); + newSilentPosts, + newStoriesMuted); } bool NotifyPeerSettingsValue::change( std::optional mute, std::optional sound, std::optional showPreviews, - std::optional silentPosts) { + std::optional silentPosts, + std::optional storiesMuted) { if (_mute == mute && _sound == sound && _showPreviews == showPreviews - && _silent == silentPosts) { + && _silent == silentPosts + && _storiesMuted == storiesMuted) { return false; } _mute = mute; _sound = sound; _showPreviews = showPreviews; _silent = silentPosts; + _storiesMuted = storiesMuted; return true; } @@ -172,11 +188,13 @@ MTPinputPeerNotifySettings NotifyPeerSettingsValue::serialize() const { MTP_flags(flag(_mute, Flag::f_mute_until) | flag(_sound, Flag::f_sound) | flag(_silent, Flag::f_silent) - | flag(_showPreviews, Flag::f_show_previews)), - MTP_bool(_showPreviews ? *_showPreviews : true), - MTP_bool(_silent ? *_silent : false), - MTP_int(_mute ? *_mute : false), - SerializeSound(_sound)); + | flag(_showPreviews, Flag::f_show_previews) + | flag(_storiesMuted, Flag::f_stories_muted)), + MTP_bool(_showPreviews.value_or(true)), + MTP_bool(_silent.value_or(false)), + MTP_int(_mute.value_or(false)), + SerializeSound(_sound), + MTP_bool(_storiesMuted.value_or(false))); } PeerNotifySettings::PeerNotifySettings() = default; @@ -203,16 +221,22 @@ bool PeerNotifySettings::change(const MTPPeerNotifySettings &settings) { bool PeerNotifySettings::change( MuteValue muteForSeconds, std::optional silentPosts, - std::optional sound) { - if (!muteForSeconds && !silentPosts && !sound) { + std::optional sound, + std::optional storiesMuted) { + if (!muteForSeconds && !silentPosts && !sound && !storiesMuted) { return false; } else if (_value) { - return _value->change(muteForSeconds, silentPosts, sound); + return _value->change( + muteForSeconds, + silentPosts, + sound, + storiesMuted); } using Flag = MTPDpeerNotifySettings::Flag; const auto flags = (muteForSeconds ? Flag::f_mute_until : Flag(0)) | (silentPosts ? Flag::f_silent : Flag(0)) - | (sound ? Flag::f_other_sound : Flag(0)); + | (sound ? Flag::f_other_sound : Flag(0)) + | (storiesMuted ? Flag::f_stories_muted : Flag(0)); return change(MTP_peerNotifySettings( MTP_flags(flags), MTPBool(), @@ -220,7 +244,8 @@ bool PeerNotifySettings::change( MTP_int(muteForSeconds.until()), MTPNotificationSound(), MTPNotificationSound(), - SerializeSound(sound))); + SerializeSound(sound), + storiesMuted ? MTP_bool(*storiesMuted) : MTPBool())); } std::optional PeerNotifySettings::muteUntil() const { diff --git a/Telegram/SourceFiles/data/notify/data_peer_notify_settings.h b/Telegram/SourceFiles/data/notify/data_peer_notify_settings.h index 3973d7820..76a8ecfd9 100644 --- a/Telegram/SourceFiles/data/notify/data_peer_notify_settings.h +++ b/Telegram/SourceFiles/data/notify/data_peer_notify_settings.h @@ -44,7 +44,8 @@ public: bool change( MuteValue muteForSeconds, std::optional silentPosts, - std::optional sound); + std::optional sound, + std::optional storiesMuted); bool settingsUnknown() const; std::optional muteUntil() const; diff --git a/Telegram/SourceFiles/dialogs/ui/dialogs_stories_content.cpp b/Telegram/SourceFiles/dialogs/ui/dialogs_stories_content.cpp index c47282c26..332dec14a 100644 --- a/Telegram/SourceFiles/dialogs/ui/dialogs_stories_content.cpp +++ b/Telegram/SourceFiles/dialogs/ui/dialogs_stories_content.cpp @@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_user.h" #include "dialogs/ui/dialogs_stories_list.h" #include "main/main_session.h" +#include "lang/lang_keys.h" #include "ui/painter.h" namespace Dialogs::Stories { @@ -144,7 +145,9 @@ Content State::next() { } result.users.push_back({ .id = uint64(user->id.value), - .name = user->shortName(), + .name = (user->isSelf() + ? tr::lng_stories_my_name(tr::now) + : user->shortName()), .userpic = std::move(userpic), .unread = info.unread, .hidden = info.hidden, diff --git a/Telegram/SourceFiles/mtproto/scheme/api.tl b/Telegram/SourceFiles/mtproto/scheme/api.tl index 577a291a1..a916847ce 100644 --- a/Telegram/SourceFiles/mtproto/scheme/api.tl +++ b/Telegram/SourceFiles/mtproto/scheme/api.tl @@ -129,7 +129,7 @@ messageMediaInvoice#f6a548d3 flags:# shipping_address_requested:flags.1?true tes messageMediaGeoLive#b940c666 flags:# geo:GeoPoint heading:flags.0?int period:int proximity_notification_radius:flags.1?int = MessageMedia; messageMediaPoll#4bd6e798 poll:Poll results:PollResults = MessageMedia; messageMediaDice#3f7ee58b value:int emoticon:string = MessageMedia; -messageMediaStory#c79aee11 user_id:long id:int = MessageMedia; +messageMediaStory#cbb20d88 flags:# user_id:long id:int story:flags.0?StoryItem = MessageMedia; messageActionEmpty#b6aef7b0 = MessageAction; messageActionChatCreate#bd47cbad title:string users:Vector = MessageAction; @@ -201,9 +201,9 @@ inputNotifyChats#4a95e84e = InputNotifyPeer; inputNotifyBroadcasts#b1db7c7e = InputNotifyPeer; inputNotifyForumTopic#5c467992 peer:InputPeer top_msg_id:int = InputNotifyPeer; -inputPeerNotifySettings#df1f002b flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?NotificationSound = InputPeerNotifySettings; +inputPeerNotifySettings#e1e51e85 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?NotificationSound stories_muted:flags.6?Bool = InputPeerNotifySettings; -peerNotifySettings#a83b0426 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int ios_sound:flags.3?NotificationSound android_sound:flags.4?NotificationSound other_sound:flags.5?NotificationSound = PeerNotifySettings; +peerNotifySettings#6cdc6e52 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int ios_sound:flags.3?NotificationSound android_sound:flags.4?NotificationSound other_sound:flags.5?NotificationSound stories_muted:flags.6?Bool = PeerNotifySettings; peerSettings#a518110d flags:# report_spam:flags.0?true add_contact:flags.1?true block_contact:flags.2?true share_contact:flags.3?true need_contacts_exception:flags.4?true report_geo:flags.5?true autoarchived:flags.7?true invite_members:flags.8?true request_chat_broadcast:flags.10?true geo_distance:flags.6?int request_chat_title:flags.9?string request_chat_date:flags.9?int = PeerSettings;