2017-12-04 17:46:03 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-12-04 17:46:03 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-12-04 17:46:03 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
2022-04-01 08:40:46 +00:00
|
|
|
class NotifyPeerSettingsValue;
|
2017-12-04 17:46:03 +00:00
|
|
|
|
2022-03-30 06:20:42 +00:00
|
|
|
struct NotifySound {
|
|
|
|
QString title;
|
|
|
|
QString data;
|
|
|
|
DocumentId id = 0;
|
|
|
|
bool none = false;
|
|
|
|
};
|
|
|
|
|
2022-09-14 08:28:59 +00:00
|
|
|
struct MuteValue {
|
|
|
|
bool unmute = false;
|
|
|
|
bool forever = false;
|
|
|
|
int period = 0;
|
|
|
|
|
|
|
|
[[nodiscard]] explicit operator bool() const {
|
|
|
|
return unmute || forever || period;
|
|
|
|
}
|
|
|
|
[[nodiscard]] int until() const;
|
|
|
|
};
|
|
|
|
|
2022-03-30 06:20:42 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2022-04-01 08:40:46 +00:00
|
|
|
class PeerNotifySettings {
|
2017-12-04 17:46:03 +00:00
|
|
|
public:
|
2022-04-01 08:40:46 +00:00
|
|
|
PeerNotifySettings();
|
2017-12-04 17:46:03 +00:00
|
|
|
|
|
|
|
bool change(const MTPPeerNotifySettings &settings);
|
|
|
|
bool change(
|
2022-09-14 08:28:59 +00:00
|
|
|
MuteValue muteForSeconds,
|
2022-03-30 09:36:41 +00:00
|
|
|
std::optional<bool> silentPosts,
|
2023-06-09 15:31:51 +00:00
|
|
|
std::optional<NotifySound> sound,
|
|
|
|
std::optional<bool> storiesMuted);
|
2023-08-23 11:20:41 +00:00
|
|
|
bool resetToDefault();
|
2018-04-09 17:48:29 +00:00
|
|
|
|
2017-12-04 17:46:03 +00:00
|
|
|
bool settingsUnknown() const;
|
2018-09-21 16:28:46 +00:00
|
|
|
std::optional<TimeId> muteUntil() const;
|
|
|
|
std::optional<bool> silentPosts() const;
|
2022-04-04 21:10:15 +00:00
|
|
|
std::optional<NotifySound> sound() const;
|
2017-12-04 17:46:03 +00:00
|
|
|
MTPinputPeerNotifySettings serialize() const;
|
|
|
|
|
2022-04-01 08:40:46 +00:00
|
|
|
~PeerNotifySettings();
|
2017-12-04 17:46:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool _known = false;
|
2022-04-01 08:40:46 +00:00
|
|
|
std::unique_ptr<NotifyPeerSettingsValue> _value;
|
2017-12-04 17:46:03 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Data
|