2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-22 18:27:17 +00:00
tdesktop/Telegram/SourceFiles/api/api_global_privacy.h

111 lines
3.3 KiB
C
Raw Normal View History

2020-07-03 20:53:24 +04:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "base/flags.h"
2020-07-03 20:53:24 +04:00
#include "mtproto/sender.h"
class ApiWrap;
namespace Main {
class Session;
} // namespace Main
namespace Api {
2023-07-13 19:33:57 +04:00
enum class UnarchiveOnNewMessage {
None,
NotInFoldersUnmuted,
AnyUnmuted,
};
2025-03-18 13:37:12 +04:00
enum class DisallowedGiftType : uchar {
2025-03-21 18:04:03 +04:00
Limited = 0x01,
Unlimited = 0x02,
2025-03-21 18:04:03 +04:00
Unique = 0x04,
Premium = 0x08,
2025-03-18 13:37:12 +04:00
SendHide = 0x10,
};
inline constexpr bool is_flag_type(DisallowedGiftType) { return true; }
using DisallowedGiftTypes = base::flags<DisallowedGiftType>;
2025-01-31 14:57:53 +04:00
[[nodiscard]] PeerId ParsePaidReactionShownPeer(
not_null<Main::Session*> session,
const MTPPaidReactionPrivacy &value);
2020-07-03 20:53:24 +04:00
class GlobalPrivacy final {
public:
explicit GlobalPrivacy(not_null<ApiWrap*> api);
void reload(Fn<void()> callback = nullptr);
2023-08-11 16:20:38 +02:00
void updateArchiveAndMute(bool value);
void updateUnarchiveOnNewMessage(UnarchiveOnNewMessage value);
2020-07-03 20:53:24 +04:00
[[nodiscard]] bool archiveAndMuteCurrent() const;
[[nodiscard]] rpl::producer<bool> archiveAndMute() const;
2023-07-13 19:33:57 +04:00
[[nodiscard]] auto unarchiveOnNewMessageCurrent() const
-> UnarchiveOnNewMessage;
[[nodiscard]] auto unarchiveOnNewMessage() const
-> rpl::producer<UnarchiveOnNewMessage>;
2020-07-03 20:53:24 +04:00
[[nodiscard]] rpl::producer<bool> showArchiveAndMute() const;
[[nodiscard]] rpl::producer<> suggestArchiveAndMute() const;
void dismissArchiveAndMuteSuggestion();
2024-01-09 13:13:30 +04:00
void updateHideReadTime(bool hide);
[[nodiscard]] bool hideReadTimeCurrent() const;
[[nodiscard]] rpl::producer<bool> hideReadTime() const;
[[nodiscard]] bool newRequirePremiumCurrent() const;
[[nodiscard]] rpl::producer<bool> newRequirePremium() const;
[[nodiscard]] int newChargeStarsCurrent() const;
[[nodiscard]] rpl::producer<int> newChargeStars() const;
void updateMessagesPrivacy(bool requirePremium, int chargeStars);
[[nodiscard]] DisallowedGiftTypes disallowedGiftTypesCurrent() const;
[[nodiscard]] auto disallowedGiftTypes() const
-> rpl::producer<DisallowedGiftTypes>;
2025-03-18 13:37:12 +04:00
void updateDisallowedGiftTypes(DisallowedGiftTypes types);
2025-01-31 14:57:53 +04:00
void loadPaidReactionShownPeer();
void updatePaidReactionShownPeer(PeerId shownPeer);
[[nodiscard]] PeerId paidReactionShownPeerCurrent() const;
[[nodiscard]] rpl::producer<PeerId> paidReactionShownPeer() const;
2020-07-03 20:53:24 +04:00
private:
void apply(const MTPGlobalPrivacySettings &settings);
2020-07-03 20:53:24 +04:00
2023-08-11 16:20:38 +02:00
void update(
bool archiveAndMute,
2024-01-09 13:13:30 +04:00
UnarchiveOnNewMessage unarchiveOnNewMessage,
bool hideReadTime,
bool newRequirePremium,
int newChargeStars,
DisallowedGiftTypes disallowedGiftTypes);
2023-08-11 16:20:38 +02:00
2020-07-03 20:53:24 +04:00
const not_null<Main::Session*> _session;
MTP::Sender _api;
mtpRequestId _requestId = 0;
rpl::variable<bool> _archiveAndMute = false;
2023-07-13 19:33:57 +04:00
rpl::variable<UnarchiveOnNewMessage> _unarchiveOnNewMessage
= UnarchiveOnNewMessage::None;
2020-07-03 20:53:24 +04:00
rpl::variable<bool> _showArchiveAndMute = false;
2024-01-09 13:13:30 +04:00
rpl::variable<bool> _hideReadTime = false;
rpl::variable<bool> _newRequirePremium = false;
rpl::variable<int> _newChargeStars = 0;
rpl::variable<DisallowedGiftTypes> _disallowedGiftTypes;
2025-01-31 14:57:53 +04:00
rpl::variable<PeerId> _paidReactionShownPeer = false;
std::vector<Fn<void()>> _callbacks;
2025-01-31 14:57:53 +04:00
bool _paidReactionShownPeerLoaded = false;
2020-07-03 20:53:24 +04:00
};
} // namespace Api