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"
|
|
|
|
|
|
|
|
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
|
|
|
|
2019-01-14 06:34:51 +00:00
|
|
|
class MegagroupInfo {
|
|
|
|
public:
|
2019-01-04 11:09:48 +00:00
|
|
|
struct Admin {
|
|
|
|
explicit Admin(MTPChatAdminRights rights)
|
|
|
|
: rights(rights) {
|
|
|
|
}
|
|
|
|
Admin(MTPChatAdminRights rights, bool canEdit)
|
|
|
|
: rights(rights)
|
|
|
|
, canEdit(canEdit) {
|
|
|
|
}
|
|
|
|
MTPChatAdminRights rights;
|
|
|
|
bool canEdit = false;
|
|
|
|
};
|
2019-01-05 10:50:04 +00:00
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
struct Restricted {
|
|
|
|
explicit Restricted(MTPChatBannedRights rights)
|
|
|
|
: rights(rights) {
|
|
|
|
}
|
|
|
|
MTPChatBannedRights rights;
|
|
|
|
};
|
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);
|
|
|
|
|
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;
|
|
|
|
MTPInputStickerSet stickerSet = MTP_inputStickerSetEmpty();
|
|
|
|
|
|
|
|
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;
|
2019-01-04 11:09:48 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class ChannelData : public PeerData {
|
|
|
|
public:
|
|
|
|
static constexpr auto kEssentialFlags = 0
|
|
|
|
| MTPDchannel::Flag::f_creator
|
|
|
|
| MTPDchannel::Flag::f_left
|
2019-01-14 06:34:51 +00:00
|
|
|
| MTPDchannel_ClientFlag::f_forbidden
|
2019-01-04 11:09:48 +00:00
|
|
|
| MTPDchannel::Flag::f_broadcast
|
|
|
|
| MTPDchannel::Flag::f_verified
|
2019-06-23 12:18:33 +00:00
|
|
|
| MTPDchannel::Flag::f_scam
|
2021-01-21 12:39:40 +00:00
|
|
|
| MTPDchannel::Flag::f_fake
|
2019-01-04 11:09:48 +00:00
|
|
|
| MTPDchannel::Flag::f_megagroup
|
2021-02-12 15:07:41 +00:00
|
|
|
| MTPDchannel::Flag::f_gigagroup
|
2019-01-04 11:09:48 +00:00
|
|
|
| MTPDchannel::Flag::f_restricted
|
|
|
|
| MTPDchannel::Flag::f_signatures
|
2019-07-17 10:37:42 +00:00
|
|
|
| MTPDchannel::Flag::f_username
|
2020-12-06 13:28:27 +00:00
|
|
|
| MTPDchannel::Flag::f_call_not_empty
|
2019-07-17 10:37:42 +00:00
|
|
|
| MTPDchannel::Flag::f_slowmode_enabled;
|
2019-01-04 11:09:48 +00:00
|
|
|
using Flags = Data::Flags<
|
|
|
|
MTPDchannel::Flags,
|
|
|
|
kEssentialFlags>;
|
|
|
|
|
|
|
|
static constexpr auto kEssentialFullFlags = 0
|
|
|
|
| MTPDchannelFull::Flag::f_can_view_participants
|
|
|
|
| MTPDchannelFull::Flag::f_can_set_username
|
2019-06-21 12:27:46 +00:00
|
|
|
| MTPDchannelFull::Flag::f_can_set_stickers
|
2019-07-16 11:46:50 +00:00
|
|
|
| MTPDchannelFull::Flag::f_location
|
|
|
|
| MTPDchannelFull::Flag::f_slowmode_seconds
|
|
|
|
| MTPDchannelFull::Flag::f_slowmode_next_send_date;
|
2019-01-04 11:09:48 +00:00
|
|
|
using FullFlags = Data::Flags<
|
|
|
|
MTPDchannelFull::Flags,
|
|
|
|
kEssentialFullFlags>;
|
|
|
|
|
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);
|
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
|
|
|
|
|
|
|
void setFlags(MTPDchannel::Flags which) {
|
|
|
|
_flags.set(which);
|
|
|
|
}
|
|
|
|
void addFlags(MTPDchannel::Flags which) {
|
|
|
|
_flags.add(which);
|
|
|
|
}
|
|
|
|
void removeFlags(MTPDchannel::Flags which) {
|
|
|
|
_flags.remove(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();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setFullFlags(MTPDchannelFull::Flags which) {
|
|
|
|
_fullFlags.set(which);
|
|
|
|
}
|
|
|
|
void addFullFlags(MTPDchannelFull::Flags which) {
|
|
|
|
_fullFlags.add(which);
|
|
|
|
}
|
|
|
|
void removeFullFlags(MTPDchannelFull::Flags which) {
|
|
|
|
_fullFlags.remove(which);
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] auto fullFlags() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _fullFlags.current();
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] auto fullFlagsValue() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return _fullFlags.value();
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool haveLeft() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return flags() & MTPDchannel::Flag::f_left;
|
|
|
|
}
|
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 {
|
2019-01-04 11:09:48 +00:00
|
|
|
return flags() & MTPDchannel::Flag::f_signatures;
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool isForbidden() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return flags() & MTPDchannel_ClientFlag::f_forbidden;
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool isVerified() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return flags() & MTPDchannel::Flag::f_verified;
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool isScam() const {
|
2019-06-23 12:18:33 +00:00
|
|
|
return flags() & MTPDchannel::Flag::f_scam;
|
|
|
|
}
|
2021-01-21 12:39:40 +00:00
|
|
|
[[nodiscard]] bool isFake() const {
|
|
|
|
return flags() & MTPDchannel::Flag::f_fake;
|
|
|
|
}
|
2019-01-04 11:09:48 +00:00
|
|
|
|
2021-03-19 15:10:44 +00:00
|
|
|
static MTPChatBannedRights EmptyRestrictedRights(
|
|
|
|
not_null<PeerData*> participant);
|
|
|
|
static MTPChatBannedRights KickedRestrictedRights(
|
|
|
|
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,
|
|
|
|
const MTPChatAdminRights &oldRights,
|
2019-07-19 13:34:09 +00:00
|
|
|
const MTPChatAdminRights &newRights,
|
|
|
|
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,
|
2019-01-04 11:09:48 +00:00
|
|
|
const MTPChatBannedRights &oldRights,
|
|
|
|
const MTPChatBannedRights &newRights);
|
|
|
|
|
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 {
|
2019-01-04 11:09:48 +00:00
|
|
|
return flags() & MTPDchannel::Flag::f_megagroup;
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool isBroadcast() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return flags() & MTPDchannel::Flag::f_broadcast;
|
|
|
|
}
|
2021-02-12 15:07:41 +00:00
|
|
|
[[nodiscard]] bool isGigagroup() const {
|
|
|
|
return flags() & MTPDchannel::Flag::f_gigagroup;
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool hasUsername() const {
|
2019-01-04 11:09:48 +00:00
|
|
|
return flags() & MTPDchannel::Flag::f_username;
|
|
|
|
}
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool hasLocation() const {
|
2019-06-21 12:27:46 +00:00
|
|
|
return fullFlags() & MTPDchannelFull::Flag::f_location;
|
|
|
|
}
|
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 {
|
2019-01-04 11:09:48 +00:00
|
|
|
return flags() & MTPDchannel::Flag::f_creator;
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
void setAdminRights(const MTPChatAdminRights &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
|
|
|
}
|
2019-01-05 10:50:04 +00:00
|
|
|
void setRestrictions(const MTPChatBannedRights &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();
|
|
|
|
}
|
|
|
|
void setDefaultRestrictions(const MTPChatBannedRights &rights);
|
|
|
|
|
|
|
|
// Like in ChatData.
|
2019-07-16 11:46:50 +00:00
|
|
|
[[nodiscard]] bool canWrite() const;
|
|
|
|
[[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 canSendPolls() 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-01-13 08:03:34 +00:00
|
|
|
enum class UpdateStatus {
|
|
|
|
Good,
|
|
|
|
TooOld,
|
|
|
|
Skipped,
|
|
|
|
};
|
|
|
|
int version() const {
|
|
|
|
return _version;
|
|
|
|
}
|
|
|
|
void setVersion(int version) {
|
|
|
|
_version = version;
|
|
|
|
}
|
|
|
|
UpdateStatus applyUpdateVersion(int version);
|
|
|
|
|
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);
|
|
|
|
void setGroupCall(const MTPInputGroupCall &call);
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
|
QString username;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
Flags _flags = Flags(MTPDchannel_ClientFlag::f_forbidden | 0);
|
|
|
|
FullFlags _fullFlags;
|
|
|
|
|
|
|
|
PtsWaiter _ptsWaiter;
|
|
|
|
|
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;
|
|
|
|
MsgId _availableMinId = 0;
|
2019-01-13 08:03:34 +00:00
|
|
|
int _version = 0;
|
2019-01-04 11:09:48 +00:00
|
|
|
|
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
|
|
|
|
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
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
|
|
|
};
|
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-07-24 06:37:10 +00:00
|
|
|
void ApplyMegagroupAdmins(
|
2019-07-19 13:34:09 +00:00
|
|
|
not_null<ChannelData*> channel,
|
|
|
|
const MTPDchannels_channelParticipants &data);
|
|
|
|
|
2019-01-13 08:03:34 +00:00
|
|
|
} // namespace Data
|