mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 15:47:11 +02:00
Update API scheme on layer 140.
This commit is contained in:
parent
b38ac32898
commit
00f442573a
5 changed files with 76 additions and 17 deletions
|
@ -220,9 +220,9 @@ inputNotifyUsers#193b4417 = InputNotifyPeer;
|
|||
inputNotifyChats#4a95e84e = InputNotifyPeer;
|
||||
inputNotifyBroadcasts#b1db7c7e = InputNotifyPeer;
|
||||
|
||||
inputPeerNotifySettings#9c3d198e flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?string = InputPeerNotifySettings;
|
||||
inputPeerNotifySettings#df1f002b flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?NotificationSound = InputPeerNotifySettings;
|
||||
|
||||
peerNotifySettings#af509d20 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?string = PeerNotifySettings;
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -388,6 +388,7 @@ updateBotChatInviteRequester#11dfa986 peer:Peer date:int user_id:long about:stri
|
|||
updateMessageReactions#154798c3 peer:Peer msg_id:int reactions:MessageReactions = Update;
|
||||
updateAttachMenuBots#17b7a20b = Update;
|
||||
updateWebViewResultSent#f8f63baa peer:Peer bot_id:long query_id:long = Update;
|
||||
updateSavedRingtones#74d8be99 = Update;
|
||||
|
||||
updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State;
|
||||
|
||||
|
@ -1349,6 +1350,14 @@ simpleWebViewResultUrl#882f76bb url:string = SimpleWebViewResult;
|
|||
|
||||
webViewMessageSent#c94511c flags:# msg_id:flags.0?InputBotInlineMessageID = WebViewMessageSent;
|
||||
|
||||
account.savedRingtonesNotModified#fbf6e8b1 = account.SavedRingtones;
|
||||
account.savedRingtones#c1e92cc5 hash:long ringtones:Vector<Document> = account.SavedRingtones;
|
||||
|
||||
notificationSoundDefault#97e8bebe = NotificationSound;
|
||||
notificationSoundNone#6f0c34df = NotificationSound;
|
||||
notificationSoundLocal#830b9ae4 title:string data:string = NotificationSound;
|
||||
notificationSoundRingtone#ff6c8049 id:long = NotificationSound;
|
||||
|
||||
---functions---
|
||||
|
||||
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
|
||||
|
@ -1452,6 +1461,9 @@ account.declinePasswordReset#4c9409f6 = Bool;
|
|||
account.getChatThemes#d638de89 hash:long = account.Themes;
|
||||
account.setAuthorizationTTL#bf899aa0 authorization_ttl_days:int = Bool;
|
||||
account.changeAuthorizationSettings#40f48462 flags:# hash:long encrypted_requests_disabled:flags.0?Bool call_requests_disabled:flags.1?Bool = Bool;
|
||||
account.getSavedRingtones#e1902288 hash:long = account.SavedRingtones;
|
||||
account.saveRingtone#e9f81323 id:InputDocument unsave:Bool = Bool;
|
||||
account.uploadRingtone#831a83a2 file:InputFile file_name:string mime_type:string = Document;
|
||||
|
||||
users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>;
|
||||
users.getFullUser#b60f5918 id:InputUser = users.UserFull;
|
||||
|
|
|
@ -1746,7 +1746,9 @@ void ApiWrap::requestNotifySettings(const MTPInputNotifyPeer &peer) {
|
|||
MTPBool(),
|
||||
MTPBool(),
|
||||
MTPint(),
|
||||
MTPstring()));
|
||||
MTPNotificationSound(),
|
||||
MTPNotificationSound(),
|
||||
MTPNotificationSound()));
|
||||
_notifySettingRequests.erase(key);
|
||||
}).send();
|
||||
|
||||
|
|
|
@ -12,13 +12,43 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace Data {
|
||||
namespace {
|
||||
|
||||
MTPinputPeerNotifySettings DefaultSettings() {
|
||||
[[nodiscard]] MTPinputPeerNotifySettings DefaultSettings() {
|
||||
return MTP_inputPeerNotifySettings(
|
||||
MTP_flags(0),
|
||||
MTPBool(),
|
||||
MTPBool(),
|
||||
MTPint(),
|
||||
MTPstring());
|
||||
MTPNotificationSound());
|
||||
}
|
||||
|
||||
[[nodiscard]] NotifySound ParseSound(const MTPNotificationSound &sound) {
|
||||
return sound.match([&](const MTPDnotificationSoundDefault &data) {
|
||||
return NotifySound();
|
||||
}, [&](const MTPDnotificationSoundNone &data) {
|
||||
return NotifySound{ .none = true };
|
||||
}, [&](const MTPDnotificationSoundLocal &data) {
|
||||
return NotifySound{
|
||||
.title = qs(data.vtitle()),
|
||||
.data = qs(data.vdata()),
|
||||
};
|
||||
}, [&](const MTPDnotificationSoundRingtone &data) {
|
||||
return NotifySound{ .id = data.vid().v };
|
||||
});
|
||||
}
|
||||
|
||||
[[nodiscard]] MTPNotificationSound SerializeSound(
|
||||
const std::optional<NotifySound> &sound) {
|
||||
return !sound
|
||||
? MTPNotificationSound()
|
||||
: sound->none
|
||||
? MTP_notificationSoundNone()
|
||||
: sound->id
|
||||
? MTP_notificationSoundRingtone(MTP_long(sound->id))
|
||||
: !sound->title.isEmpty()
|
||||
? MTP_notificationSoundLocal(
|
||||
MTP_string(sound->title),
|
||||
MTP_string(sound->data))
|
||||
: MTP_notificationSoundDefault();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -39,12 +69,12 @@ public:
|
|||
private:
|
||||
bool change(
|
||||
std::optional<int> mute,
|
||||
std::optional<QString> sound,
|
||||
std::optional<NotifySound> sound,
|
||||
std::optional<bool> showPreviews,
|
||||
std::optional<bool> silentPosts);
|
||||
|
||||
std::optional<TimeId> _mute;
|
||||
std::optional<QString> _sound;
|
||||
std::optional<NotifySound> _sound;
|
||||
std::optional<bool> _silent;
|
||||
std::optional<bool> _showPreviews;
|
||||
|
||||
|
@ -57,12 +87,12 @@ NotifySettingsValue::NotifySettingsValue(
|
|||
|
||||
bool NotifySettingsValue::change(const MTPDpeerNotifySettings &data) {
|
||||
const auto mute = data.vmute_until();
|
||||
const auto sound = data.vsound();
|
||||
const auto sound = data.vother_sound();
|
||||
const auto showPreviews = data.vshow_previews();
|
||||
const auto silent = data.vsilent();
|
||||
return change(
|
||||
mute ? std::make_optional(mute->v) : std::nullopt,
|
||||
sound ? std::make_optional(qs(*sound)) : std::nullopt,
|
||||
sound ? std::make_optional(ParseSound(*sound)) : std::nullopt,
|
||||
(showPreviews
|
||||
? std::make_optional(mtpIsTrue(*showPreviews))
|
||||
: std::nullopt),
|
||||
|
@ -81,22 +111,19 @@ bool NotifySettingsValue::change(
|
|||
? (now + *muteForSeconds)
|
||||
: 0)
|
||||
: _mute;
|
||||
const auto newSound = (_sound && _sound->isEmpty() && notMuted)
|
||||
? qsl("default")
|
||||
: _sound;
|
||||
const auto newSilentPosts = silentPosts
|
||||
? base::make_optional(*silentPosts)
|
||||
: _silent;
|
||||
return change(
|
||||
newMute,
|
||||
newSound,
|
||||
_sound,
|
||||
_showPreviews,
|
||||
newSilentPosts);
|
||||
}
|
||||
|
||||
bool NotifySettingsValue::change(
|
||||
std::optional<int> mute,
|
||||
std::optional<QString> sound,
|
||||
std::optional<NotifySound> sound,
|
||||
std::optional<bool> showPreviews,
|
||||
std::optional<bool> silentPosts) {
|
||||
if (_mute == mute
|
||||
|
@ -133,7 +160,7 @@ MTPinputPeerNotifySettings NotifySettingsValue::serialize() const {
|
|||
MTP_bool(_showPreviews ? *_showPreviews : true),
|
||||
MTP_bool(_silent ? *_silent : false),
|
||||
MTP_int(_mute ? *_mute : false),
|
||||
MTP_string(_sound ? *_sound : QString()));
|
||||
SerializeSound(_sound));
|
||||
}
|
||||
|
||||
NotifySettings::NotifySettings() = default;
|
||||
|
@ -178,7 +205,9 @@ bool NotifySettings::change(
|
|||
MTPBool(),
|
||||
silentPosts ? MTP_bool(*silentPosts) : MTPBool(),
|
||||
MTP_int(muteUntil),
|
||||
MTPstring()));
|
||||
MTPNotificationSound(),
|
||||
MTPNotificationSound(),
|
||||
MTPNotificationSound()));
|
||||
}
|
||||
|
||||
std::optional<TimeId> NotifySettings::muteUntil() const {
|
||||
|
|
|
@ -11,6 +11,20 @@ namespace Data {
|
|||
|
||||
class NotifySettingsValue;
|
||||
|
||||
struct NotifySound {
|
||||
QString title;
|
||||
QString data;
|
||||
DocumentId id = 0;
|
||||
bool none = false;
|
||||
};
|
||||
|
||||
inline bool operator==(const NotifySound &a, const NotifySound &b) {
|
||||
return (a.id == b.id)
|
||||
&& (a.none == b.none)
|
||||
&& (a.title == b.title)
|
||||
&& (a.data == b.data);
|
||||
}
|
||||
|
||||
class NotifySettings {
|
||||
public:
|
||||
NotifySettings();
|
||||
|
|
|
@ -3964,7 +3964,9 @@ void Session::resetNotifySettingsToDefault(not_null<PeerData*> peer) {
|
|||
MTPBool(),
|
||||
MTPBool(),
|
||||
MTPint(),
|
||||
MTPstring());
|
||||
MTPNotificationSound(),
|
||||
MTPNotificationSound(),
|
||||
MTPNotificationSound());
|
||||
if (peer->notifyChange(empty)) {
|
||||
updateNotifySettingsLocal(peer);
|
||||
_session->api().updateNotifySettingsDelayed(peer);
|
||||
|
|
Loading…
Add table
Reference in a new issue