mirror of https://github.com/procxx/kepka.git
Allow admins to see the linked chat.
This commit is contained in:
parent
d7ab7aed62
commit
f7cb38c36a
|
@ -277,8 +277,9 @@ object_ptr<BoxContent> EditLinkedChatBox(
|
||||||
not_null<ChannelData*> channel,
|
not_null<ChannelData*> channel,
|
||||||
ChannelData *chat,
|
ChannelData *chat,
|
||||||
std::vector<not_null<PeerData*>> &&chats,
|
std::vector<not_null<PeerData*>> &&chats,
|
||||||
|
bool canEdit,
|
||||||
Fn<void(ChannelData*)> callback) {
|
Fn<void(ChannelData*)> callback) {
|
||||||
Expects(channel->isBroadcast() || (chat != nullptr));
|
Expects((channel->isBroadcast() && canEdit) || (chat != nullptr));
|
||||||
|
|
||||||
const auto init = [=](not_null<PeerListBox*> box) {
|
const auto init = [=](not_null<PeerListBox*> box) {
|
||||||
auto above = object_ptr<Ui::VerticalLayout>(box);
|
auto above = object_ptr<Ui::VerticalLayout>(box);
|
||||||
|
@ -291,7 +292,7 @@ object_ptr<BoxContent> EditLinkedChatBox(
|
||||||
box->peerListSetAboveWidget(std::move(above));
|
box->peerListSetAboveWidget(std::move(above));
|
||||||
|
|
||||||
auto below = object_ptr<Ui::VerticalLayout>(box);
|
auto below = object_ptr<Ui::VerticalLayout>(box);
|
||||||
if (chat) {
|
if (chat && canEdit) {
|
||||||
below->add(SetupUnlink(below, channel, callback));
|
below->add(SetupUnlink(below, channel, callback));
|
||||||
}
|
}
|
||||||
below->add(
|
below->add(
|
||||||
|
@ -318,12 +319,18 @@ object_ptr<BoxContent> EditLinkedChatBox(
|
||||||
not_null<ChannelData*> channel,
|
not_null<ChannelData*> channel,
|
||||||
std::vector<not_null<PeerData*>> &&chats,
|
std::vector<not_null<PeerData*>> &&chats,
|
||||||
Fn<void(ChannelData*)> callback) {
|
Fn<void(ChannelData*)> callback) {
|
||||||
return EditLinkedChatBox(channel, nullptr, std::move(chats), callback);
|
return EditLinkedChatBox(
|
||||||
|
channel,
|
||||||
|
nullptr,
|
||||||
|
std::move(chats),
|
||||||
|
true,
|
||||||
|
callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ptr<BoxContent> EditLinkedChatBox(
|
object_ptr<BoxContent> EditLinkedChatBox(
|
||||||
not_null<ChannelData*> channel,
|
not_null<ChannelData*> channel,
|
||||||
not_null<ChannelData*> chat,
|
not_null<ChannelData*> chat,
|
||||||
|
bool canEdit,
|
||||||
Fn<void(ChannelData*)> callback) {
|
Fn<void(ChannelData*)> callback) {
|
||||||
return EditLinkedChatBox(channel, chat, {}, callback);
|
return EditLinkedChatBox(channel, chat, {}, canEdit, callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
object_ptr<BoxContent> EditLinkedChatBox(
|
object_ptr<BoxContent> EditLinkedChatBox(
|
||||||
not_null<ChannelData*> channel,
|
not_null<ChannelData*> channel,
|
||||||
not_null<ChannelData*> chat,
|
not_null<ChannelData*> chat,
|
||||||
|
bool canEdit,
|
||||||
Fn<void(ChannelData*)> callback);
|
Fn<void(ChannelData*)> callback);
|
||||||
|
|
||||||
object_ptr<BoxContent> EditLinkedChatBox(
|
object_ptr<BoxContent> EditLinkedChatBox(
|
||||||
|
|
|
@ -524,12 +524,19 @@ void Controller::showEditLinkedChatBox() {
|
||||||
_linkedChatUpdates.fire_copy(result);
|
_linkedChatUpdates.fire_copy(result);
|
||||||
refreshHistoryVisibility();
|
refreshHistoryVisibility();
|
||||||
};
|
};
|
||||||
|
const auto canEdit = channel->isBroadcast()
|
||||||
|
? channel->canEditInformation()
|
||||||
|
: (channel->canPinMessages()
|
||||||
|
&& (channel->amCreator() || channel->adminRights() != 0)
|
||||||
|
&& (!channel->hiddenPreHistory()
|
||||||
|
|| channel->canEditPreHistoryHidden()));
|
||||||
|
|
||||||
if (const auto chat = *_linkedChatSavedValue) {
|
if (const auto chat = *_linkedChatSavedValue) {
|
||||||
*box = Ui::show(
|
*box = Ui::show(
|
||||||
EditLinkedChatBox(channel, chat, callback),
|
EditLinkedChatBox(channel, chat, canEdit, callback),
|
||||||
LayerOption::KeepOther);
|
LayerOption::KeepOther);
|
||||||
return;
|
return;
|
||||||
} else if (_linkedChatsRequestId) {
|
} else if (!canEdit || _linkedChatsRequestId) {
|
||||||
return;
|
return;
|
||||||
} else if (channel->isMegagroup()) {
|
} else if (channel->isMegagroup()) {
|
||||||
// Restore original linked channel.
|
// Restore original linked channel.
|
||||||
|
@ -779,16 +786,12 @@ void Controller::fillManageSection() {
|
||||||
: false;
|
: false;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
const auto canEditLinkedChat = [&] {
|
const auto canViewOrEditLinkedChat = [&] {
|
||||||
return !isChannel
|
return !isChannel
|
||||||
? false
|
? false
|
||||||
: channel->isBroadcast()
|
: channel->linkedChat()
|
||||||
? channel->canEditInformation()
|
? true
|
||||||
: (channel->linkedChat()
|
: (channel->isBroadcast() && channel->canEditInformation());
|
||||||
&& channel->canPinMessages()
|
|
||||||
&& (channel->amCreator() || channel->adminRights() != 0)
|
|
||||||
&& (!channel->hiddenPreHistory()
|
|
||||||
|| channel->canEditPreHistoryHidden()));
|
|
||||||
}();
|
}();
|
||||||
|
|
||||||
AddSkip(_controls.buttonsLayout, 0);
|
AddSkip(_controls.buttonsLayout, 0);
|
||||||
|
@ -798,7 +801,7 @@ void Controller::fillManageSection() {
|
||||||
} else if (canEditInviteLink) {
|
} else if (canEditInviteLink) {
|
||||||
fillInviteLinkButton();
|
fillInviteLinkButton();
|
||||||
}
|
}
|
||||||
if (canEditLinkedChat) {
|
if (canViewOrEditLinkedChat) {
|
||||||
fillLinkedChatButton();
|
fillLinkedChatButton();
|
||||||
}
|
}
|
||||||
if (canEditSignatures) {
|
if (canEditSignatures) {
|
||||||
|
@ -810,7 +813,7 @@ void Controller::fillManageSection() {
|
||||||
if (canEditPreHistoryHidden
|
if (canEditPreHistoryHidden
|
||||||
|| canEditSignatures
|
|| canEditSignatures
|
||||||
|| canEditInviteLink
|
|| canEditInviteLink
|
||||||
|| canEditLinkedChat
|
|| canViewOrEditLinkedChat
|
||||||
|| canEditUsername) {
|
|| canEditUsername) {
|
||||||
AddSkip(
|
AddSkip(
|
||||||
_controls.buttonsLayout,
|
_controls.buttonsLayout,
|
||||||
|
|
Loading…
Reference in New Issue