2019-01-04 11:09:48 +00: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 "data/data_peer.h"
|
|
|
|
#include "data/data_pts_waiter.h"
|
2019-06-21 12:27:46 +00:00
|
|
|
#include "data/data_location.h"
|
2021-11-21 19:48:08 +00:00
|
|
|
#include "data/data_chat_participant_status.h"
|
2022-05-14 21:27:21 +00:00
|
|
|
#include "data/data_peer_bot_commands.h"
|
2022-10-14 15:49:40 +00:00
|
|
|
#include "data/data_user_names.h"
|
2022-10-12 15:06:21 +00:00
|
|
|
|
2019-06-21 12:27:46 +00:00
|
|
|
struct ChannelLocation {
|
|
|
|
QString address;
|
|
|
|
Data::LocationPoint point;
|
|
|
|
|
|
|
|
friend inline bool operator==(
|
|
|
|
const ChannelLocation &a,
|
|
|
|
const ChannelLocation &b) {
|
|
|
|
return a.address.isEmpty()
|
|
|
|
? b.address.isEmpty()
|
|
|
|
: (a.address == b.address && a.point == b.point);
|
|
|
|
}
|
|
|
|
friend inline bool operator!=(
|
|
|
|
const ChannelLocation &a,
|
|
|
|
const ChannelLocation &b) {
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
};
|
2019-01-04 11:09:48 +00:00
|
|
|
|
2021-07-08 13:11:09 +00:00
|
|
|
enum class ChannelDataFlag {
|
|
|
|
Left = (1 << 0),
|
|
|
|
Creator = (1 << 1),
|
|
|
|
Forbidden = (1 << 2),
|
|
|
|
CallActive = (1 << 3),
|
|
|
|
CallNotEmpty = (1 << 4),
|
|
|
|
Signatures = (1 << 5),
|
|
|
|
Verified = (1 << 6),
|
|
|
|
Scam = (1 << 7),
|
|
|
|
Fake = (1 << 8),
|
|
|
|
Megagroup = (1 << 9),
|
|
|
|
Broadcast = (1 << 10),
|
|
|
|
Gigagroup = (1 << 11),
|
|
|
|
Username = (1 << 12),
|
|
|
|
Location = (1 << 13),
|
|
|
|
CanSetUsername = (1 << 14),
|
|
|
|
CanSetStickers = (1 << 15),
|
|
|
|
PreHistoryHidden = (1 << 16),
|
|
|
|
CanViewParticipants = (1 << 17),
|
|
|
|
HasLink = (1 << 18),
|
|
|
|
SlowmodeEnabled = (1 << 19),
|
2021-11-05 14:03:17 +00:00
|
|
|
NoForwards = (1 << 20),
|
2022-04-15 16:57:03 +00:00
|
|
|
JoinToWrite = (1 << 21),
|
|
|
|
RequestToJoin = (1 << 22),
|
2022-09-20 09:35:47 +00:00
|
|
|
Forum = (1 << 23),
|
2022-11-25 15:57:09 +00:00
|
|
|
AntiSpam = (1 << 24),
|
2022-12-16 14:22:56 +00:00
|
|
|
ParticipantsHidden = (1 << 25),
|
2021-07-08 13:11:09 +00:00
|
|
|
};
|
|
|
|
inline constexpr bool is_flag_type(ChannelDataFlag) { return true; };
|
|
|
|
using ChannelDataFlags = base::flags<ChannelDataFlag>;
|
|
|
|
|
2019-01-14 06:34:51 +00:00
|
|
|
class MegagroupInfo {
|
|
|
|
public:
|
2022-09-20 09:35:47 +00:00
|
|
|
MegagroupInfo();
|
|
|
|
~MegagroupInfo();
|
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
struct Admin {
|
2021-07-08 10:34:06 +00:00
|
|
|
explicit Admin(ChatAdminRightsInfo rights)
|
2019-01-04 11:09:48 +00:00
|
|
|
: rights(rights) {
|
|
|
|
}
|
2021-07-08 10:34:06 +00:00
|
|
|
Admin(ChatAdminRightsInfo rights, bool canEdit)
|
2019-01-04 11:09:48 +00:00
|
|
|
: rights(rights)
|
|
|
|
, canEdit(canEdit) {
|
|
|
|
}
|
2021-07-08 10:34:06 +00:00
|
|
|
ChatAdminRightsInfo rights;
|
2019-01-04 11:09:48 +00:00
|
|
|
bool canEdit = false;
|
|
|
|
};
|
2019-01-05 10:50:04 +00:00
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
struct Restricted {
|
2021-07-08 10:34:06 +00:00
|
|
|
explicit Restricted(ChatRestrictionsInfo rights)
|
2019-01-04 11:09:48 +00:00
|
|
|
: rights(rights) {
|
|
|
|
}
|
2021-07-08 10:34:06 +00:00
|
|
|
ChatRestrictionsInfo rights;
|
2019-01-04 11:09:48 +00:00
|
|
|
};
|
2019-01-05 10:50:04 +00:00
|
|
|
|
2019-01-14 06:34:51 +00:00
|
|
|
ChatData *getMigrateFromChat() const;
|
|
|
|
void setMigrateFromChat(ChatData *chat);
|
|
|
|
|
2019-06-21 12:27:46 +00:00
|
|
|
const ChannelLocation *getLocation() const;
|
|
|
|
void setLocation(const ChannelLocation &location);
|
|
|
|
|
2022-05-14 21:27:21 +00:00
|
|
|
Data::ChatBotCommands::Changed setBotCommands(
|
|
|
|
const std::vector<Data::BotCommands> &commands);
|
|
|
|
[[nodiscard]] const Data::ChatBotCommands &botCommands() const {
|
2021-07-01 11:05:15 +00:00
|
|
|
return _botCommands;
|
|
|
|
}
|
|
|
|
|
2022-09-26 13:37:32 +00:00
|
|
|
void ensureForum(not_null<ChannelData*> that);
|
2022-09-20 09:35:47 +00:00
|
|
|
[[nodiscard]] Data::Forum *forum() const;
|
2022-09-26 13:37:32 +00:00
|
|
|
[[nodiscard]] std::unique_ptr<Data::Forum> takeForumData();
|
2022-09-20 09:35:47 +00:00
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
std::deque<not_null<UserData*>> lastParticipants;
|
|
|
|
base::flat_map<not_null<UserData*>, Admin> lastAdmins;
|
|
|
|
base::flat_map<not_null<UserData*>, Restricted> lastRestricted;
|
|
|
|
base::flat_set<not_null<PeerData*>> markupSenders;
|
|
|
|
base::flat_set<not_null<UserData*>> bots;
|
|
|
|
|
2019-07-19 13:34:09 +00:00
|
|
|
// For admin badges, full admins list with ranks.
|
|
|
|
base::flat_map<UserId, QString> admins;
|
2019-01-04 11:09:48 +00:00
|
|
|
|
|
|
|
UserData *creator = nullptr; // nullptr means unknown
|
2019-07-19 13:34:09 +00:00
|
|
|
QString creatorRank;
|
2019-01-04 11:09:48 +00:00
|
|
|
int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other
|
|
|
|
bool joinedMessageFound = false;
|
2021-07-08 16:42:57 +00:00
|
|
|
StickerSetIdentifier stickerSet;
|
2019-01-04 11:09:48 +00:00
|
|
|
|
|
|
|
enum LastParticipantsStatus {
|
|
|
|
LastParticipantsUpToDate = 0x00,
|
2020-03-13 19:14:23 +00:00
|
|
|
LastParticipantsOnceReceived = 0x01,
|
2019-01-04 11:09:48 +00:00
|
|
|
LastParticipantsCountOutdated = 0x02,
|
|
|
|
};
|
|
|
|
mutable int lastParticipantsStatus = LastParticipantsUpToDate;
|
|
|
|
int lastParticipantsCount = 0;
|
|
|
|
|
2019-01-14 06:34:51 +00:00
|
|
|
private:
|
|
|
|
ChatData *_migratedFrom = nullptr;
|
2019-06-21 12:27:46 +00:00
|
|
|
ChannelLocation _location;
|
2022-05-14 21:27:21 +00:00
|
|
|
Data::ChatBotCommands _botCommands;
|
2022-09-20 09:35:47 +00:00
|
|
|
std::unique_ptr<Data::Forum> _forum;
|
2019-01-04 11:09:48 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2022-09-20 09:35:47 +00:00
|
|
|
class ChannelData final : public PeerData {
|
2019-01-04 11:09:48 +00:00
|
|
|
public:
|
2021-07-08 13:11:09 +00:00
|
|
|
using Flag = ChannelDataFlag;
|
|
|
|
using Flags = Data::Flags<ChannelDataFlags>;
|
2019-01-04 11:09:48 +00:00
|
|
|
|
2019-01-05 10:50:04 +00:00
|
|
|
using AdminRight = ChatAdminRight;
|
|
|
|
using Restriction = ChatRestriction;
|
|
|
|
using AdminRights = ChatAdminRights;
|
|
|
|
using Restrictions = ChatRestrictions;
|
|
|
|
using AdminRightFlags = Data::Flags<AdminRights>;
|
|
|
|
using RestrictionFlags = Data::Flags<Restrictions>;
|
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
ChannelData(not_null<Data::Session*> owner, PeerId id);
|
|
|
|
|
|
|
|
void setName(const QString &name, const QString &username);
|
2022-10-05 10:40:31 +00:00
|
|
|
void setUsername(const QString &username);
|
2022-10-14 15:49:40 +00:00
|
|
|
void setUsernames(const Data::Usernames &newUsernames);
|
2021-03-30 08:16:05 +00:00
|
|
|
void setPhoto(const MTPChatPhoto &photo);
|
2020-02-07 16:07:21 +00:00
|
|
|
void setAccessHash(uint64 accessHash);
|
2019-01-04 11:09:48 +00:00
|
|
|
|
2022-09-26 13:37:32 +00:00
|
|
|
void setFlags(ChannelDataFlags which);
|
|
|
|
void addFlags(ChannelDataFlags which);
|
|
|
|
void removeFlags(ChannelDataFlags which);
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] auto flags() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _flags.current();
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] auto flagsValue() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _flags.value();
|
|
|
|
}
|
|
|
|
|
2022-10-05 10:40:31 +00:00
|
|
|
[[nodiscard]] QString username() const;
|
2022-10-14 15:49:40 +00:00
|
|
|
[[nodiscard]] QString editableUsername() const;
|
2022-10-12 15:06:21 +00:00
|
|
|
[[nodiscard]] const std::vector<QString> &usernames() const;
|
2022-10-05 10:40:31 +00:00
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] int membersCount() const {
|
2019-05-20 18:40:53 +00:00
|
|
|
return std::max(_membersCount, 1);
|
2019-01-04 11:09:48 +00:00
|
|
|
}
|
|
|
|
void setMembersCount(int newMembersCount);
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool membersCountKnown() const {
|
2019-05-20 18:40:53 +00:00
|
|
|
return (_membersCount >= 0);
|
|
|
|
}
|
2019-01-04 11:09:48 +00:00
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] int adminsCount() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _adminsCount;
|
|
|
|
}
|
|
|
|
void setAdminsCount(int newAdminsCount);
|
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] int restrictedCount() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _restrictedCount;
|
|
|
|
}
|
|
|
|
void setRestrictedCount(int newRestrictedCount);
|
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] int kickedCount() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _kickedCount;
|
|
|
|
}
|
|
|
|
void setKickedCount(int newKickedCount);
|
|
|
|
|
2021-10-12 08:39:07 +00:00
|
|
|
[[nodiscard]] int pendingRequestsCount() const {
|
|
|
|
return _pendingRequestsCount;
|
|
|
|
}
|
2021-10-27 05:57:37 +00:00
|
|
|
[[nodiscard]] const std::vector<UserId> &recentRequesters() const {
|
|
|
|
return _recentRequesters;
|
|
|
|
}
|
|
|
|
void setPendingRequestsCount(
|
|
|
|
int count,
|
|
|
|
const QVector<MTPlong> &recentRequesters);
|
|
|
|
void setPendingRequestsCount(
|
|
|
|
int count,
|
|
|
|
std::vector<UserId> recentRequesters);
|
2021-10-12 08:39:07 +00:00
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool haveLeft() const {
|
2021-07-08 13:11:09 +00:00
|
|
|
return flags() & Flag::Left;
|
2019-01-04 11:09:48 +00:00
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool amIn() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return !isForbidden() && !haveLeft();
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool addsSignature() const {
|
2021-07-08 13:11:09 +00:00
|
|
|
return flags() & Flag::Signatures;
|
2019-01-04 11:09:48 +00:00
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool isForbidden() const {
|
2021-07-08 13:11:09 +00:00
|
|
|
return flags() & Flag::Forbidden;
|
2019-01-04 11:09:48 +00:00
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool isVerified() const {
|
2021-07-08 13:11:09 +00:00
|
|
|
return flags() & Flag::Verified;
|
2019-01-04 11:09:48 +00:00
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool isScam() const {
|
2021-07-08 13:11:09 +00:00
|
|
|
return flags() & Flag::Scam;
|
2019-06-23 12:18:33 +00:00
|
|
|
}
|
2021-01-21 12:39:40 +00:00
|
|
|
[[nodiscard]] bool isFake() const {
|
2021-07-08 13:11:09 +00:00
|
|
|
return flags() & Flag::Fake;
|
2021-01-21 12:39:40 +00:00
|
|
|
}
|
2019-01-04 11:09:48 +00:00
|
|
|
|
2021-07-08 10:34:06 +00:00
|
|
|
[[nodiscard]] static ChatRestrictionsInfo KickedRestrictedRights(
|
2021-03-19 15:10:44 +00:00
|
|
|
not_null<PeerData*> participant);
|
2019-01-04 11:09:48 +00:00
|
|
|
static constexpr auto kRestrictUntilForever = TimeId(INT_MAX);
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] static bool IsRestrictedForever(TimeId until) {
|
2019-01-04 11:09:48 +00:00
|
|
|
return !until || (until == kRestrictUntilForever);
|
|
|
|
}
|
|
|
|
void applyEditAdmin(
|
|
|
|
not_null<UserData*> user,
|
2021-07-08 10:34:06 +00:00
|
|
|
ChatAdminRightsInfo oldRights,
|
|
|
|
ChatAdminRightsInfo newRights,
|
2019-07-19 13:34:09 +00:00
|
|
|
const QString &rank);
|
2019-01-04 11:09:48 +00:00
|
|
|
void applyEditBanned(
|
2021-03-19 14:01:21 +00:00
|
|
|
not_null<PeerData*> participant,
|
2021-07-08 10:34:06 +00:00
|
|
|
ChatRestrictionsInfo oldRights,
|
|
|
|
ChatRestrictionsInfo newRights);
|
2019-01-04 11:09:48 +00:00
|
|
|
|
2019-04-09 13:18:47 +00:00
|
|
|
void markForbidden();
|
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool isGroupAdmin(not_null<UserData*> user) const;
|
2020-03-13 19:14:23 +00:00
|
|
|
[[nodiscard]] bool lastParticipantsRequestNeeded() const;
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool isMegagroup() const {
|
2021-07-08 13:11:09 +00:00
|
|
|
return flags() & Flag::Megagroup;
|
2019-01-04 11:09:48 +00:00
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool isBroadcast() const {
|
2021-07-08 13:11:09 +00:00
|
|
|
return flags() & Flag::Broadcast;
|
2019-01-04 11:09:48 +00:00
|
|
|
}
|
2021-02-12 15:07:41 +00:00
|
|
|
[[nodiscard]] bool isGigagroup() const {
|
2021-07-08 13:11:09 +00:00
|
|
|
return flags() & Flag::Gigagroup;
|
2021-02-12 15:07:41 +00:00
|
|
|
}
|
2022-09-20 09:35:47 +00:00
|
|
|
[[nodiscard]] bool isForum() const {
|
|
|
|
return flags() & Flag::Forum;
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool hasUsername() const {
|
2021-07-08 13:11:09 +00:00
|
|
|
return flags() & Flag::Username;
|
2019-01-04 11:09:48 +00:00
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool hasLocation() const {
|
2021-07-08 13:11:09 +00:00
|
|
|
return flags() & Flag::Location;
|
2019-06-21 12:27:46 +00:00
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool isPublic() const {
|
2019-06-21 12:27:46 +00:00
|
|
|
return hasUsername() || hasLocation();
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool amCreator() const {
|
2021-07-08 13:11:09 +00:00
|
|
|
return flags() & Flag::Creator;
|
2019-01-04 11:09:48 +00:00
|
|
|
}
|
2022-04-15 16:57:03 +00:00
|
|
|
[[nodiscard]] bool joinToWrite() const {
|
|
|
|
return flags() & Flag::JoinToWrite;
|
|
|
|
}
|
|
|
|
[[nodiscard]] bool requestToJoin() const {
|
|
|
|
return flags() & Flag::RequestToJoin;
|
|
|
|
}
|
2022-11-25 15:57:09 +00:00
|
|
|
[[nodiscard]] bool antiSpamMode() const {
|
|
|
|
return flags() & Flag::AntiSpam;
|
|
|
|
}
|
2019-01-04 11:09:48 +00:00
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] auto adminRights() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _adminRights.current();
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] auto adminRightsValue() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _adminRights.value();
|
|
|
|
}
|
2021-07-08 10:34:06 +00:00
|
|
|
void setAdminRights(ChatAdminRights rights);
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool hasAdminRights() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return (adminRights() != 0);
|
|
|
|
}
|
2019-01-05 10:50:04 +00:00
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] auto restrictions() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _restrictions.current();
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] auto restrictionsValue() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _restrictions.value();
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] TimeId restrictedUntil() const {
|
2019-01-05 10:50:04 +00:00
|
|
|
return _restrictedUntil;
|
2019-01-04 11:09:48 +00:00
|
|
|
}
|
2021-07-08 10:34:06 +00:00
|
|
|
void setRestrictions(ChatRestrictionsInfo rights);
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool hasRestrictions() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return (restrictions() != 0);
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool hasRestrictions(TimeId now) const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return hasRestrictions()
|
|
|
|
&& (restrictedUntil() > now);
|
|
|
|
}
|
2019-01-05 10:50:04 +00:00
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] auto defaultRestrictions() const {
|
2019-01-05 10:50:04 +00:00
|
|
|
return _defaultRestrictions.current();
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] auto defaultRestrictionsValue() const {
|
2019-01-05 10:50:04 +00:00
|
|
|
return _defaultRestrictions.value();
|
|
|
|
}
|
2021-07-08 10:34:06 +00:00
|
|
|
void setDefaultRestrictions(ChatRestrictions rights);
|
2019-01-05 10:50:04 +00:00
|
|
|
|
|
|
|
// Like in ChatData.
|
2021-11-05 14:03:17 +00:00
|
|
|
[[nodiscard]] bool allowsForwarding() const;
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool canEditInformation() const;
|
|
|
|
[[nodiscard]] bool canEditPermissions() const;
|
|
|
|
[[nodiscard]] bool canEditUsername() const;
|
|
|
|
[[nodiscard]] bool canEditPreHistoryHidden() const;
|
|
|
|
[[nodiscard]] bool canAddMembers() const;
|
|
|
|
[[nodiscard]] bool canAddAdmins() const;
|
|
|
|
[[nodiscard]] bool canBanMembers() const;
|
|
|
|
[[nodiscard]] bool anyoneCanAddMembers() const;
|
|
|
|
|
|
|
|
[[nodiscard]] bool canEditMessages() const;
|
|
|
|
[[nodiscard]] bool canDeleteMessages() const;
|
|
|
|
[[nodiscard]] bool hiddenPreHistory() const;
|
|
|
|
[[nodiscard]] bool canPublish() const;
|
|
|
|
[[nodiscard]] bool canViewMembers() const;
|
|
|
|
[[nodiscard]] bool canViewAdmins() const;
|
|
|
|
[[nodiscard]] bool canViewBanned() const;
|
|
|
|
[[nodiscard]] bool canEditSignatures() const;
|
|
|
|
[[nodiscard]] bool canEditStickers() const;
|
|
|
|
[[nodiscard]] bool canDelete() const;
|
|
|
|
[[nodiscard]] bool canEditAdmin(not_null<UserData*> user) const;
|
2021-03-19 15:10:44 +00:00
|
|
|
[[nodiscard]] bool canRestrictParticipant(
|
|
|
|
not_null<PeerData*> participant) const;
|
2019-01-04 11:09:48 +00:00
|
|
|
|
|
|
|
void setInviteLink(const QString &newInviteLink);
|
2020-12-14 12:52:18 +00:00
|
|
|
[[nodiscard]] QString inviteLink() const {
|
|
|
|
return _inviteLink;
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool canHaveInviteLink() const;
|
2019-01-04 11:09:48 +00:00
|
|
|
|
2019-06-21 12:27:46 +00:00
|
|
|
void setLocation(const MTPChannelLocation &data);
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] const ChannelLocation *getLocation() const;
|
2019-06-21 12:27:46 +00:00
|
|
|
|
2019-05-23 21:38:49 +00:00
|
|
|
void setLinkedChat(ChannelData *linked);
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] ChannelData *linkedChat() const;
|
2020-09-10 11:56:46 +00:00
|
|
|
[[nodiscard]] bool linkedChatKnown() const;
|
2019-05-23 21:38:49 +00:00
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
void ptsInit(int32 pts) {
|
|
|
|
_ptsWaiter.init(pts);
|
|
|
|
}
|
|
|
|
void ptsReceived(int32 pts) {
|
|
|
|
_ptsWaiter.updateAndApply(this, pts, 0);
|
|
|
|
}
|
|
|
|
bool ptsUpdateAndApply(int32 pts, int32 count) {
|
|
|
|
return _ptsWaiter.updateAndApply(this, pts, count);
|
|
|
|
}
|
|
|
|
bool ptsUpdateAndApply(
|
2019-01-05 10:50:04 +00:00
|
|
|
int32 pts,
|
|
|
|
int32 count,
|
|
|
|
const MTPUpdate &update) {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _ptsWaiter.updateAndApply(this, pts, count, update);
|
|
|
|
}
|
|
|
|
bool ptsUpdateAndApply(
|
2019-07-16 11:46:50 +00:00
|
|
|
int32 pts,
|
|
|
|
int32 count,
|
|
|
|
const MTPUpdates &updates) {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _ptsWaiter.updateAndApply(this, pts, count, updates);
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] int32 pts() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _ptsWaiter.current();
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool ptsInited() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _ptsWaiter.inited();
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool ptsRequesting() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _ptsWaiter.requesting();
|
|
|
|
}
|
|
|
|
void ptsSetRequesting(bool isRequesting) {
|
|
|
|
return _ptsWaiter.setRequesting(isRequesting);
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
// < 0 - not waiting
|
|
|
|
void ptsWaitingForShortPoll(int32 ms) {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _ptsWaiter.setWaitingForShortPoll(this, ms);
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool ptsWaitingForSkipped() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _ptsWaiter.waitingForSkipped();
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool ptsWaitingForShortPoll() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _ptsWaiter.waitingForShortPoll();
|
|
|
|
}
|
|
|
|
|
2019-12-09 13:57:33 +00:00
|
|
|
void setUnavailableReasons(
|
|
|
|
std::vector<Data::UnavailableReason> &&reason);
|
2019-01-04 11:09:48 +00:00
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] MsgId availableMinId() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _availableMinId;
|
|
|
|
}
|
|
|
|
void setAvailableMinId(MsgId availableMinId);
|
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] ChatData *getMigrateFromChat() const;
|
2019-01-14 06:34:51 +00:00
|
|
|
void setMigrateFromChat(ChatData *chat);
|
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] int slowmodeSeconds() const;
|
|
|
|
void setSlowmodeSeconds(int seconds);
|
|
|
|
[[nodiscard]] TimeId slowmodeLastMessage() const;
|
2019-07-16 13:59:50 +00:00
|
|
|
void growSlowmodeLastMessage(TimeId when);
|
2019-07-16 11:46:50 +00:00
|
|
|
|
2020-07-01 14:19:25 +00:00
|
|
|
void setInvitePeek(const QString &hash, TimeId expires);
|
|
|
|
void clearInvitePeek();
|
|
|
|
[[nodiscard]] TimeId invitePeekExpires() const;
|
|
|
|
[[nodiscard]] QString invitePeekHash() const;
|
|
|
|
void privateErrorReceived();
|
|
|
|
|
2020-12-14 12:52:18 +00:00
|
|
|
[[nodiscard]] Data::GroupCall *groupCall() const {
|
2020-11-20 19:25:35 +00:00
|
|
|
return _call.get();
|
|
|
|
}
|
2020-12-14 12:52:18 +00:00
|
|
|
void migrateCall(std::unique_ptr<Data::GroupCall> call);
|
2021-04-12 11:36:19 +00:00
|
|
|
void setGroupCall(
|
|
|
|
const MTPInputGroupCall &call,
|
2022-02-25 11:14:15 +00:00
|
|
|
TimeId scheduleDate = 0,
|
|
|
|
bool rtmp = false);
|
2020-12-14 12:52:18 +00:00
|
|
|
void clearGroupCall();
|
2021-03-05 08:14:34 +00:00
|
|
|
void setGroupCallDefaultJoinAs(PeerId peerId);
|
|
|
|
[[nodiscard]] PeerId groupCallDefaultJoinAs() const;
|
2020-11-20 19:25:35 +00:00
|
|
|
|
2022-08-22 09:15:34 +00:00
|
|
|
void setAllowedReactions(Data::AllowedReactions value);
|
|
|
|
[[nodiscard]] const Data::AllowedReactions &allowedReactions() const;
|
2021-12-07 11:11:27 +00:00
|
|
|
|
2022-09-20 09:35:47 +00:00
|
|
|
[[nodiscard]] Data::Forum *forum() const {
|
|
|
|
return mgInfo ? mgInfo->forum() : nullptr;
|
|
|
|
}
|
|
|
|
|
2022-11-08 11:36:46 +00:00
|
|
|
void processTopics(const MTPVector<MTPForumTopic> &topics);
|
|
|
|
|
2019-01-05 10:50:04 +00:00
|
|
|
// Still public data members.
|
|
|
|
uint64 access = 0;
|
|
|
|
|
2020-09-17 15:13:12 +00:00
|
|
|
MTPinputChannel inputChannel = MTP_inputChannelEmpty();
|
2019-01-05 10:50:04 +00:00
|
|
|
|
|
|
|
int32 date = 0;
|
|
|
|
std::unique_ptr<MegagroupInfo> mgInfo;
|
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
// > 0 - user who invited me to channel, < 0 - not in channel.
|
|
|
|
UserId inviter = 0;
|
2019-01-05 10:50:04 +00:00
|
|
|
TimeId inviteDate = 0;
|
2021-10-14 11:42:51 +00:00
|
|
|
bool inviteViaRequest = false;
|
2019-01-05 10:50:04 +00:00
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
private:
|
2020-07-01 14:19:25 +00:00
|
|
|
struct InvitePeek {
|
|
|
|
QString hash;
|
|
|
|
TimeId expires = 0;
|
|
|
|
};
|
|
|
|
|
2019-12-09 13:57:33 +00:00
|
|
|
auto unavailableReasons() const
|
|
|
|
-> const std::vector<Data::UnavailableReason> & override;
|
2019-01-04 11:09:48 +00:00
|
|
|
bool canEditLastAdmin(not_null<UserData*> user) const;
|
|
|
|
|
2021-07-08 13:11:09 +00:00
|
|
|
Flags _flags = ChannelDataFlags(Flag::Forbidden);
|
2019-01-04 11:09:48 +00:00
|
|
|
|
|
|
|
PtsWaiter _ptsWaiter;
|
|
|
|
|
2022-10-14 15:49:40 +00:00
|
|
|
Data::UsernamesInfo _username;
|
2022-10-05 10:40:31 +00:00
|
|
|
|
2019-05-20 18:40:53 +00:00
|
|
|
int _membersCount = -1;
|
2019-01-04 11:09:48 +00:00
|
|
|
int _adminsCount = 1;
|
|
|
|
int _restrictedCount = 0;
|
|
|
|
int _kickedCount = 0;
|
2021-10-12 08:39:07 +00:00
|
|
|
int _pendingRequestsCount = 0;
|
2021-10-27 05:57:37 +00:00
|
|
|
std::vector<UserId> _recentRequesters;
|
2019-01-04 11:09:48 +00:00
|
|
|
MsgId _availableMinId = 0;
|
|
|
|
|
2019-01-05 10:50:04 +00:00
|
|
|
RestrictionFlags _defaultRestrictions;
|
2019-01-04 11:09:48 +00:00
|
|
|
AdminRightFlags _adminRights;
|
|
|
|
RestrictionFlags _restrictions;
|
2019-01-05 10:50:04 +00:00
|
|
|
TimeId _restrictedUntil;
|
2019-01-04 11:09:48 +00:00
|
|
|
|
2019-12-09 13:57:33 +00:00
|
|
|
std::vector<Data::UnavailableReason> _unavailableReasons;
|
2020-07-01 14:19:25 +00:00
|
|
|
std::unique_ptr<InvitePeek> _invitePeek;
|
2019-01-04 11:09:48 +00:00
|
|
|
QString _inviteLink;
|
2020-09-10 11:56:46 +00:00
|
|
|
std::optional<ChannelData*> _linkedChat;
|
2019-01-04 11:09:48 +00:00
|
|
|
|
2022-08-22 09:15:34 +00:00
|
|
|
Data::AllowedReactions _allowedReactions;
|
2021-12-07 11:11:27 +00:00
|
|
|
|
2020-11-20 19:25:35 +00:00
|
|
|
std::unique_ptr<Data::GroupCall> _call;
|
2021-03-05 08:14:34 +00:00
|
|
|
PeerId _callDefaultJoinAs = 0;
|
2020-11-20 19:25:35 +00:00
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
int _slowmodeSeconds = 0;
|
|
|
|
TimeId _slowmodeLastMessage = 0;
|
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
};
|
2019-01-13 08:03:34 +00:00
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
2019-01-14 06:34:51 +00:00
|
|
|
void ApplyMigration(
|
|
|
|
not_null<ChatData*> chat,
|
|
|
|
not_null<ChannelData*> channel);
|
|
|
|
|
2019-01-13 08:03:34 +00:00
|
|
|
void ApplyChannelUpdate(
|
|
|
|
not_null<ChannelData*> channel,
|
|
|
|
const MTPDupdateChatDefaultBannedRights &update);
|
|
|
|
|
2019-04-23 09:40:14 +00:00
|
|
|
void ApplyChannelUpdate(
|
|
|
|
not_null<ChannelData*> channel,
|
|
|
|
const MTPDchannelFull &update);
|
|
|
|
|
2019-01-13 08:03:34 +00:00
|
|
|
} // namespace Data
|