tdesktop/Telegram/SourceFiles/data/notify/data_peer_notify_settings.h

66 lines
1.4 KiB
C
Raw Normal View History

2017-12-04 17:46:03 +00:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
2017-12-04 17:46:03 +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 {
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);
}
class PeerNotifySettings {
2017-12-04 17:46:03 +00:00
public:
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,
std::optional<bool> silentPosts,
2023-06-09 15:31:51 +00:00
std::optional<NotifySound> sound,
std::optional<bool> storiesMuted);
bool resetToDefault();
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;
std::optional<NotifySound> sound() const;
2017-12-04 17:46:03 +00:00
MTPinputPeerNotifySettings serialize() const;
~PeerNotifySettings();
2017-12-04 17:46:03 +00:00
private:
bool _known = false;
std::unique_ptr<NotifyPeerSettingsValue> _value;
2017-12-04 17:46:03 +00:00
};
} // namespace Data