2017-09-26 11:49:16 +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-09-26 11:49:16 +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-09-26 11:49:16 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "data/data_types.h"
|
|
|
|
#include "data/data_flags.h"
|
2022-04-01 08:40:46 +00:00
|
|
|
#include "data/notify/data_peer_notify_settings.h"
|
2020-05-28 14:32:10 +00:00
|
|
|
#include "data/data_cloud_file.h"
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2022-04-11 08:16:34 +00:00
|
|
|
struct BotInfo;
|
2017-12-05 08:43:18 +00:00
|
|
|
class PeerData;
|
|
|
|
class UserData;
|
|
|
|
class ChatData;
|
|
|
|
class ChannelData;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2021-11-21 19:48:08 +00:00
|
|
|
enum class ChatRestriction;
|
2022-07-18 20:35:16 +00:00
|
|
|
enum class UserRestriction;
|
2021-02-02 16:38:30 +00:00
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
namespace Ui {
|
|
|
|
class EmptyUserpic;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2019-06-06 11:59:00 +00:00
|
|
|
namespace Main {
|
|
|
|
class Account;
|
2019-07-24 11:45:24 +00:00
|
|
|
class Session;
|
2019-06-06 11:59:00 +00:00
|
|
|
} // namespace Main
|
|
|
|
|
2017-12-05 08:43:18 +00:00
|
|
|
namespace Data {
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2022-09-23 19:21:31 +00:00
|
|
|
class Forum;
|
2022-10-12 12:57:17 +00:00
|
|
|
class ForumTopic;
|
2019-01-03 12:36:01 +00:00
|
|
|
class Session;
|
2020-12-14 12:52:18 +00:00
|
|
|
class GroupCall;
|
2021-02-02 16:38:30 +00:00
|
|
|
class CloudImageView;
|
2022-08-22 09:15:34 +00:00
|
|
|
struct ReactionId;
|
2018-01-04 09:40:58 +00:00
|
|
|
|
2017-12-05 08:43:18 +00:00
|
|
|
int PeerColorIndex(PeerId peerId);
|
2021-04-01 21:04:10 +00:00
|
|
|
int PeerColorIndex(BareId bareId);
|
2017-12-05 08:43:18 +00:00
|
|
|
style::color PeerUserpicColor(PeerId peerId);
|
2021-12-31 12:47:23 +00:00
|
|
|
|
|
|
|
// Must be used only for PeerColor-s.
|
2019-03-15 15:15:56 +00:00
|
|
|
PeerId FakePeerIdForJustName(const QString &name);
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-01-14 17:43:06 +00:00
|
|
|
class RestrictionCheckResult {
|
|
|
|
public:
|
|
|
|
[[nodiscard]] static RestrictionCheckResult Allowed() {
|
|
|
|
return { 0 };
|
|
|
|
}
|
|
|
|
[[nodiscard]] static RestrictionCheckResult WithEveryone() {
|
|
|
|
return { 1 };
|
|
|
|
}
|
|
|
|
[[nodiscard]] static RestrictionCheckResult Explicit() {
|
|
|
|
return { 2 };
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit operator bool() const {
|
|
|
|
return (_value != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const RestrictionCheckResult &other) const {
|
|
|
|
return (_value == other._value);
|
|
|
|
}
|
|
|
|
bool operator!=(const RestrictionCheckResult &other) const {
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] bool isAllowed() const {
|
|
|
|
return (*this == Allowed());
|
|
|
|
}
|
|
|
|
[[nodiscard]] bool isWithEveryone() const {
|
|
|
|
return (*this == WithEveryone());
|
|
|
|
}
|
|
|
|
[[nodiscard]] bool isExplicit() const {
|
|
|
|
return (*this == Explicit());
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
RestrictionCheckResult(int value) : _value(value) {
|
|
|
|
}
|
|
|
|
|
|
|
|
int _value = 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-12-09 13:57:33 +00:00
|
|
|
struct UnavailableReason {
|
|
|
|
QString reason;
|
|
|
|
QString text;
|
|
|
|
|
|
|
|
bool operator==(const UnavailableReason &other) const {
|
|
|
|
return (reason == other.reason) && (text == other.text);
|
|
|
|
}
|
|
|
|
bool operator!=(const UnavailableReason &other) const {
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-04-11 08:16:34 +00:00
|
|
|
bool ApplyBotMenuButton(
|
|
|
|
not_null<BotInfo*> info,
|
2022-04-15 13:32:34 +00:00
|
|
|
const MTPBotMenuButton *button);
|
2021-07-01 11:05:15 +00:00
|
|
|
|
2022-08-22 09:15:34 +00:00
|
|
|
enum class AllowedReactionsType {
|
|
|
|
All,
|
|
|
|
Default,
|
|
|
|
Some,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AllowedReactions {
|
|
|
|
std::vector<ReactionId> some;
|
|
|
|
AllowedReactionsType type = AllowedReactionsType::Some;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool operator<(const AllowedReactions &a, const AllowedReactions &b);
|
|
|
|
bool operator==(const AllowedReactions &a, const AllowedReactions &b);
|
|
|
|
|
|
|
|
[[nodiscard]] AllowedReactions Parse(const MTPChatReactions &value);
|
|
|
|
|
2019-01-14 17:43:06 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
class PeerClickHandler : public ClickHandler {
|
|
|
|
public:
|
|
|
|
PeerClickHandler(not_null<PeerData*> peer);
|
2018-07-09 18:13:48 +00:00
|
|
|
void onClick(ClickContext context) const override;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
not_null<PeerData*> peer() const {
|
|
|
|
return _peer;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
not_null<PeerData*> _peer;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-07-08 14:30:27 +00:00
|
|
|
enum class PeerSetting {
|
|
|
|
ReportSpam = (1 << 0),
|
|
|
|
AddContact = (1 << 1),
|
|
|
|
BlockContact = (1 << 2),
|
|
|
|
ShareContact = (1 << 3),
|
|
|
|
NeedContactsException = (1 << 4),
|
|
|
|
AutoArchived = (1 << 5),
|
2021-11-22 16:59:44 +00:00
|
|
|
RequestChat = (1 << 6),
|
|
|
|
RequestChatIsBroadcast = (1 << 7),
|
|
|
|
Unknown = (1 << 8),
|
2021-07-08 14:30:27 +00:00
|
|
|
};
|
|
|
|
inline constexpr bool is_flag_type(PeerSetting) { return true; };
|
|
|
|
using PeerSettings = base::flags<PeerSetting>;
|
2019-06-10 12:50:21 +00:00
|
|
|
|
2021-07-08 14:30:27 +00:00
|
|
|
class PeerData {
|
2017-09-26 11:49:16 +00:00
|
|
|
protected:
|
2019-01-03 12:36:01 +00:00
|
|
|
PeerData(not_null<Data::Session*> owner, PeerId id);
|
2017-09-26 11:49:16 +00:00
|
|
|
PeerData(const PeerData &other) = delete;
|
|
|
|
PeerData &operator=(const PeerData &other) = delete;
|
|
|
|
|
|
|
|
public:
|
2021-07-08 14:30:27 +00:00
|
|
|
using Settings = Data::Flags<PeerSettings>;
|
2019-06-07 11:32:58 +00:00
|
|
|
|
2017-12-04 17:46:03 +00:00
|
|
|
virtual ~PeerData();
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-03-12 10:36:33 +00:00
|
|
|
static constexpr auto kServiceNotificationsId = peerFromUser(777000);
|
|
|
|
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] Data::Session &owner() const;
|
2019-07-24 11:45:24 +00:00
|
|
|
[[nodiscard]] Main::Session &session() const;
|
2019-06-06 11:59:00 +00:00
|
|
|
[[nodiscard]] Main::Account &account() const;
|
2019-01-03 12:36:01 +00:00
|
|
|
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] bool isUser() const {
|
2017-09-26 11:49:16 +00:00
|
|
|
return peerIsUser(id);
|
|
|
|
}
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] bool isChat() const {
|
2017-09-26 11:49:16 +00:00
|
|
|
return peerIsChat(id);
|
|
|
|
}
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] bool isChannel() const {
|
2017-09-26 11:49:16 +00:00
|
|
|
return peerIsChannel(id);
|
|
|
|
}
|
2021-12-01 14:51:18 +00:00
|
|
|
[[nodiscard]] bool isSelf() const;
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] bool isVerified() const;
|
2022-05-16 11:38:35 +00:00
|
|
|
[[nodiscard]] bool isPremium() const;
|
2019-06-23 12:18:33 +00:00
|
|
|
[[nodiscard]] bool isScam() const;
|
2021-01-21 12:39:40 +00:00
|
|
|
[[nodiscard]] bool isFake() const;
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] bool isMegagroup() const;
|
2020-09-03 11:53:54 +00:00
|
|
|
[[nodiscard]] bool isBroadcast() const;
|
2022-09-20 09:35:47 +00:00
|
|
|
[[nodiscard]] bool isForum() const;
|
2021-02-12 15:07:41 +00:00
|
|
|
[[nodiscard]] bool isGigagroup() const;
|
2020-09-11 15:33:26 +00:00
|
|
|
[[nodiscard]] bool isRepliesChat() const;
|
|
|
|
[[nodiscard]] bool sharedMediaInfo() const {
|
|
|
|
return isSelf() || isRepliesChat();
|
|
|
|
}
|
2017-12-04 17:46:03 +00:00
|
|
|
|
2019-03-12 10:36:33 +00:00
|
|
|
[[nodiscard]] bool isNotificationsUser() const {
|
|
|
|
return (id == peerFromUser(333000))
|
|
|
|
|| (id == kServiceNotificationsId);
|
|
|
|
}
|
|
|
|
[[nodiscard]] bool isServiceUser() const {
|
2021-04-01 21:04:10 +00:00
|
|
|
return isUser() && !(id.value % 1000);
|
2019-03-12 10:36:33 +00:00
|
|
|
}
|
|
|
|
|
2022-09-23 19:21:31 +00:00
|
|
|
[[nodiscard]] Data::Forum *forum() const;
|
2022-10-12 12:57:17 +00:00
|
|
|
[[nodiscard]] Data::ForumTopic *forumTopicFor(
|
|
|
|
not_null<const HistoryItem*> item) const;
|
|
|
|
[[nodiscard]] Data::ForumTopic *forumTopicFor(MsgId rootId) const;
|
2022-09-23 19:21:31 +00:00
|
|
|
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] std::optional<TimeId> notifyMuteUntil() const {
|
2018-04-09 17:48:29 +00:00
|
|
|
return _notify.muteUntil();
|
2017-12-04 17:46:03 +00:00
|
|
|
}
|
|
|
|
bool notifyChange(const MTPPeerNotifySettings &settings) {
|
|
|
|
return _notify.change(settings);
|
|
|
|
}
|
|
|
|
bool notifyChange(
|
2022-09-14 08:28:59 +00:00
|
|
|
Data::MuteValue muteForSeconds,
|
2022-03-30 09:36:41 +00:00
|
|
|
std::optional<bool> silentPosts,
|
2022-04-04 21:10:15 +00:00
|
|
|
std::optional<Data::NotifySound> sound) {
|
|
|
|
return _notify.change(muteForSeconds, silentPosts, sound);
|
2017-12-04 17:46:03 +00:00
|
|
|
}
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] bool notifySettingsUnknown() const {
|
2017-12-04 17:46:03 +00:00
|
|
|
return _notify.settingsUnknown();
|
|
|
|
}
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] std::optional<bool> notifySilentPosts() const {
|
2017-12-04 17:46:03 +00:00
|
|
|
return _notify.silentPosts();
|
|
|
|
}
|
2022-04-04 21:10:15 +00:00
|
|
|
[[nodiscard]] std::optional<Data::NotifySound> notifySound() const {
|
|
|
|
return _notify.sound();
|
2022-03-30 09:36:41 +00:00
|
|
|
}
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] MTPinputPeerNotifySettings notifySerialize() const {
|
2017-12-04 17:46:03 +00:00
|
|
|
return _notify.serialize();
|
|
|
|
}
|
|
|
|
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] bool canWrite() const;
|
2021-11-05 14:03:17 +00:00
|
|
|
[[nodiscard]] bool allowsForwarding() const;
|
2019-01-14 17:43:06 +00:00
|
|
|
[[nodiscard]] Data::RestrictionCheckResult amRestricted(
|
|
|
|
ChatRestriction right) const;
|
2020-09-10 11:19:48 +00:00
|
|
|
[[nodiscard]] bool amAnonymous() const;
|
2019-03-21 13:48:40 +00:00
|
|
|
[[nodiscard]] bool canRevokeFullHistory() const;
|
2019-07-17 10:37:42 +00:00
|
|
|
[[nodiscard]] bool slowmodeApplied() const;
|
2020-09-30 11:06:08 +00:00
|
|
|
[[nodiscard]] rpl::producer<bool> slowmodeAppliedValue() const;
|
2019-07-17 10:37:42 +00:00
|
|
|
[[nodiscard]] int slowmodeSecondsLeft() const;
|
2020-01-15 13:30:29 +00:00
|
|
|
[[nodiscard]] bool canSendPolls() const;
|
2020-12-14 12:52:18 +00:00
|
|
|
[[nodiscard]] bool canManageGroupCall() const;
|
2019-01-05 10:50:04 +00:00
|
|
|
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] UserData *asUser();
|
|
|
|
[[nodiscard]] const UserData *asUser() const;
|
|
|
|
[[nodiscard]] ChatData *asChat();
|
|
|
|
[[nodiscard]] const ChatData *asChat() const;
|
|
|
|
[[nodiscard]] ChannelData *asChannel();
|
|
|
|
[[nodiscard]] const ChannelData *asChannel() const;
|
|
|
|
[[nodiscard]] ChannelData *asMegagroup();
|
|
|
|
[[nodiscard]] const ChannelData *asMegagroup() const;
|
2020-09-03 11:53:54 +00:00
|
|
|
[[nodiscard]] ChannelData *asBroadcast();
|
|
|
|
[[nodiscard]] const ChannelData *asBroadcast() const;
|
2019-01-13 13:28:05 +00:00
|
|
|
[[nodiscard]] ChatData *asChatNotMigrated();
|
|
|
|
[[nodiscard]] const ChatData *asChatNotMigrated() const;
|
|
|
|
[[nodiscard]] ChannelData *asChannelOrMigrated();
|
|
|
|
[[nodiscard]] const ChannelData *asChannelOrMigrated() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] ChatData *migrateFrom() const;
|
|
|
|
[[nodiscard]] ChannelData *migrateTo() const;
|
2019-01-14 06:34:51 +00:00
|
|
|
[[nodiscard]] not_null<PeerData*> migrateToOrMe();
|
|
|
|
[[nodiscard]] not_null<const PeerData*> migrateToOrMe() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
|
|
|
void updateFull();
|
|
|
|
void updateFullForced();
|
|
|
|
void fullUpdated();
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] bool wasFullUpdated() const {
|
2017-09-26 11:49:16 +00:00
|
|
|
return (_lastFullUpdate != 0);
|
|
|
|
}
|
|
|
|
|
2022-08-09 11:12:19 +00:00
|
|
|
[[nodiscard]] int nameVersion() const;
|
|
|
|
[[nodiscard]] const QString &name() const;
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] const QString &shortName() const;
|
2022-08-09 11:12:19 +00:00
|
|
|
[[nodiscard]] const QString &topBarNameText() const;
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] QString userName() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] const base::flat_set<QString> &nameWords() const {
|
2017-10-24 17:11:35 +00:00
|
|
|
return _nameWords;
|
|
|
|
}
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] const base::flat_set<QChar> &nameFirstLetters() const {
|
2018-01-22 09:33:09 +00:00
|
|
|
return _nameFirstLetters;
|
2017-10-24 17:11:35 +00:00
|
|
|
}
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2022-05-16 11:38:35 +00:00
|
|
|
void setUserpic(
|
|
|
|
PhotoId photoId,
|
|
|
|
const ImageLocation &location,
|
|
|
|
bool hasVideo);
|
2017-12-05 06:41:43 +00:00
|
|
|
void setUserpicPhoto(const MTPPhoto &data);
|
2017-09-26 11:49:16 +00:00
|
|
|
void paintUserpic(
|
|
|
|
Painter &p,
|
2020-05-28 14:32:10 +00:00
|
|
|
std::shared_ptr<Data::CloudImageView> &view,
|
2017-09-26 11:49:16 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int size) const;
|
|
|
|
void paintUserpicLeft(
|
|
|
|
Painter &p,
|
2020-05-28 14:32:10 +00:00
|
|
|
std::shared_ptr<Data::CloudImageView> &view,
|
2017-09-26 11:49:16 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int w,
|
|
|
|
int size) const {
|
2020-05-28 14:32:10 +00:00
|
|
|
paintUserpic(p, view, rtl() ? (w - x - size) : x, y, size);
|
2017-09-26 11:49:16 +00:00
|
|
|
}
|
2019-04-12 11:52:39 +00:00
|
|
|
void loadUserpic();
|
2020-05-28 14:32:10 +00:00
|
|
|
[[nodiscard]] bool hasUserpic() const;
|
|
|
|
[[nodiscard]] std::shared_ptr<Data::CloudImageView> activeUserpicView();
|
|
|
|
[[nodiscard]] std::shared_ptr<Data::CloudImageView> createUserpicView();
|
|
|
|
[[nodiscard]] bool useEmptyUserpic(
|
|
|
|
std::shared_ptr<Data::CloudImageView> &view) const;
|
|
|
|
[[nodiscard]] InMemoryKey userpicUniqueKey(
|
|
|
|
std::shared_ptr<Data::CloudImageView> &view) const;
|
|
|
|
void saveUserpic(
|
|
|
|
std::shared_ptr<Data::CloudImageView> &view,
|
|
|
|
const QString &path,
|
|
|
|
int size) const;
|
|
|
|
void saveUserpicRounded(
|
|
|
|
std::shared_ptr<Data::CloudImageView> &view,
|
|
|
|
const QString &path,
|
|
|
|
int size) const;
|
|
|
|
[[nodiscard]] QPixmap genUserpic(
|
|
|
|
std::shared_ptr<Data::CloudImageView> &view,
|
|
|
|
int size) const;
|
2021-09-08 21:10:49 +00:00
|
|
|
[[nodiscard]] QImage generateUserpicImage(
|
2020-05-28 14:32:10 +00:00
|
|
|
std::shared_ptr<Data::CloudImageView> &view,
|
|
|
|
int size) const;
|
2021-09-08 21:10:49 +00:00
|
|
|
[[nodiscard]] QImage generateUserpicImage(
|
|
|
|
std::shared_ptr<Data::CloudImageView> &view,
|
|
|
|
int size,
|
|
|
|
ImageRoundRadius radius) const;
|
2020-05-28 14:32:10 +00:00
|
|
|
[[nodiscard]] ImageLocation userpicLocation() const {
|
|
|
|
return _userpic.location();
|
2017-11-20 19:54:05 +00:00
|
|
|
}
|
2021-05-19 12:59:31 +00:00
|
|
|
|
|
|
|
static constexpr auto kUnknownPhotoId = PhotoId(0xFFFFFFFFFFFFFFFFULL);
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] bool userpicPhotoUnknown() const {
|
2017-12-05 06:41:43 +00:00
|
|
|
return (_userpicPhotoId == kUnknownPhotoId);
|
|
|
|
}
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] PhotoId userpicPhotoId() const {
|
2017-12-05 06:41:43 +00:00
|
|
|
return userpicPhotoUnknown() ? 0 : _userpicPhotoId;
|
|
|
|
}
|
2022-05-16 11:38:35 +00:00
|
|
|
[[nodiscard]] bool userpicHasVideo() const {
|
|
|
|
return _userpicHasVideo;
|
|
|
|
}
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] Data::FileOrigin userpicOrigin() const;
|
|
|
|
[[nodiscard]] Data::FileOrigin userpicPhotoOrigin() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-01-04 07:57:07 +00:00
|
|
|
// If this string is not empty we must not allow to open the
|
|
|
|
// conversation and we must show this string instead.
|
2019-12-09 13:57:33 +00:00
|
|
|
[[nodiscard]] QString computeUnavailableReason() const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] ClickHandlerPtr createOpenLink();
|
|
|
|
[[nodiscard]] const ClickHandlerPtr &openLink() {
|
2017-09-26 11:49:16 +00:00
|
|
|
if (!_openLink) {
|
|
|
|
_openLink = createOpenLink();
|
|
|
|
}
|
|
|
|
return _openLink;
|
|
|
|
}
|
|
|
|
|
2020-05-28 14:32:10 +00:00
|
|
|
[[nodiscard]] Image *currentUserpic(
|
|
|
|
std::shared_ptr<Data::CloudImageView> &view) const;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-01-10 11:01:59 +00:00
|
|
|
[[nodiscard]] bool canPinMessages() const;
|
2020-04-23 12:08:50 +00:00
|
|
|
[[nodiscard]] bool canEditMessagesIndefinitely() const;
|
2020-10-21 11:07:49 +00:00
|
|
|
|
2019-03-21 18:14:48 +00:00
|
|
|
[[nodiscard]] bool canExportChatHistory() const;
|
|
|
|
|
2019-01-08 13:57:22 +00:00
|
|
|
// Returns true if about text was changed.
|
|
|
|
bool setAbout(const QString &newAbout);
|
2021-11-22 16:59:44 +00:00
|
|
|
[[nodiscard]] const QString &about() const {
|
2019-01-08 13:57:22 +00:00
|
|
|
return _about;
|
|
|
|
}
|
|
|
|
|
2019-04-23 09:40:14 +00:00
|
|
|
void checkFolder(FolderId folderId);
|
|
|
|
|
2021-07-08 14:30:27 +00:00
|
|
|
void setSettings(PeerSettings which) {
|
2019-06-07 11:32:58 +00:00
|
|
|
_settings.set(which);
|
|
|
|
}
|
2021-11-22 16:59:44 +00:00
|
|
|
[[nodiscard]] auto settings() const {
|
2021-07-08 14:30:27 +00:00
|
|
|
return (_settings.current() & PeerSetting::Unknown)
|
2019-06-07 11:32:58 +00:00
|
|
|
? std::nullopt
|
|
|
|
: std::make_optional(_settings.current());
|
|
|
|
}
|
2021-11-22 16:59:44 +00:00
|
|
|
[[nodiscard]] auto settingsValue() const {
|
2021-07-08 14:30:27 +00:00
|
|
|
return (_settings.current() & PeerSetting::Unknown)
|
2019-06-07 11:32:58 +00:00
|
|
|
? _settings.changes()
|
2019-06-22 20:42:30 +00:00
|
|
|
: (_settings.value() | rpl::type_erased());
|
2019-06-07 11:32:58 +00:00
|
|
|
}
|
2021-11-22 16:59:44 +00:00
|
|
|
[[nodiscard]] QString requestChatTitle() const {
|
|
|
|
return _requestChatTitle;
|
|
|
|
}
|
|
|
|
[[nodiscard]] TimeId requestChatDate() const {
|
|
|
|
return _requestChatDate;
|
|
|
|
}
|
2019-06-07 11:32:58 +00:00
|
|
|
|
2021-07-08 14:30:27 +00:00
|
|
|
void setSettings(const MTPPeerSettings &data);
|
|
|
|
|
2020-09-01 06:44:18 +00:00
|
|
|
enum class BlockStatus : char {
|
|
|
|
Unknown,
|
|
|
|
Blocked,
|
|
|
|
NotBlocked,
|
2019-01-10 11:01:59 +00:00
|
|
|
};
|
2020-09-01 06:44:18 +00:00
|
|
|
[[nodiscard]] BlockStatus blockStatus() const {
|
|
|
|
return _blockStatus;
|
|
|
|
}
|
|
|
|
[[nodiscard]] bool isBlocked() const {
|
|
|
|
return (blockStatus() == BlockStatus::Blocked);
|
|
|
|
}
|
|
|
|
void setIsBlocked(bool is);
|
|
|
|
|
|
|
|
enum class LoadedStatus : char {
|
|
|
|
Not,
|
|
|
|
Minimal,
|
2021-10-12 12:50:18 +00:00
|
|
|
Normal,
|
2020-09-01 06:44:18 +00:00
|
|
|
Full,
|
|
|
|
};
|
|
|
|
[[nodiscard]] LoadedStatus loadedStatus() const {
|
|
|
|
return _loadedStatus;
|
|
|
|
}
|
|
|
|
[[nodiscard]] bool isMinimalLoaded() const {
|
|
|
|
return (loadedStatus() != LoadedStatus::Not);
|
|
|
|
}
|
2021-10-12 12:50:18 +00:00
|
|
|
[[nodiscard]] bool isLoaded() const {
|
|
|
|
return (loadedStatus() == LoadedStatus::Normal) || isFullLoaded();
|
|
|
|
}
|
2020-09-01 06:44:18 +00:00
|
|
|
[[nodiscard]] bool isFullLoaded() const {
|
|
|
|
return (loadedStatus() == LoadedStatus::Full);
|
|
|
|
}
|
|
|
|
void setLoadedStatus(LoadedStatus status);
|
2019-01-10 11:01:59 +00:00
|
|
|
|
2021-02-02 16:38:30 +00:00
|
|
|
[[nodiscard]] TimeId messagesTTL() const;
|
2021-02-15 10:31:04 +00:00
|
|
|
void setMessagesTTL(TimeId period);
|
2021-02-02 16:38:30 +00:00
|
|
|
|
2020-12-14 12:52:18 +00:00
|
|
|
[[nodiscard]] Data::GroupCall *groupCall() const;
|
2021-03-05 08:14:34 +00:00
|
|
|
[[nodiscard]] PeerId groupCallDefaultJoinAs() const;
|
2020-12-14 12:52:18 +00:00
|
|
|
|
2021-09-24 15:10:25 +00:00
|
|
|
void setThemeEmoji(const QString &emoticon);
|
2021-08-25 16:16:50 +00:00
|
|
|
[[nodiscard]] const QString &themeEmoji() const;
|
|
|
|
|
2019-01-10 11:01:59 +00:00
|
|
|
const PeerId id;
|
2020-09-17 15:13:12 +00:00
|
|
|
MTPinputPeer input = MTP_inputPeerEmpty();
|
2019-01-10 11:01:59 +00:00
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
protected:
|
|
|
|
void updateNameDelayed(
|
|
|
|
const QString &newName,
|
|
|
|
const QString &newNameOrPhone,
|
|
|
|
const QString &newUsername);
|
2022-05-16 11:38:35 +00:00
|
|
|
void updateUserpic(PhotoId photoId, MTP::DcId dcId, bool hasVideo);
|
2017-12-05 06:41:43 +00:00
|
|
|
void clearUserpic();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void fillNames();
|
2020-05-28 14:32:10 +00:00
|
|
|
[[nodiscard]] not_null<Ui::EmptyUserpic*> ensureEmptyUserpic() const;
|
2019-12-09 13:57:33 +00:00
|
|
|
[[nodiscard]] virtual auto unavailableReasons() const
|
|
|
|
-> const std::vector<Data::UnavailableReason> &;
|
2017-12-05 06:41:43 +00:00
|
|
|
|
2022-05-16 11:38:35 +00:00
|
|
|
void setUserpicChecked(
|
|
|
|
PhotoId photoId,
|
|
|
|
const ImageLocation &location,
|
|
|
|
bool hasVideo);
|
2017-12-12 11:45:40 +00:00
|
|
|
|
2020-01-09 17:24:54 +00:00
|
|
|
const not_null<Data::Session*> _owner;
|
2019-01-03 12:36:01 +00:00
|
|
|
|
2020-05-28 14:32:10 +00:00
|
|
|
mutable Data::CloudImage _userpic;
|
2017-12-05 06:41:43 +00:00
|
|
|
PhotoId _userpicPhotoId = kUnknownPhotoId;
|
2022-05-16 11:38:35 +00:00
|
|
|
bool _userpicHasVideo = false;
|
|
|
|
|
2017-12-05 08:43:18 +00:00
|
|
|
mutable std::unique_ptr<Ui::EmptyUserpic> _userpicEmpty;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2022-04-01 08:40:46 +00:00
|
|
|
Data::PeerNotifySettings _notify;
|
2017-12-04 17:46:03 +00:00
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
ClickHandlerPtr _openLink;
|
2018-01-22 09:33:09 +00:00
|
|
|
base::flat_set<QString> _nameWords; // for filtering
|
|
|
|
base::flat_set<QChar> _nameFirstLetters;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time _lastFullUpdate = 0;
|
2021-02-02 16:38:30 +00:00
|
|
|
|
2022-08-09 11:12:19 +00:00
|
|
|
QString _name;
|
|
|
|
int _nameVersion = 1;
|
|
|
|
|
2021-02-15 10:31:04 +00:00
|
|
|
TimeId _ttlPeriod = 0;
|
2017-09-26 11:49:16 +00:00
|
|
|
|
2021-07-08 14:30:27 +00:00
|
|
|
Settings _settings = PeerSettings(PeerSetting::Unknown);
|
2020-09-01 06:44:18 +00:00
|
|
|
BlockStatus _blockStatus = BlockStatus::Unknown;
|
|
|
|
LoadedStatus _loadedStatus = LoadedStatus::Not;
|
2019-06-07 11:32:58 +00:00
|
|
|
|
2021-11-22 16:59:44 +00:00
|
|
|
QString _requestChatTitle;
|
|
|
|
TimeId _requestChatDate = 0;
|
|
|
|
|
2019-01-08 13:57:22 +00:00
|
|
|
QString _about;
|
2021-09-24 15:10:25 +00:00
|
|
|
QString _themeEmoticon;
|
2019-01-08 13:57:22 +00:00
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
};
|
2019-01-14 17:43:06 +00:00
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
2019-06-19 15:09:03 +00:00
|
|
|
std::optional<QString> RestrictionError(
|
2019-01-14 17:43:06 +00:00
|
|
|
not_null<PeerData*> peer,
|
|
|
|
ChatRestriction restriction);
|
|
|
|
|
2022-07-18 20:35:16 +00:00
|
|
|
std::optional<QString> RestrictionError(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
UserRestriction restriction);
|
2022-07-14 19:25:04 +00:00
|
|
|
|
2022-10-11 15:08:19 +00:00
|
|
|
void SetTopPinnedMessageId(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
MsgId topicRootId,
|
|
|
|
MsgId messageId);
|
2020-10-22 12:40:33 +00:00
|
|
|
[[nodiscard]] FullMsgId ResolveTopPinnedId(
|
|
|
|
not_null<PeerData*> peer,
|
2022-10-11 15:08:19 +00:00
|
|
|
MsgId topicRootId,
|
2020-10-22 12:40:33 +00:00
|
|
|
PeerData *migrated);
|
2020-10-26 11:46:08 +00:00
|
|
|
[[nodiscard]] FullMsgId ResolveMinPinnedId(
|
|
|
|
not_null<PeerData*> peer,
|
2022-10-11 15:08:19 +00:00
|
|
|
MsgId topicRootId,
|
2020-10-22 12:40:33 +00:00
|
|
|
PeerData *migrated);
|
2020-10-21 11:07:49 +00:00
|
|
|
|
2019-01-14 17:43:06 +00:00
|
|
|
} // namespace Data
|