mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-24 12:22:44 +00:00
Prepare legacy group restrictions checking.
This commit is contained in:
parent
441989a8e1
commit
61419b57c8
@ -665,7 +665,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_profile_manage_admins" = "Manage administrators";
|
||||
"lng_profile_manage_blocklist" = "Manage banned users";
|
||||
"lng_profile_manage_restrictedlist" = "Manage restricted users";
|
||||
"lng_profile_recent_actions" = "Recent actions";
|
||||
"lng_profile_common_groups#one" = "{count} group in common";
|
||||
"lng_profile_common_groups#other" = "{count} groups in common";
|
||||
"lng_profile_participants_section" = "Members";
|
||||
@ -1297,9 +1296,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_edit_contact_title" = "Edit contact name";
|
||||
"lng_edit_channel_title" = "Edit channel";
|
||||
"lng_edit_sign_messages" = "Sign messages";
|
||||
"lng_edit_group_who_invites" = "Who can add members";
|
||||
"lng_edit_group_invites_everybody" = "All members";
|
||||
"lng_edit_group_invites_only_admins" = "Only admins";
|
||||
"lng_edit_group" = "Edit group";
|
||||
"lng_edit_self_title" = "Edit your name";
|
||||
"lng_confirm_contact_data" = "New Contact";
|
||||
|
@ -1061,7 +1061,7 @@ void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mt
|
||||
|
||||
if (canViewAdmins != channel->canViewAdmins()
|
||||
|| canViewMembers != channel->canViewMembers()) {
|
||||
Notify::peerUpdatedDelayed(channel, UpdateFlag::ChannelRightsChanged);
|
||||
Notify::peerUpdatedDelayed(channel, UpdateFlag::RightsChanged);
|
||||
}
|
||||
|
||||
notifySettingReceived(MTP_inputNotifyPeer(peer->input), f.vnotify_settings);
|
||||
|
@ -159,8 +159,6 @@ namespace App {
|
||||
case mtpc_chatParticipants: {
|
||||
const auto &d(p.c_chatParticipants());
|
||||
chat = App::chat(d.vchat_id.v);
|
||||
// #TODO groups
|
||||
auto canEdit = chat->canEditInformation();
|
||||
if (!requestBotInfos || chat->version <= d.vversion.v) { // !requestBotInfos is true on getFullChat result
|
||||
chat->version = d.vversion.v;
|
||||
auto &v = d.vparticipants.v;
|
||||
@ -238,10 +236,6 @@ namespace App {
|
||||
}
|
||||
}
|
||||
}
|
||||
// #TODO groups
|
||||
if (canEdit != chat->canEditInformation()) {
|
||||
Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::ChatCanEdit);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::MembersChanged | Notify::PeerUpdate::Flag::AdminsChanged);
|
||||
@ -291,8 +285,6 @@ namespace App {
|
||||
Auth().api().requestPeer(chat);
|
||||
} else if (chat->version <= d.vversion.v && chat->count > 0) {
|
||||
chat->version = d.vversion.v;
|
||||
// #TODO groups
|
||||
auto canEdit = chat->canEditInformation();
|
||||
const auto user = App::userLoaded(d.vuser_id.v);
|
||||
if (user) {
|
||||
if (chat->participants.empty()) {
|
||||
@ -334,25 +326,19 @@ namespace App {
|
||||
chat->invalidateParticipants();
|
||||
chat->count--;
|
||||
}
|
||||
// #TODO groups
|
||||
if (canEdit != chat->canEditInformation()) {
|
||||
Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::ChatCanEdit);
|
||||
}
|
||||
Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::MembersChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void feedParticipantAdmin(const MTPDupdateChatParticipantAdmin &d) {
|
||||
ChatData *chat = App::chat(d.vchat_id.v);
|
||||
const auto chat = App::chat(d.vchat_id.v);
|
||||
if (chat->version + 1 < d.vversion.v) {
|
||||
chat->version = d.vversion.v;
|
||||
chat->invalidateParticipants();
|
||||
Auth().api().requestPeer(chat);
|
||||
} else if (chat->version <= d.vversion.v && chat->count > 0) {
|
||||
chat->version = d.vversion.v;
|
||||
// #TODO groups
|
||||
auto canEdit = chat->canEditInformation();
|
||||
UserData *user = App::userLoaded(d.vuser_id.v);
|
||||
const auto user = App::userLoaded(d.vuser_id.v);
|
||||
if (user) {
|
||||
if (mtpIsTrue(d.vis_admin)) {
|
||||
if (user->isSelf()) {
|
||||
@ -374,9 +360,6 @@ namespace App {
|
||||
} else {
|
||||
chat->invalidateParticipants();
|
||||
}
|
||||
if (canEdit != chat->canEditInformation()) {
|
||||
Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::ChatCanEdit);
|
||||
}
|
||||
Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::AdminsChanged);
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,6 @@ private:
|
||||
|
||||
void descriptionResized();
|
||||
void updateMaxHeight();
|
||||
void updateSelected(const QPoint &cursorGlobalPosition);
|
||||
|
||||
CreatingGroupType _creating;
|
||||
bool _fromTypeChoose = false;
|
||||
@ -138,7 +137,6 @@ private:
|
||||
};
|
||||
void privacyChanged(Privacy value);
|
||||
void updateSelected(const QPoint &cursorGlobalPosition);
|
||||
void showAddContactsToChannelBox() const;
|
||||
void handleChange();
|
||||
void check();
|
||||
void save();
|
||||
|
@ -844,22 +844,15 @@ std::unique_ptr<ChatsListBoxController::Row> AddBotToGroupBoxController::createR
|
||||
|
||||
bool AddBotToGroupBoxController::needToCreateRow(not_null<PeerData*> peer) const {
|
||||
if (sharingBotGame()) {
|
||||
if (!peer->canWrite()) {
|
||||
if (!peer->canWrite()
|
||||
|| peer->amRestricted(ChatRestriction::f_send_games)) {
|
||||
return false;
|
||||
}
|
||||
if (auto group = peer->asMegagroup()) {
|
||||
if (group->restricted(ChatRestriction::f_send_games)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (auto chat = peer->asChat()) {
|
||||
// #TODO groups
|
||||
if (chat->canEditInformation()) {
|
||||
return true;
|
||||
}
|
||||
} else if (auto group = peer->asMegagroup()) {
|
||||
if (const auto chat = peer->asChat()) {
|
||||
return chat->canAddMembers();
|
||||
} else if (const auto group = peer->asMegagroup()) {
|
||||
return group->canAddMembers();
|
||||
}
|
||||
return false;
|
||||
|
@ -61,10 +61,6 @@ private:
|
||||
Public,
|
||||
Private,
|
||||
};
|
||||
enum class Invites {
|
||||
Everyone,
|
||||
OnlyAdmins,
|
||||
};
|
||||
enum class HistoryVisibility {
|
||||
Visible,
|
||||
Hidden,
|
||||
@ -93,7 +89,6 @@ private:
|
||||
std::shared_ptr<Ui::RadioenumGroup<HistoryVisibility>> historyVisibility;
|
||||
Ui::SlideWrap<Ui::RpWidget> *historyVisibilityWrap = nullptr;
|
||||
|
||||
std::shared_ptr<Ui::RadioenumGroup<Invites>> invites;
|
||||
Ui::Checkbox *signatures = nullptr;
|
||||
};
|
||||
struct Saving {
|
||||
@ -102,7 +97,6 @@ private:
|
||||
std::optional<QString> description;
|
||||
std::optional<bool> hiddenPreHistory;
|
||||
std::optional<bool> signatures;
|
||||
std::optional<bool> everyoneInvites;
|
||||
};
|
||||
|
||||
Fn<QString()> computeTitle() const;
|
||||
@ -116,7 +110,6 @@ private:
|
||||
object_ptr<Ui::RpWidget> createInviteLinkEdit();
|
||||
object_ptr<Ui::RpWidget> createHistoryVisibilityEdit();
|
||||
object_ptr<Ui::RpWidget> createSignaturesEdit();
|
||||
object_ptr<Ui::RpWidget> createInvitesEdit();
|
||||
object_ptr<Ui::RpWidget> createStickersEdit();
|
||||
object_ptr<Ui::RpWidget> createManageAdminsButton();
|
||||
object_ptr<Ui::RpWidget> createUpgradeButton();
|
||||
@ -153,7 +146,6 @@ private:
|
||||
bool validateTitle(Saving &to) const;
|
||||
bool validateDescription(Saving &to) const;
|
||||
bool validateHistoryVisibility(Saving &to) const;
|
||||
bool validateInvites(Saving &to) const;
|
||||
bool validateSignatures(Saving &to) const;
|
||||
|
||||
void save();
|
||||
@ -161,7 +153,6 @@ private:
|
||||
void saveTitle();
|
||||
void saveDescription();
|
||||
void saveHistoryVisibility();
|
||||
void saveInvites();
|
||||
void saveSignatures();
|
||||
void savePhoto();
|
||||
void pushSaveStage(FnMut<void()> &&lambda);
|
||||
@ -218,7 +209,6 @@ object_ptr<Ui::VerticalLayout> Controller::createContent() {
|
||||
_wrap->add(createInviteLinkEdit());
|
||||
_wrap->add(createHistoryVisibilityEdit());
|
||||
_wrap->add(createSignaturesEdit());
|
||||
_wrap->add(createInvitesEdit());
|
||||
_wrap->add(createStickersEdit());
|
||||
_wrap->add(createManageAdminsButton());
|
||||
_wrap->add(createUpgradeButton());
|
||||
@ -917,57 +907,6 @@ object_ptr<Ui::RpWidget> Controller::createSignaturesEdit() {
|
||||
return std::move(result);
|
||||
}
|
||||
|
||||
object_ptr<Ui::RpWidget> Controller::createInvitesEdit() {
|
||||
Expects(_wrap != nullptr);
|
||||
|
||||
auto channel = _peer->asChannel();
|
||||
if (!channel
|
||||
|| !channel->canEditInvites()
|
||||
|| !channel->isMegagroup()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto result = object_ptr<Ui::PaddingWrap<Ui::VerticalLayout>>(
|
||||
_wrap,
|
||||
object_ptr<Ui::VerticalLayout>(_wrap),
|
||||
st::editPeerInvitesMargins);
|
||||
|
||||
auto container = result->entity();
|
||||
container->add(object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
Lang::Viewer(lng_edit_group_who_invites),
|
||||
st::editPeerSectionLabel));
|
||||
|
||||
_controls.invites = std::make_shared<Ui::RadioenumGroup<Invites>>(
|
||||
channel->anyoneCanAddMembers()
|
||||
? Invites::Everyone
|
||||
: Invites::OnlyAdmins);
|
||||
auto addButton = [&](
|
||||
Invites value,
|
||||
LangKey textKey) {
|
||||
container->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
container,
|
||||
st::editPeerInvitesTopSkip + st::editPeerInvitesSkip));
|
||||
container->add(object_ptr<Ui::Radioenum<Invites>>(
|
||||
container,
|
||||
_controls.invites,
|
||||
value,
|
||||
lang(textKey),
|
||||
st::defaultBoxCheckbox));
|
||||
};
|
||||
addButton(
|
||||
Invites::Everyone,
|
||||
lng_edit_group_invites_everybody);
|
||||
addButton(
|
||||
Invites::OnlyAdmins,
|
||||
lng_edit_group_invites_only_admins);
|
||||
container->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
container,
|
||||
st::editPeerInvitesSkip));
|
||||
|
||||
return std::move(result);
|
||||
}
|
||||
|
||||
object_ptr<Ui::RpWidget> Controller::createStickersEdit() {
|
||||
Expects(_wrap != nullptr);
|
||||
|
||||
@ -1102,7 +1041,6 @@ std::optional<Controller::Saving> Controller::validate() const {
|
||||
&& validateTitle(result)
|
||||
&& validateDescription(result)
|
||||
&& validateHistoryVisibility(result)
|
||||
&& validateInvites(result)
|
||||
&& validateSignatures(result)) {
|
||||
return result;
|
||||
}
|
||||
@ -1158,15 +1096,6 @@ bool Controller::validateHistoryVisibility(Saving &to) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Controller::validateInvites(Saving &to) const {
|
||||
if (!_controls.invites) {
|
||||
return true;
|
||||
}
|
||||
to.everyoneInvites
|
||||
= (_controls.invites->value() == Invites::Everyone);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Controller::validateSignatures(Saving &to) const {
|
||||
if (!_controls.signatures) {
|
||||
return true;
|
||||
@ -1187,7 +1116,6 @@ void Controller::save() {
|
||||
pushSaveStage([this] { saveTitle(); });
|
||||
pushSaveStage([this] { saveDescription(); });
|
||||
pushSaveStage([this] { saveHistoryVisibility(); });
|
||||
pushSaveStage([this] { saveInvites(); });
|
||||
pushSaveStage([this] { saveSignatures(); });
|
||||
pushSaveStage([this] { savePhoto(); });
|
||||
continueSave();
|
||||
@ -1351,29 +1279,6 @@ void Controller::saveHistoryVisibility() {
|
||||
}).send();
|
||||
}
|
||||
|
||||
void Controller::saveInvites() {
|
||||
auto channel = _peer->asChannel();
|
||||
if (!_savingData.everyoneInvites
|
||||
|| !channel
|
||||
|| *_savingData.everyoneInvites == channel->anyoneCanAddMembers()) {
|
||||
return continueSave();
|
||||
}
|
||||
// #TODO groups
|
||||
//request(MTPchannels_ToggleInvites(
|
||||
// channel->inputChannel,
|
||||
// MTP_bool(*_savingData.everyoneInvites)
|
||||
//)).done([this](const MTPUpdates &result) {
|
||||
// Auth().api().applyUpdates(result);
|
||||
// continueSave();
|
||||
//}).fail([this](const RPCError &error) {
|
||||
// if (error.type() == qstr("CHAT_NOT_MODIFIED")) {
|
||||
// continueSave();
|
||||
// } else {
|
||||
// cancelSave();
|
||||
// }
|
||||
//}).send();
|
||||
}
|
||||
|
||||
void Controller::saveSignatures() {
|
||||
auto channel = _peer->asChannel();
|
||||
if (!_savingData.signatures
|
||||
|
@ -352,7 +352,7 @@ TabbedSelector::TabbedSelector(
|
||||
subscribe(
|
||||
Notify::PeerUpdated(),
|
||||
Notify::PeerUpdatedHandler(
|
||||
Notify::PeerUpdate::Flag::ChannelRightsChanged,
|
||||
Notify::PeerUpdate::Flag::RightsChanged,
|
||||
handleUpdate));
|
||||
|
||||
Auth().api().stickerSetInstalled(
|
||||
@ -672,9 +672,12 @@ void TabbedSelector::setCurrentPeer(PeerData *peer) {
|
||||
}
|
||||
|
||||
void TabbedSelector::checkRestrictedPeer() {
|
||||
if (auto megagroup = _currentPeer ? _currentPeer->asMegagroup() : nullptr) {
|
||||
auto restricted = (_currentTabType == SelectorTab::Stickers) ? megagroup->restricted(ChatRestriction::f_send_stickers) :
|
||||
(_currentTabType == SelectorTab::Gifs) ? megagroup->restricted(ChatRestriction::f_send_gifs) : false;
|
||||
if (_currentPeer) {
|
||||
const auto restricted = (_currentTabType == SelectorTab::Stickers)
|
||||
? _currentPeer->amRestricted(ChatRestriction::f_send_stickers)
|
||||
: (_currentTabType == SelectorTab::Gifs)
|
||||
? _currentPeer->amRestricted(ChatRestriction::f_send_gifs)
|
||||
: false;
|
||||
if (restricted) {
|
||||
if (!_restrictedLabel) {
|
||||
auto text = (_currentTabType == SelectorTab::Stickers)
|
||||
|
@ -318,21 +318,17 @@ bool ChannelData::hiddenPreHistory() const {
|
||||
}
|
||||
|
||||
bool ChannelData::canAddMembers() const {
|
||||
return (adminRights() & AdminRight::f_invite_users)
|
||||
|| amCreator()
|
||||
|| (anyoneCanAddMembers()
|
||||
&& amIn()
|
||||
&& !hasRestrictions());
|
||||
return !amRestricted(ChatRestriction::f_invite_users);
|
||||
}
|
||||
|
||||
bool ChannelData::canAddAdmins() const {
|
||||
return (adminRights() & AdminRight::f_add_admins)
|
||||
|| amCreator();
|
||||
return amCreator()
|
||||
|| (adminRights() & AdminRight::f_add_admins);
|
||||
}
|
||||
|
||||
bool ChannelData::canPublish() const {
|
||||
return (adminRights() & AdminRight::f_post_messages)
|
||||
|| amCreator();
|
||||
return amCreator()
|
||||
|| (adminRights() & AdminRight::f_post_messages);
|
||||
}
|
||||
|
||||
bool ChannelData::canWrite() const {
|
||||
@ -340,7 +336,7 @@ bool ChannelData::canWrite() const {
|
||||
return amIn()
|
||||
&& (canPublish()
|
||||
|| (!isBroadcast()
|
||||
&& !restricted(Restriction::f_send_messages)));
|
||||
&& !amRestricted(Restriction::f_send_messages)));
|
||||
}
|
||||
|
||||
bool ChannelData::canViewMembers() const {
|
||||
@ -357,12 +353,7 @@ bool ChannelData::canViewBanned() const {
|
||||
}
|
||||
|
||||
bool ChannelData::canEditInformation() const {
|
||||
return (adminRights() & AdminRight::f_change_info)
|
||||
|| amCreator();
|
||||
}
|
||||
|
||||
bool ChannelData::canEditInvites() const {
|
||||
return canEditInformation();
|
||||
return !amRestricted(Restriction::f_change_info);
|
||||
}
|
||||
|
||||
bool ChannelData::canEditSignatures() const {
|
||||
@ -375,13 +366,11 @@ bool ChannelData::canEditPreHistoryHidden() const {
|
||||
|
||||
bool ChannelData::canEditUsername() const {
|
||||
return amCreator()
|
||||
&& (fullFlags()
|
||||
& MTPDchannelFull::Flag::f_can_set_username);
|
||||
&& (fullFlags() & MTPDchannelFull::Flag::f_can_set_username);
|
||||
}
|
||||
|
||||
bool ChannelData::canEditStickers() const {
|
||||
return (fullFlags()
|
||||
& MTPDchannelFull::Flag::f_can_set_stickers);
|
||||
return (fullFlags() & MTPDchannelFull::Flag::f_can_set_stickers);
|
||||
}
|
||||
|
||||
bool ChannelData::canDelete() const {
|
||||
@ -447,15 +436,15 @@ void ChannelData::setAdminRights(const MTPChatAdminRights &rights) {
|
||||
auto amAdmin = hasAdminRights() || amCreator();
|
||||
Data::ChannelAdminChanges(this).feed(session().userId(), amAdmin);
|
||||
}
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::ChannelRightsChanged | UpdateFlag::AdminsChanged | UpdateFlag::BannedUsersChanged);
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::RightsChanged | UpdateFlag::AdminsChanged | UpdateFlag::BannedUsersChanged);
|
||||
}
|
||||
|
||||
void ChannelData::setRestrictedRights(const MTPChatBannedRights &rights) {
|
||||
void ChannelData::setRestrictions(const MTPChatBannedRights &rights) {
|
||||
if (rights.c_chatBannedRights().vflags.v == restrictions()
|
||||
&& rights.c_chatBannedRights().vuntil_date.v == _restrictedUntill) {
|
||||
&& rights.c_chatBannedRights().vuntil_date.v == _restrictedUntil) {
|
||||
return;
|
||||
}
|
||||
_restrictedUntill = rights.c_chatBannedRights().vuntil_date.v;
|
||||
_restrictedUntil = rights.c_chatBannedRights().vuntil_date.v;
|
||||
_restrictions.set(rights.c_chatBannedRights().vflags.v);
|
||||
if (isMegagroup()) {
|
||||
const auto self = session().user();
|
||||
@ -470,5 +459,13 @@ void ChannelData::setRestrictedRights(const MTPChatBannedRights &rights) {
|
||||
mgInfo->lastRestricted.remove(self);
|
||||
}
|
||||
}
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::ChannelRightsChanged | UpdateFlag::AdminsChanged | UpdateFlag::BannedUsersChanged);
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::RightsChanged | UpdateFlag::AdminsChanged | UpdateFlag::BannedUsersChanged);
|
||||
}
|
||||
|
||||
void ChannelData::setDefaultRestrictions(const MTPChatBannedRights &rights) {
|
||||
if (rights.c_chatBannedRights().vflags.v == defaultRestrictions()) {
|
||||
return;
|
||||
}
|
||||
_defaultRestrictions.set(rights.c_chatBannedRights().vflags.v);
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::RightsChanged);
|
||||
}
|
||||
|
@ -22,12 +22,14 @@ struct MegagroupInfo {
|
||||
MTPChatAdminRights rights;
|
||||
bool canEdit = false;
|
||||
};
|
||||
|
||||
struct Restricted {
|
||||
explicit Restricted(MTPChatBannedRights rights)
|
||||
: rights(rights) {
|
||||
}
|
||||
MTPChatBannedRights rights;
|
||||
};
|
||||
|
||||
std::deque<not_null<UserData*>> lastParticipants;
|
||||
base::flat_map<not_null<UserData*>, Admin> lastAdmins;
|
||||
base::flat_map<not_null<UserData*>, Restricted> lastRestricted;
|
||||
@ -76,6 +78,13 @@ public:
|
||||
MTPDchannelFull::Flags,
|
||||
kEssentialFullFlags>;
|
||||
|
||||
using AdminRight = ChatAdminRight;
|
||||
using Restriction = ChatRestriction;
|
||||
using AdminRights = ChatAdminRights;
|
||||
using Restrictions = ChatRestrictions;
|
||||
using AdminRightFlags = Data::Flags<AdminRights>;
|
||||
using RestrictionFlags = Data::Flags<Restrictions>;
|
||||
|
||||
ChannelData(not_null<Data::Session*> owner, PeerId id);
|
||||
|
||||
void setPhoto(const MTPChatPhoto &photo);
|
||||
@ -115,12 +124,6 @@ public:
|
||||
return _fullFlags.value();
|
||||
}
|
||||
|
||||
uint64 access = 0;
|
||||
|
||||
MTPinputChannel inputChannel;
|
||||
|
||||
QString username;
|
||||
|
||||
// Returns true if about text was changed.
|
||||
bool setAbout(const QString &newAbout);
|
||||
const QString &about() const {
|
||||
@ -179,9 +182,6 @@ public:
|
||||
|
||||
bool isGroupAdmin(not_null<UserData*> user) const;
|
||||
|
||||
int32 date = 0;
|
||||
int version = 0;
|
||||
std::unique_ptr<MegagroupInfo> mgInfo;
|
||||
bool lastParticipantsCountOutdated() const {
|
||||
if (!mgInfo
|
||||
|| !(mgInfo->lastParticipantsStatus
|
||||
@ -208,12 +208,6 @@ public:
|
||||
return flags() & MTPDchannel::Flag::f_creator;
|
||||
}
|
||||
|
||||
using AdminRight = ChatAdminRight;
|
||||
using Restriction = ChatRestriction;
|
||||
using AdminRights = ChatAdminRights;
|
||||
using Restrictions = ChatRestrictions;
|
||||
using AdminRightFlags = Data::Flags<AdminRights>;
|
||||
using RestrictionFlags = Data::Flags<Restrictions>;
|
||||
auto adminRights() const {
|
||||
return _adminRights.current();
|
||||
}
|
||||
@ -224,19 +218,17 @@ public:
|
||||
bool hasAdminRights() const {
|
||||
return (adminRights() != 0);
|
||||
}
|
||||
|
||||
auto restrictions() const {
|
||||
return _restrictions.current();
|
||||
}
|
||||
auto restrictionsValue() const {
|
||||
return _restrictions.value();
|
||||
}
|
||||
bool restricted(Restriction right) const {
|
||||
return restrictions() & right;
|
||||
}
|
||||
TimeId restrictedUntil() const {
|
||||
return _restrictedUntill;
|
||||
return _restrictedUntil;
|
||||
}
|
||||
void setRestrictedRights(const MTPChatBannedRights &rights);
|
||||
void setRestrictions(const MTPChatBannedRights &rights);
|
||||
bool hasRestrictions() const {
|
||||
return (restrictions() != 0);
|
||||
}
|
||||
@ -244,20 +236,30 @@ public:
|
||||
return hasRestrictions()
|
||||
&& (restrictedUntil() > now);
|
||||
}
|
||||
|
||||
auto defaultRestrictions() const {
|
||||
return _defaultRestrictions.current();
|
||||
}
|
||||
auto defaultRestrictionsValue() const {
|
||||
return _defaultRestrictions.value();
|
||||
}
|
||||
void setDefaultRestrictions(const MTPChatBannedRights &rights);
|
||||
|
||||
// Like in ChatData.
|
||||
bool canWrite() const;
|
||||
bool canEditInformation() const;
|
||||
bool canAddMembers() const;
|
||||
|
||||
bool canBanMembers() const;
|
||||
bool canEditMessages() const;
|
||||
bool canDeleteMessages() const;
|
||||
bool anyoneCanAddMembers() const;
|
||||
bool hiddenPreHistory() const;
|
||||
bool canAddMembers() const;
|
||||
bool canAddAdmins() const;
|
||||
bool canPublish() const;
|
||||
bool canWrite() const;
|
||||
bool canViewMembers() const;
|
||||
bool canViewAdmins() const;
|
||||
bool canViewBanned() const;
|
||||
bool canEditInformation() const;
|
||||
bool canEditInvites() const;
|
||||
bool canEditSignatures() const;
|
||||
bool canEditPreHistoryHidden() const;
|
||||
bool canEditUsername() const;
|
||||
@ -270,9 +272,6 @@ public:
|
||||
QString inviteLink() const;
|
||||
bool canHaveInviteLink() const;
|
||||
|
||||
UserId inviter = 0; // > 0 - user who invited me to channel, < 0 - not in channel
|
||||
TimeId inviteDate = 0;
|
||||
|
||||
void ptsInit(int32 pts) {
|
||||
_ptsWaiter.init(pts);
|
||||
}
|
||||
@ -283,15 +282,15 @@ public:
|
||||
return _ptsWaiter.updateAndApply(this, pts, count);
|
||||
}
|
||||
bool ptsUpdateAndApply(
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdate &update) {
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdate &update) {
|
||||
return _ptsWaiter.updateAndApply(this, pts, count, update);
|
||||
}
|
||||
bool ptsUpdateAndApply(
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdates &updates) {
|
||||
int32 pts,
|
||||
int32 count,
|
||||
const MTPUpdates &updates) {
|
||||
return _ptsWaiter.updateAndApply(this, pts, count, updates);
|
||||
}
|
||||
int32 pts() const {
|
||||
@ -331,6 +330,20 @@ public:
|
||||
return _feed;
|
||||
}
|
||||
|
||||
// Still public data members.
|
||||
uint64 access = 0;
|
||||
|
||||
MTPinputChannel inputChannel;
|
||||
|
||||
QString username;
|
||||
|
||||
int32 date = 0;
|
||||
int version = 0;
|
||||
std::unique_ptr<MegagroupInfo> mgInfo;
|
||||
|
||||
UserId inviter = 0; // > 0 - user who invited me to channel, < 0 - not in channel
|
||||
TimeId inviteDate = 0;
|
||||
|
||||
private:
|
||||
void flagsUpdated(MTPDchannel::Flags diff);
|
||||
void fullFlagsUpdated(MTPDchannelFull::Flags diff);
|
||||
@ -349,9 +362,10 @@ private:
|
||||
int _kickedCount = 0;
|
||||
MsgId _availableMinId = 0;
|
||||
|
||||
RestrictionFlags _defaultRestrictions;
|
||||
AdminRightFlags _adminRights;
|
||||
RestrictionFlags _restrictions;
|
||||
TimeId _restrictedUntill;
|
||||
TimeId _restrictedUntil;
|
||||
|
||||
QString _unavailableReason;
|
||||
QString _about;
|
||||
|
@ -33,10 +33,24 @@ void ChatData::setPhoto(PhotoId photoId, const MTPChatPhoto &photo) {
|
||||
}
|
||||
}
|
||||
|
||||
bool ChatData::actionsUnavailable() const {
|
||||
return isDeactivated() || !amIn();
|
||||
}
|
||||
|
||||
bool ChatData::canWrite() const {
|
||||
// Duplicated in Data::CanWriteValue().
|
||||
return !actionsUnavailable()
|
||||
&& !amRestricted(ChatRestriction::f_send_messages);
|
||||
}
|
||||
|
||||
bool ChatData::canEditInformation() const {
|
||||
// #TODO groups
|
||||
return !isDeactivated()
|
||||
/*&& ((adminRights() & AdminRight::f_change_info) || amCreator())*/;
|
||||
return !actionsUnavailable()
|
||||
&& !amRestricted(ChatRestriction::f_change_info);
|
||||
}
|
||||
|
||||
bool ChatData::canAddMembers() const {
|
||||
return !actionsUnavailable()
|
||||
&& !amRestricted(ChatRestriction::f_invite_users);
|
||||
}
|
||||
|
||||
void ChatData::setName(const QString &newName) {
|
||||
@ -45,16 +59,14 @@ void ChatData::setName(const QString &newName) {
|
||||
|
||||
void ChatData::invalidateParticipants() {
|
||||
// #TODO groups
|
||||
auto wasCanEdit = canEditInformation();
|
||||
participants.clear();
|
||||
admins.clear();
|
||||
//removeFlags(MTPDchat::Flag::f_admin);
|
||||
invitedByMe.clear();
|
||||
botStatus = 0;
|
||||
if (wasCanEdit != canEditInformation()) {
|
||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::ChatCanEdit);
|
||||
}
|
||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::MembersChanged | Notify::PeerUpdate::Flag::AdminsChanged);
|
||||
Notify::peerUpdatedDelayed(
|
||||
this,
|
||||
UpdateFlag::MembersChanged | UpdateFlag::AdminsChanged);
|
||||
}
|
||||
|
||||
void ChatData::setInviteLink(const QString &newInviteLink) {
|
||||
@ -63,3 +75,23 @@ void ChatData::setInviteLink(const QString &newInviteLink) {
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::InviteLinkChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatData::setAdminRights(const MTPChatAdminRights &rights) {
|
||||
if (rights.c_chatAdminRights().vflags.v == adminRights()) {
|
||||
return;
|
||||
}
|
||||
_adminRights.set(rights.c_chatAdminRights().vflags.v);
|
||||
Notify::peerUpdatedDelayed(
|
||||
this,
|
||||
(UpdateFlag::RightsChanged
|
||||
| UpdateFlag::AdminsChanged
|
||||
| UpdateFlag::BannedUsersChanged));
|
||||
}
|
||||
|
||||
void ChatData::setDefaultRestrictions(const MTPChatBannedRights &rights) {
|
||||
if (rights.c_chatBannedRights().vflags.v == defaultRestrictions()) {
|
||||
return;
|
||||
}
|
||||
_defaultRestrictions.set(rights.c_chatBannedRights().vflags.v);
|
||||
Notify::peerUpdatedDelayed(this, UpdateFlag::RightsChanged);
|
||||
}
|
||||
|
@ -23,6 +23,13 @@ public:
|
||||
MTPDchat::Flags,
|
||||
kEssentialFlags>;
|
||||
|
||||
using AdminRight = ChatAdminRight;
|
||||
using Restriction = ChatRestriction;
|
||||
using AdminRights = ChatAdminRights;
|
||||
using Restrictions = ChatRestrictions;
|
||||
using AdminRightFlags = Data::Flags<AdminRights>;
|
||||
using RestrictionFlags = Data::Flags<Restrictions>;
|
||||
|
||||
ChatData(not_null<Data::Session*> owner, PeerId id);
|
||||
|
||||
void setPhoto(const MTPChatPhoto &photo);
|
||||
@ -35,15 +42,6 @@ public:
|
||||
return (count > 0 || amIn()) && participants.empty();
|
||||
}
|
||||
|
||||
MTPint inputChat;
|
||||
|
||||
ChannelData *migrateToPtr = nullptr;
|
||||
|
||||
int count = 0;
|
||||
TimeId date = 0;
|
||||
int version = 0;
|
||||
UserId creator = 0;
|
||||
|
||||
void setFlags(MTPDchat::Flags which) {
|
||||
_flags.set(which);
|
||||
}
|
||||
@ -60,17 +58,31 @@ public:
|
||||
return _flags.value();
|
||||
}
|
||||
|
||||
auto adminRights() const {
|
||||
return _adminRights.current();
|
||||
}
|
||||
auto adminRightsValue() const {
|
||||
return _adminRights.value();
|
||||
}
|
||||
void setAdminRights(const MTPChatAdminRights &rights);
|
||||
bool hasAdminRights() const {
|
||||
return (adminRights() != 0);
|
||||
}
|
||||
|
||||
auto defaultRestrictions() const {
|
||||
return _defaultRestrictions.current();
|
||||
}
|
||||
auto defaultRestrictionsValue() const {
|
||||
return _defaultRestrictions.value();
|
||||
}
|
||||
void setDefaultRestrictions(const MTPChatBannedRights &rights);
|
||||
|
||||
bool isForbidden() const {
|
||||
return flags() & MTPDchat_ClientFlag::f_forbidden;
|
||||
}
|
||||
bool amIn() const {
|
||||
return !isForbidden() && !haveLeft() && !wasKicked();
|
||||
}
|
||||
bool canEditInformation() const;
|
||||
bool canWrite() const {
|
||||
// Duplicated in Data::CanWriteValue().
|
||||
return !isDeactivated() && amIn();
|
||||
}
|
||||
bool haveLeft() const {
|
||||
return flags() & MTPDchat::Flag::f_left;
|
||||
}
|
||||
@ -86,6 +98,27 @@ public:
|
||||
bool isMigrated() const {
|
||||
return flags() & MTPDchat::Flag::f_migrated_to;
|
||||
}
|
||||
|
||||
// Like in ChatData.
|
||||
bool canWrite() const;
|
||||
bool canEditInformation() const;
|
||||
bool canAddMembers() const;
|
||||
|
||||
void setInviteLink(const QString &newInviteLink);
|
||||
QString inviteLink() const {
|
||||
return _inviteLink;
|
||||
}
|
||||
|
||||
// Still public data members.
|
||||
MTPint inputChat;
|
||||
|
||||
ChannelData *migrateToPtr = nullptr;
|
||||
|
||||
int count = 0;
|
||||
TimeId date = 0;
|
||||
int version = 0;
|
||||
UserId creator = 0;
|
||||
|
||||
base::flat_map<not_null<UserData*>, int> participants;
|
||||
base::flat_set<not_null<UserData*>> invitedByMe;
|
||||
base::flat_set<not_null<UserData*>> admins;
|
||||
@ -94,15 +127,14 @@ public:
|
||||
int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other
|
||||
// ImagePtr photoFull;
|
||||
|
||||
void setInviteLink(const QString &newInviteLink);
|
||||
QString inviteLink() const {
|
||||
return _inviteLink;
|
||||
}
|
||||
|
||||
private:
|
||||
[[nodiscard]] bool actionsUnavailable() const;
|
||||
void flagsUpdated(MTPDchat::Flags diff);
|
||||
|
||||
Flags _flags;
|
||||
QString _inviteLink;
|
||||
|
||||
RestrictionFlags _defaultRestrictions;
|
||||
AdminRightFlags _adminRights;
|
||||
|
||||
};
|
||||
|
@ -222,7 +222,7 @@ bool Media::forwardedBecomesUnread() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString Media::errorTextForForward(not_null<ChannelData*> channel) const {
|
||||
QString Media::errorTextForForward(not_null<PeerData*> peer) const {
|
||||
return QString();
|
||||
}
|
||||
|
||||
@ -325,9 +325,8 @@ bool MediaPhoto::allowsEditCaption() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
QString MediaPhoto::errorTextForForward(
|
||||
not_null<ChannelData*> channel) const {
|
||||
if (channel->restricted(ChatRestriction::f_send_media)) {
|
||||
QString MediaPhoto::errorTextForForward(not_null<PeerData*> peer) const {
|
||||
if (peer->amRestricted(ChatRestriction::f_send_media)) {
|
||||
return lang(lng_restricted_send_media);
|
||||
}
|
||||
return QString();
|
||||
@ -650,23 +649,22 @@ bool MediaFile::forwardedBecomesUnread() const {
|
||||
|| _document->isVideoMessage();
|
||||
}
|
||||
|
||||
QString MediaFile::errorTextForForward(
|
||||
not_null<ChannelData*> channel) const {
|
||||
QString MediaFile::errorTextForForward(not_null<PeerData*> peer) const {
|
||||
if (const auto sticker = _document->sticker()) {
|
||||
if (channel->restricted(ChatRestriction::f_send_stickers)) {
|
||||
if (peer->amRestricted(ChatRestriction::f_send_stickers)) {
|
||||
return lang(lng_restricted_send_stickers);
|
||||
}
|
||||
} else if (_document->isAnimation()) {
|
||||
if (_document->isVideoMessage()) {
|
||||
if (channel->restricted(ChatRestriction::f_send_media)) {
|
||||
if (peer->amRestricted(ChatRestriction::f_send_media)) {
|
||||
return lang(lng_restricted_send_media);
|
||||
}
|
||||
} else {
|
||||
if (channel->restricted(ChatRestriction::f_send_gifs)) {
|
||||
if (peer->amRestricted(ChatRestriction::f_send_gifs)) {
|
||||
return lang(lng_restricted_send_gifs);
|
||||
}
|
||||
}
|
||||
} else if (channel->restricted(ChatRestriction::f_send_media)) {
|
||||
} else if (peer->amRestricted(ChatRestriction::f_send_media)) {
|
||||
return lang(lng_restricted_send_media);
|
||||
}
|
||||
return QString();
|
||||
@ -1116,9 +1114,8 @@ TextWithEntities MediaGame::clipboardText() const {
|
||||
return TextWithEntities();
|
||||
}
|
||||
|
||||
QString MediaGame::errorTextForForward(
|
||||
not_null<ChannelData*> channel) const {
|
||||
if (channel->restricted(ChatRestriction::f_send_games)) {
|
||||
QString MediaGame::errorTextForForward(not_null<PeerData*> peer) const {
|
||||
if (peer->amRestricted(ChatRestriction::f_send_games)) {
|
||||
return lang(lng_restricted_send_inline);
|
||||
}
|
||||
return QString();
|
||||
|
@ -95,8 +95,7 @@ public:
|
||||
virtual bool allowsEditCaption() const;
|
||||
virtual bool allowsRevoke() const;
|
||||
virtual bool forwardedBecomesUnread() const;
|
||||
virtual QString errorTextForForward(
|
||||
not_null<ChannelData*> channel) const;
|
||||
virtual QString errorTextForForward(not_null<PeerData*> peer) const;
|
||||
|
||||
[[nodiscard]] virtual bool consumeMessageText(
|
||||
const TextWithEntities &text);
|
||||
@ -142,8 +141,7 @@ public:
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextWithEntities clipboardText() const override;
|
||||
bool allowsEditCaption() const override;
|
||||
QString errorTextForForward(
|
||||
not_null<ChannelData*> channel) const override;
|
||||
QString errorTextForForward(not_null<PeerData*> peer) const override;
|
||||
|
||||
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
@ -179,8 +177,7 @@ public:
|
||||
TextWithEntities clipboardText() const override;
|
||||
bool allowsEditCaption() const override;
|
||||
bool forwardedBecomesUnread() const override;
|
||||
QString errorTextForForward(
|
||||
not_null<ChannelData*> channel) const override;
|
||||
QString errorTextForForward(not_null<PeerData*> peer) const override;
|
||||
|
||||
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
@ -331,8 +328,7 @@ public:
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextWithEntities clipboardText() const override;
|
||||
QString errorTextForForward(
|
||||
not_null<ChannelData*> channel) const override;
|
||||
QString errorTextForForward(not_null<PeerData*> peer) const override;
|
||||
|
||||
bool consumeMessageText(const TextWithEntities &text) override;
|
||||
TextWithEntities consumedMessageText() const override;
|
||||
|
@ -546,3 +546,28 @@ bool PeerData::canWrite() const {
|
||||
? asUser()->canWrite()
|
||||
: false;
|
||||
}
|
||||
|
||||
bool PeerData::amRestricted(ChatRestriction right) const {
|
||||
const auto allowByAdminRights = [](auto right, auto chat) -> bool {
|
||||
if (right == ChatRestriction::f_invite_users) {
|
||||
return chat->adminRights() & ChatAdminRight::f_invite_users;
|
||||
} else if (right == ChatRestriction::f_change_info) {
|
||||
return chat->adminRights() & ChatAdminRight::f_change_info;
|
||||
} else if (right == ChatRestriction::f_pin_messages) {
|
||||
return chat->adminRights() & ChatAdminRight::f_pin_messages;
|
||||
} else {
|
||||
return chat->hasAdminRights();
|
||||
}
|
||||
};
|
||||
if (const auto channel = asChannel()) {
|
||||
return !channel->amCreator()
|
||||
&& !allowByAdminRights(right, channel)
|
||||
&& ((channel->restrictions() & right)
|
||||
|| (channel->defaultRestrictions() & right));
|
||||
} else if (const auto chat = asChat()) {
|
||||
return !chat->amCreator()
|
||||
&& !allowByAdminRights(right, chat)
|
||||
&& (chat->defaultRestrictions() & right);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -100,6 +100,8 @@ public:
|
||||
}
|
||||
|
||||
bool canWrite() const;
|
||||
bool amRestricted(ChatRestriction right) const;
|
||||
|
||||
UserData *asUser();
|
||||
const UserData *asUser() const;
|
||||
ChatData *asChat();
|
||||
|
@ -89,6 +89,22 @@ inline auto AdminRightValue(
|
||||
return SingleFlagValue(AdminRightsValue(channel), flag);
|
||||
}
|
||||
|
||||
inline auto AdminRightsValue(not_null<ChatData*> chat) {
|
||||
return chat->adminRightsValue();
|
||||
}
|
||||
|
||||
inline auto AdminRightsValue(
|
||||
not_null<ChatData*> chat,
|
||||
MTPDchatAdminRights::Flags mask) {
|
||||
return FlagsValueWithMask(AdminRightsValue(chat), mask);
|
||||
}
|
||||
|
||||
inline auto AdminRightValue(
|
||||
not_null<ChatData*> chat,
|
||||
MTPDchatAdminRights::Flag flag) {
|
||||
return SingleFlagValue(AdminRightsValue(chat), flag);
|
||||
}
|
||||
|
||||
inline auto RestrictionsValue(not_null<ChannelData*> channel) {
|
||||
return channel->restrictionsValue();
|
||||
}
|
||||
@ -105,6 +121,38 @@ inline auto RestrictionValue(
|
||||
return SingleFlagValue(RestrictionsValue(channel), flag);
|
||||
}
|
||||
|
||||
inline auto DefaultRestrictionsValue(not_null<ChannelData*> channel) {
|
||||
return channel->defaultRestrictionsValue();
|
||||
}
|
||||
|
||||
inline auto DefaultRestrictionsValue(
|
||||
not_null<ChannelData*> channel,
|
||||
MTPDchatBannedRights::Flags mask) {
|
||||
return FlagsValueWithMask(DefaultRestrictionsValue(channel), mask);
|
||||
}
|
||||
|
||||
inline auto DefaultRestrictionValue(
|
||||
not_null<ChannelData*> channel,
|
||||
MTPDchatBannedRights::Flag flag) {
|
||||
return SingleFlagValue(DefaultRestrictionsValue(channel), flag);
|
||||
}
|
||||
|
||||
inline auto DefaultRestrictionsValue(not_null<ChatData*> chat) {
|
||||
return chat->defaultRestrictionsValue();
|
||||
}
|
||||
|
||||
inline auto DefaultRestrictionsValue(
|
||||
not_null<ChatData*> chat,
|
||||
MTPDchatBannedRights::Flags mask) {
|
||||
return FlagsValueWithMask(DefaultRestrictionsValue(chat), mask);
|
||||
}
|
||||
|
||||
inline auto DefaultRestrictionValue(
|
||||
not_null<ChatData*> chat,
|
||||
MTPDchatBannedRights::Flag flag) {
|
||||
return SingleFlagValue(DefaultRestrictionsValue(chat), flag);
|
||||
}
|
||||
|
||||
rpl::producer<bool> PeerFlagValue(
|
||||
ChatData *chat,
|
||||
MTPDchat_ClientFlag flag) {
|
||||
@ -125,17 +173,36 @@ rpl::producer<bool> CanWriteValue(UserData *user) {
|
||||
|
||||
rpl::producer<bool> CanWriteValue(ChatData *chat) {
|
||||
using namespace rpl::mappers;
|
||||
auto mask = 0
|
||||
const auto mask = 0
|
||||
| MTPDchat::Flag::f_deactivated
|
||||
| MTPDchat_ClientFlag::f_forbidden
|
||||
| MTPDchat::Flag::f_left
|
||||
| MTPDchat::Flag::f_creator
|
||||
| MTPDchat::Flag::f_kicked;
|
||||
return PeerFlagsValue(chat, mask)
|
||||
| rpl::map(!_1);
|
||||
return rpl::combine(
|
||||
PeerFlagsValue(chat, mask),
|
||||
AdminRightsValue(chat),
|
||||
DefaultRestrictionValue(
|
||||
chat,
|
||||
MTPDchatBannedRights::Flag::f_send_messages),
|
||||
[](
|
||||
MTPDchat::Flags flags,
|
||||
Data::Flags<ChatAdminRights>::Change adminRights,
|
||||
bool defaultSendMessagesRestriction) {
|
||||
const auto actionsUnavailableFlags = 0
|
||||
| MTPDchat::Flag::f_deactivated
|
||||
| MTPDchat_ClientFlag::f_forbidden
|
||||
| MTPDchat::Flag::f_left
|
||||
| MTPDchat::Flag::f_kicked;
|
||||
return !(flags & actionsUnavailableFlags)
|
||||
&& ((flags & MTPDchat::Flag::f_creator)
|
||||
|| (adminRights.value != MTPDchatAdminRights::Flags(0))
|
||||
|| !defaultSendMessagesRestriction);
|
||||
});
|
||||
}
|
||||
|
||||
rpl::producer<bool> CanWriteValue(ChannelData *channel) {
|
||||
auto mask = 0
|
||||
const auto mask = 0
|
||||
| MTPDchannel::Flag::f_left
|
||||
| MTPDchannel_ClientFlag::f_forbidden
|
||||
| MTPDchannel::Flag::f_creator
|
||||
@ -148,18 +215,23 @@ rpl::producer<bool> CanWriteValue(ChannelData *channel) {
|
||||
RestrictionValue(
|
||||
channel,
|
||||
MTPDchatBannedRights::Flag::f_send_messages),
|
||||
DefaultRestrictionValue(
|
||||
channel,
|
||||
MTPDchatBannedRights::Flag::f_send_messages),
|
||||
[](
|
||||
MTPDchannel::Flags flags,
|
||||
bool postMessagesRight,
|
||||
bool sendMessagesRestriction) {
|
||||
auto notAmInFlags = 0
|
||||
bool sendMessagesRestriction,
|
||||
bool defaultSendMessagesRestriction) {
|
||||
const auto notAmInFlags = 0
|
||||
| MTPDchannel::Flag::f_left
|
||||
| MTPDchannel_ClientFlag::f_forbidden;
|
||||
return !(flags & notAmInFlags)
|
||||
&& (postMessagesRight
|
||||
|| (flags & MTPDchannel::Flag::f_creator)
|
||||
|| (!(flags & MTPDchannel::Flag::f_broadcast)
|
||||
&& !sendMessagesRestriction));
|
||||
&& !sendMessagesRestriction
|
||||
&& !defaultSendMessagesRestriction));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -428,8 +428,8 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
|
||||
|
||||
data.match([&](const MTPDchat &data) {
|
||||
const auto chat = result->asChat();
|
||||
// #TODO groups
|
||||
const auto canEdit = chat->canEditInformation();
|
||||
|
||||
const auto canAddMembers = chat->canAddMembers();
|
||||
|
||||
if (chat->version < data.vversion.v) {
|
||||
chat->version = data.vversion.v;
|
||||
@ -441,6 +441,13 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
|
||||
chat->setPhoto(data.vphoto);
|
||||
chat->date = data.vdate.v;
|
||||
|
||||
chat->setAdminRights(data.has_admin_rights()
|
||||
? data.vadmin_rights
|
||||
: MTPChatAdminRights(MTP_chatAdminRights(MTP_flags(0))));
|
||||
chat->setDefaultRestrictions(data.has_default_banned_rights()
|
||||
? data.vdefault_banned_rights
|
||||
: MTPChatBannedRights(MTP_chatBannedRights(MTP_flags(0), MTP_int(0))));
|
||||
|
||||
const auto &migratedTo = data.has_migrated_to()
|
||||
? data.vmigrated_to
|
||||
: MTPInputChannel(MTP_inputChannelEmpty());
|
||||
@ -480,22 +487,16 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
|
||||
}, [](const MTPDinputChannelEmpty &) {
|
||||
});
|
||||
|
||||
// #TODO groups
|
||||
//if (!(chat->flags() & MTPDchat::Flag::f_admins_enabled)
|
||||
// && (data.vflags.v & MTPDchat::Flag::f_admins_enabled)) {
|
||||
// chat->invalidateParticipants();
|
||||
//}
|
||||
chat->setFlags(data.vflags.v);
|
||||
|
||||
chat->count = data.vparticipants_count.v;
|
||||
// #TODO groups
|
||||
if (canEdit != chat->canEditInformation()) {
|
||||
update.flags |= UpdateFlag::ChatCanEdit;
|
||||
|
||||
if (canAddMembers != chat->canAddMembers()) {
|
||||
update.flags |= UpdateFlag::RightsChanged;
|
||||
}
|
||||
}, [&](const MTPDchatForbidden &data) {
|
||||
const auto chat = result->asChat();
|
||||
// #TODO groups
|
||||
const auto canEdit = chat->canEditInformation();
|
||||
|
||||
const auto canAddMembers = chat->canAddMembers();
|
||||
|
||||
chat->input = MTP_inputPeerChat(data.vid);
|
||||
chat->setName(qs(data.vtitle));
|
||||
@ -504,9 +505,12 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
|
||||
chat->count = -1;
|
||||
chat->invalidateParticipants();
|
||||
chat->setFlags(MTPDchat_ClientFlag::f_forbidden | 0);
|
||||
// #TODO groups
|
||||
if (canEdit != chat->canEditInformation()) {
|
||||
update.flags |= UpdateFlag::ChatCanEdit;
|
||||
chat->setAdminRights(MTP_chatAdminRights(MTP_flags(0)));
|
||||
chat->setDefaultRestrictions(
|
||||
MTP_chatBannedRights(MTP_flags(0), MTP_int(0)));
|
||||
|
||||
if (canAddMembers != chat->canAddMembers()) {
|
||||
update.flags |= UpdateFlag::RightsChanged;
|
||||
}
|
||||
}, [&](const MTPDchannel &data) {
|
||||
const auto channel = result->asChannel();
|
||||
@ -545,9 +549,9 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
|
||||
channel->setAdminRights(MTP_chatAdminRights(MTP_flags(0)));
|
||||
}
|
||||
if (data.has_banned_rights()) {
|
||||
channel->setRestrictedRights(data.vbanned_rights);
|
||||
channel->setRestrictions(data.vbanned_rights);
|
||||
} else if (channel->hasRestrictions()) {
|
||||
channel->setRestrictedRights(MTP_chatBannedRights(MTP_flags(0), MTP_int(0)));
|
||||
channel->setRestrictions(MTP_chatBannedRights(MTP_flags(0), MTP_int(0)));
|
||||
}
|
||||
channel->inputChannel = MTP_inputChannel(data.vid, data.vaccess_hash);
|
||||
channel->access = data.vaccess_hash.v;
|
||||
@ -577,7 +581,7 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
|
||||
if (canViewAdmins != channel->canViewAdmins()
|
||||
|| canViewMembers != channel->canViewMembers()
|
||||
|| canAddMembers != channel->canAddMembers()) {
|
||||
update.flags |= UpdateFlag::ChannelRightsChanged;
|
||||
update.flags |= UpdateFlag::RightsChanged;
|
||||
}
|
||||
}, [&](const MTPDchannelForbidden &data) {
|
||||
const auto channel = result->asChannel();
|
||||
@ -597,7 +601,7 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
|
||||
channel->setAdminRights(MTP_chatAdminRights(MTP_flags(0)));
|
||||
}
|
||||
if (channel->hasRestrictions()) {
|
||||
channel->setRestrictedRights(MTP_chatBannedRights(MTP_flags(0), MTP_int(0)));
|
||||
channel->setRestrictions(MTP_chatBannedRights(MTP_flags(0), MTP_int(0)));
|
||||
}
|
||||
|
||||
channel->setName(qs(data.vtitle), QString());
|
||||
@ -613,7 +617,7 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
|
||||
if (canViewAdmins != channel->canViewAdmins()
|
||||
|| canViewMembers != channel->canViewMembers()
|
||||
|| canAddMembers != channel->canAddMembers()) {
|
||||
update.flags |= UpdateFlag::ChannelRightsChanged;
|
||||
update.flags |= UpdateFlag::RightsChanged;
|
||||
}
|
||||
}, [](const MTPDchatEmpty &) {
|
||||
});
|
||||
|
@ -52,16 +52,14 @@ MTPDmessage::Flags NewForwardedFlags(
|
||||
if (fwd->Has<HistoryMessageVia>()) {
|
||||
result |= MTPDmessage::Flag::f_via_bot_id;
|
||||
}
|
||||
if (const auto channel = peer->asChannel()) {
|
||||
if (dynamic_cast<Data::MediaWebPage*>(fwd->media())) {
|
||||
if (const auto media = fwd->media()) {
|
||||
if (dynamic_cast<Data::MediaWebPage*>(media)) {
|
||||
// Drop web page if we're not allowed to send it.
|
||||
if (channel->restricted(
|
||||
ChatRestriction::f_embed_links)) {
|
||||
if (peer->amRestricted(ChatRestriction::f_embed_links)) {
|
||||
result &= ~MTPDmessage::Flag::f_media;
|
||||
}
|
||||
}
|
||||
} else if (const auto media = fwd->media()) {
|
||||
if (media->forwardedBecomesUnread()) {
|
||||
if (!peer->isChannel() && media->forwardedBecomesUnread()) {
|
||||
result |= MTPDmessage::Flag::f_media_unread;
|
||||
}
|
||||
}
|
||||
@ -256,19 +254,17 @@ QString GetErrorTextForForward(
|
||||
return lang(lng_forward_cant);
|
||||
}
|
||||
|
||||
if (auto megagroup = peer->asMegagroup()) {
|
||||
for (const auto item : items) {
|
||||
if (const auto media = item->media()) {
|
||||
const auto error = media->errorTextForForward(megagroup);
|
||||
if (!error.isEmpty() && error != qstr("skip")) {
|
||||
return error;
|
||||
}
|
||||
for (const auto item : items) {
|
||||
if (const auto media = item->media()) {
|
||||
const auto error = media->errorTextForForward(peer);
|
||||
if (!error.isEmpty() && error != qstr("skip")) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
if (megagroup->restricted(ChatRestriction::f_send_inline)
|
||||
&& HasInlineItems(items)) {
|
||||
return lang(lng_restricted_send_inline);
|
||||
}
|
||||
}
|
||||
if (peer->amRestricted(ChatRestriction::f_send_inline)
|
||||
&& HasInlineItems(items)) {
|
||||
return lang(lng_restricted_send_inline);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
@ -385,6 +381,8 @@ HistoryMessage::HistoryMessage(
|
||||
NewForwardedFlags(history->peer, from, original) | flags,
|
||||
date,
|
||||
from) {
|
||||
const auto peer = history->peer;
|
||||
|
||||
CreateConfig config;
|
||||
|
||||
if (original->Has<HistoryMessageForwarded>() || !original->history()->peer->isSelf()) {
|
||||
@ -397,7 +395,7 @@ HistoryMessage::HistoryMessage(
|
||||
config.originalId = original->idOriginal();
|
||||
}
|
||||
}
|
||||
if (history->peer->isSelf()) {
|
||||
if (peer->isSelf()) {
|
||||
//
|
||||
// iOS app sends you to the original post if we forward a forward from channel.
|
||||
// But server returns not the original post but the forward in saved_from_...
|
||||
@ -430,12 +428,10 @@ HistoryMessage::HistoryMessage(
|
||||
|
||||
createComponents(config);
|
||||
|
||||
auto ignoreMedia = [&] {
|
||||
const auto ignoreMedia = [&] {
|
||||
if (mediaOriginal && mediaOriginal->webpage()) {
|
||||
if (const auto channel = history->peer->asChannel()) {
|
||||
if (channel->restricted(ChatRestriction::f_embed_links)) {
|
||||
return true;
|
||||
}
|
||||
if (peer->amRestricted(ChatRestriction::f_embed_links)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -405,7 +405,7 @@ HistoryWidget::HistoryWidget(
|
||||
}
|
||||
});
|
||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
||||
auto changes = UpdateFlag::ChannelRightsChanged
|
||||
auto changes = UpdateFlag::RightsChanged
|
||||
| UpdateFlag::UnreadMentionsChanged
|
||||
| UpdateFlag::UnreadViewChanged
|
||||
| UpdateFlag::MigrationChanged
|
||||
@ -420,7 +420,7 @@ HistoryWidget::HistoryWidget(
|
||||
| UpdateFlag::ChannelPromotedChanged;
|
||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(changes, [this](const Notify::PeerUpdate &update) {
|
||||
if (update.peer == _peer) {
|
||||
if (update.flags & UpdateFlag::ChannelRightsChanged) {
|
||||
if (update.flags & UpdateFlag::RightsChanged) {
|
||||
checkPreview();
|
||||
}
|
||||
if (update.flags & UpdateFlag::UnreadMentionsChanged) {
|
||||
@ -1934,11 +1934,7 @@ bool HistoryWidget::canWriteMessage() const {
|
||||
}
|
||||
|
||||
bool HistoryWidget::isRestrictedWrite() const {
|
||||
if (auto megagroup = _peer ? _peer->asMegagroup() : nullptr) {
|
||||
return megagroup->restricted(
|
||||
ChatRestriction::f_send_messages);
|
||||
}
|
||||
return false;
|
||||
return _peer && _peer->amRestricted(ChatRestriction::f_send_messages);
|
||||
}
|
||||
|
||||
void HistoryWidget::updateControlsVisibility() {
|
||||
@ -3034,12 +3030,11 @@ void HistoryWidget::step_recording(float64 ms, bool timer) {
|
||||
}
|
||||
|
||||
void HistoryWidget::chooseAttach() {
|
||||
if (!_peer || !_peer->canWrite()) return;
|
||||
if (auto megagroup = _peer->asMegagroup()) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_media)) {
|
||||
Ui::show(Box<InformBox>(lang(lng_restricted_send_media)));
|
||||
return;
|
||||
}
|
||||
if (!_peer || !_peer->canWrite()) {
|
||||
return;
|
||||
} else if (_peer->amRestricted(ChatRestriction::f_send_media)) {
|
||||
Ui::show(Box<InformBox>(lang(lng_restricted_send_media)));
|
||||
return;
|
||||
}
|
||||
|
||||
auto filter = FileDialog::AllFilesFilter() + qsl(";;Image files (*") + cImgExtensions().join(qsl(" *")) + qsl(")");
|
||||
@ -3142,14 +3137,11 @@ void HistoryWidget::leaveToChildEvent(QEvent *e, QWidget *child) { // e -- from
|
||||
}
|
||||
|
||||
void HistoryWidget::recordStartCallback() {
|
||||
if (!Media::Capture::instance()->available()) {
|
||||
if (_peer && _peer->amRestricted(ChatRestriction::f_send_media)) {
|
||||
Ui::show(Box<InformBox>(lang(lng_restricted_send_media)));
|
||||
return;
|
||||
} else if (!Media::Capture::instance()->available()) {
|
||||
return;
|
||||
}
|
||||
if (auto megagroup = _peer ? _peer->asMegagroup() : nullptr) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_media)) {
|
||||
Ui::show(Box<InformBox>(lang(lng_restricted_send_media)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
emit Media::Capture::instance()->start();
|
||||
@ -3940,12 +3932,9 @@ void HistoryWidget::updateFieldPlaceholder() {
|
||||
bool HistoryWidget::showSendingFilesError(
|
||||
const Storage::PreparedList &list) const {
|
||||
const auto text = [&] {
|
||||
if (const auto megagroup = _peer ? _peer->asMegagroup() : nullptr) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_media)) {
|
||||
return lang(lng_restricted_send_media);
|
||||
}
|
||||
}
|
||||
if (!canWriteMessage()) {
|
||||
if (_peer && _peer->amRestricted(ChatRestriction::f_send_media)) {
|
||||
return lang(lng_restricted_send_media);
|
||||
} else if (!canWriteMessage()) {
|
||||
return lang(lng_forward_send_files_cant);
|
||||
}
|
||||
using Error = Storage::PreparedList::Error;
|
||||
@ -5379,13 +5368,11 @@ void HistoryWidget::destroyPinnedBar() {
|
||||
bool HistoryWidget::sendExistingDocument(
|
||||
not_null<DocumentData*> document,
|
||||
TextWithEntities caption) {
|
||||
if (const auto megagroup = _peer ? _peer->asMegagroup() : nullptr) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_stickers)) {
|
||||
Ui::show(
|
||||
Box<InformBox>(lang(lng_restricted_send_stickers)),
|
||||
LayerOption::KeepOther);
|
||||
return false;
|
||||
}
|
||||
if (_peer && _peer->amRestricted(ChatRestriction::f_send_stickers)) {
|
||||
Ui::show(
|
||||
Box<InformBox>(lang(lng_restricted_send_stickers)),
|
||||
LayerOption::KeepOther);
|
||||
return false;
|
||||
} else if (!_peer || !_peer->canWrite()) {
|
||||
return false;
|
||||
}
|
||||
@ -5415,13 +5402,11 @@ bool HistoryWidget::sendExistingDocument(
|
||||
bool HistoryWidget::sendExistingPhoto(
|
||||
not_null<PhotoData*> photo,
|
||||
TextWithEntities caption) {
|
||||
if (const auto megagroup = _peer ? _peer->asMegagroup() : nullptr) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_media)) {
|
||||
Ui::show(
|
||||
Box<InformBox>(lang(lng_restricted_send_media)),
|
||||
LayerOption::KeepOther);
|
||||
return false;
|
||||
}
|
||||
if (_peer && _peer->amRestricted(ChatRestriction::f_send_media)) {
|
||||
Ui::show(
|
||||
Box<InformBox>(lang(lng_restricted_send_media)),
|
||||
LayerOption::KeepOther);
|
||||
return false;
|
||||
} else if (!_peer || !_peer->canWrite()) {
|
||||
return false;
|
||||
}
|
||||
@ -5862,12 +5847,7 @@ void HistoryWidget::previewCancel() {
|
||||
|
||||
void HistoryWidget::checkPreview() {
|
||||
auto previewRestricted = [this] {
|
||||
if (auto megagroup = _peer ? _peer->asMegagroup() : nullptr) {
|
||||
if (megagroup->restricted(ChatRestriction::f_embed_links)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return _peer && _peer->amRestricted(ChatRestriction::f_embed_links);
|
||||
};
|
||||
if (_previewCancelled || previewRestricted()) {
|
||||
previewCancel();
|
||||
|
@ -285,14 +285,14 @@ void Cover::initViewers() {
|
||||
_peer,
|
||||
Flag::UserOnlineChanged | Flag::MembersChanged
|
||||
) | rpl::start_with_next(
|
||||
[this] { refreshStatusText(); },
|
||||
[=] { refreshStatusText(); },
|
||||
lifetime());
|
||||
if (!_peer->isUser()) {
|
||||
Notify::PeerUpdateValue(
|
||||
_peer,
|
||||
Flag::ChannelRightsChanged | Flag::ChatCanEdit
|
||||
Flag::RightsChanged
|
||||
) | rpl::start_with_next(
|
||||
[this] { refreshUploadPhotoOverlay(); },
|
||||
[=] { refreshUploadPhotoOverlay(); },
|
||||
lifetime());
|
||||
} else if (_peer->isSelf()) {
|
||||
refreshUploadPhotoOverlay();
|
||||
@ -300,7 +300,7 @@ void Cover::initViewers() {
|
||||
VerifiedValue(
|
||||
_peer
|
||||
) | rpl::start_with_next(
|
||||
[this](bool verified) { setVerified(verified); },
|
||||
[=](bool verified) { setVerified(verified); },
|
||||
lifetime());
|
||||
}
|
||||
|
||||
|
@ -214,8 +214,8 @@ rpl::producer<int> AdminsCountValue(
|
||||
using Flag = Notify::PeerUpdate::Flag;
|
||||
return Notify::PeerUpdateValue(
|
||||
channel,
|
||||
Flag::AdminsChanged | Flag::ChannelRightsChanged
|
||||
) | rpl::map([channel] {
|
||||
Flag::AdminsChanged | Flag::RightsChanged
|
||||
) | rpl::map([=] {
|
||||
return channel->canViewAdmins()
|
||||
? channel->adminsCount()
|
||||
: 0;
|
||||
@ -227,8 +227,8 @@ rpl::producer<int> RestrictedCountValue(
|
||||
using Flag = Notify::PeerUpdate::Flag;
|
||||
return Notify::PeerUpdateValue(
|
||||
channel,
|
||||
Flag::BannedUsersChanged | Flag::ChannelRightsChanged
|
||||
) | rpl::map([channel] {
|
||||
Flag::BannedUsersChanged | Flag::RightsChanged
|
||||
) | rpl::map([=] {
|
||||
return channel->canViewBanned()
|
||||
? channel->restrictedCount()
|
||||
: 0;
|
||||
@ -240,8 +240,8 @@ rpl::producer<int> KickedCountValue(
|
||||
using Flag = Notify::PeerUpdate::Flag;
|
||||
return Notify::PeerUpdateValue(
|
||||
channel,
|
||||
Flag::BannedUsersChanged | Flag::ChannelRightsChanged
|
||||
) | rpl::map([channel] {
|
||||
Flag::BannedUsersChanged | Flag::RightsChanged
|
||||
) | rpl::map([=] {
|
||||
return channel->canViewBanned()
|
||||
? channel->kickedCount()
|
||||
: 0;
|
||||
@ -284,15 +284,15 @@ rpl::producer<bool> CanAddMemberValue(
|
||||
if (auto chat = peer->asChat()) {
|
||||
return Notify::PeerUpdateValue(
|
||||
chat,
|
||||
Notify::PeerUpdate::Flag::ChatCanEdit
|
||||
) | rpl::map([chat] {
|
||||
return chat->canEditInformation(); // #TODO groups
|
||||
Notify::PeerUpdate::Flag::RightsChanged
|
||||
) | rpl::map([=] {
|
||||
return chat->canAddMembers();
|
||||
});
|
||||
} else if (auto channel = peer->asChannel()) {
|
||||
return Notify::PeerUpdateValue(
|
||||
channel,
|
||||
Notify::PeerUpdate::Flag::ChannelRightsChanged
|
||||
) | rpl::map([channel] {
|
||||
Notify::PeerUpdate::Flag::RightsChanged
|
||||
) | rpl::map([=] {
|
||||
return channel->canAddMembers();
|
||||
});
|
||||
}
|
||||
|
@ -64,10 +64,8 @@ void SendDataCommon::addToHistory(
|
||||
QString SendDataCommon::getErrorOnSend(
|
||||
const Result *owner,
|
||||
not_null<History*> history) const {
|
||||
if (const auto megagroup = history->peer->asMegagroup()) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_messages)) {
|
||||
return lang(lng_restricted_send_message);
|
||||
}
|
||||
if (history->peer->amRestricted(ChatRestriction::f_send_messages)) {
|
||||
return lang(lng_restricted_send_message);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
@ -146,10 +144,8 @@ void SendPhoto::addToHistory(
|
||||
QString SendPhoto::getErrorOnSend(
|
||||
const Result *owner,
|
||||
not_null<History*> history) const {
|
||||
if (const auto megagroup = history->peer->asMegagroup()) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_media)) {
|
||||
return lang(lng_restricted_send_media);
|
||||
}
|
||||
if (history->peer->amRestricted(ChatRestriction::f_send_media)) {
|
||||
return lang(lng_restricted_send_media);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
@ -181,17 +177,15 @@ void SendFile::addToHistory(
|
||||
QString SendFile::getErrorOnSend(
|
||||
const Result *owner,
|
||||
not_null<History*> history) const {
|
||||
if (const auto megagroup = history->peer->asMegagroup()) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_media)) {
|
||||
return lang(lng_restricted_send_media);
|
||||
} else if (megagroup->restricted(ChatRestriction::f_send_stickers)
|
||||
&& (_document->sticker() != nullptr)) {
|
||||
return lang(lng_restricted_send_stickers);
|
||||
} else if (megagroup->restricted(ChatRestriction::f_send_gifs)
|
||||
&& _document->isAnimation()
|
||||
&& !_document->isVideoMessage()) {
|
||||
return lang(lng_restricted_send_gifs);
|
||||
}
|
||||
if (history->peer->amRestricted(ChatRestriction::f_send_media)) {
|
||||
return lang(lng_restricted_send_media);
|
||||
} else if (history->peer->amRestricted(ChatRestriction::f_send_stickers)
|
||||
&& (_document->sticker() != nullptr)) {
|
||||
return lang(lng_restricted_send_stickers);
|
||||
} else if (history->peer->amRestricted(ChatRestriction::f_send_gifs)
|
||||
&& _document->isAnimation()
|
||||
&& !_document->isVideoMessage()) {
|
||||
return lang(lng_restricted_send_gifs);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
@ -222,10 +216,8 @@ void SendGame::addToHistory(
|
||||
QString SendGame::getErrorOnSend(
|
||||
const Result *owner,
|
||||
not_null<History*> history) const {
|
||||
if (auto megagroup = history->peer->asMegagroup()) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_games)) {
|
||||
return lang(lng_restricted_send_inline);
|
||||
}
|
||||
if (history->peer->amRestricted(ChatRestriction::f_send_games)) {
|
||||
return lang(lng_restricted_send_inline);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ Inner::Inner(QWidget *parent, not_null<Window::Controller*> controller) : TWidge
|
||||
update();
|
||||
}
|
||||
});
|
||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::ChannelRightsChanged, [this](const Notify::PeerUpdate &update) {
|
||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::RightsChanged, [this](const Notify::PeerUpdate &update) {
|
||||
if (update.peer == _inlineQueryPeer) {
|
||||
auto isRestricted = (_restrictedLabel != nullptr);
|
||||
if (isRestricted != isRestrictedView()) {
|
||||
@ -80,8 +80,8 @@ void Inner::visibleTopBottomUpdated(
|
||||
}
|
||||
|
||||
void Inner::checkRestrictedPeer() {
|
||||
if (auto megagroup = _inlineQueryPeer ? _inlineQueryPeer->asMegagroup() : nullptr) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_inline)) {
|
||||
if (_inlineQueryPeer) {
|
||||
if (_inlineQueryPeer->amRestricted(ChatRestriction::f_send_inline)) {
|
||||
if (!_restrictedLabel) {
|
||||
_restrictedLabel.create(this, lang(lng_restricted_send_inline), Ui::FlatLabel::InitType::Simple, st::stickersRestrictedLabel);
|
||||
_restrictedLabel->show();
|
||||
|
@ -565,11 +565,9 @@ bool MainWidget::sendPaths(PeerId peerId) {
|
||||
if (!peer->canWrite()) {
|
||||
Ui::show(Box<InformBox>(lang(lng_forward_send_files_cant)));
|
||||
return false;
|
||||
} else if (auto megagroup = peer->asMegagroup()) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_media)) {
|
||||
Ui::show(Box<InformBox>(lang(lng_restricted_send_media)));
|
||||
return false;
|
||||
}
|
||||
} else if (peer->amRestricted(ChatRestriction::f_send_media)) {
|
||||
Ui::show(Box<InformBox>(lang(lng_restricted_send_media)));
|
||||
return false;
|
||||
}
|
||||
Ui::showPeerHistory(peer, ShowAtTheEndMsgId);
|
||||
return _history->confirmSendingFiles(cSendPaths());
|
||||
|
@ -46,26 +46,23 @@ struct PeerUpdate {
|
||||
AdminsChanged = (1 << 13),
|
||||
BannedUsersChanged = (1 << 14),
|
||||
UnreadMentionsChanged = (1 << 15),
|
||||
RightsChanged = (1 << 16),
|
||||
|
||||
// For users
|
||||
UserCanShareContact = (1 << 16),
|
||||
UserIsContact = (1 << 17),
|
||||
UserPhoneChanged = (1 << 18),
|
||||
UserIsBlocked = (1 << 19),
|
||||
BotCommandsChanged = (1 << 20),
|
||||
UserOnlineChanged = (1 << 21),
|
||||
BotCanAddToGroups = (1 << 22),
|
||||
UserCommonChatsChanged = (1 << 23),
|
||||
UserHasCalls = (1 << 24),
|
||||
UserOccupiedChanged = (1 << 25),
|
||||
UserSupportInfoChanged = (1 << 26),
|
||||
|
||||
// For chats
|
||||
ChatCanEdit = (1 << 16),
|
||||
UserCanShareContact = (1 << 17),
|
||||
UserIsContact = (1 << 18),
|
||||
UserPhoneChanged = (1 << 19),
|
||||
UserIsBlocked = (1 << 20),
|
||||
BotCommandsChanged = (1 << 21),
|
||||
UserOnlineChanged = (1 << 22),
|
||||
BotCanAddToGroups = (1 << 23),
|
||||
UserCommonChatsChanged = (1 << 24),
|
||||
UserHasCalls = (1 << 25),
|
||||
UserOccupiedChanged = (1 << 26),
|
||||
UserSupportInfoChanged = (1 << 27),
|
||||
|
||||
// For channels
|
||||
ChannelAmIn = (1 << 16),
|
||||
ChannelRightsChanged = (1 << 17),
|
||||
ChannelAmIn = (1 << 17),
|
||||
ChannelStickersChanged = (1 << 18),
|
||||
ChannelPromotedChanged = (1 << 19),
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user