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,
|
||||
ChannelData *chat,
|
||||
std::vector<not_null<PeerData*>> &&chats,
|
||||
bool canEdit,
|
||||
Fn<void(ChannelData*)> callback) {
|
||||
Expects(channel->isBroadcast() || (chat != nullptr));
|
||||
Expects((channel->isBroadcast() && canEdit) || (chat != nullptr));
|
||||
|
||||
const auto init = [=](not_null<PeerListBox*> box) {
|
||||
auto above = object_ptr<Ui::VerticalLayout>(box);
|
||||
|
@ -291,7 +292,7 @@ object_ptr<BoxContent> EditLinkedChatBox(
|
|||
box->peerListSetAboveWidget(std::move(above));
|
||||
|
||||
auto below = object_ptr<Ui::VerticalLayout>(box);
|
||||
if (chat) {
|
||||
if (chat && canEdit) {
|
||||
below->add(SetupUnlink(below, channel, callback));
|
||||
}
|
||||
below->add(
|
||||
|
@ -318,12 +319,18 @@ object_ptr<BoxContent> EditLinkedChatBox(
|
|||
not_null<ChannelData*> channel,
|
||||
std::vector<not_null<PeerData*>> &&chats,
|
||||
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(
|
||||
not_null<ChannelData*> channel,
|
||||
not_null<ChannelData*> chat,
|
||||
bool canEdit,
|
||||
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(
|
||||
not_null<ChannelData*> channel,
|
||||
not_null<ChannelData*> chat,
|
||||
bool canEdit,
|
||||
Fn<void(ChannelData*)> callback);
|
||||
|
||||
object_ptr<BoxContent> EditLinkedChatBox(
|
||||
|
|
|
@ -524,12 +524,19 @@ void Controller::showEditLinkedChatBox() {
|
|||
_linkedChatUpdates.fire_copy(result);
|
||||
refreshHistoryVisibility();
|
||||
};
|
||||
const auto canEdit = channel->isBroadcast()
|
||||
? channel->canEditInformation()
|
||||
: (channel->canPinMessages()
|
||||
&& (channel->amCreator() || channel->adminRights() != 0)
|
||||
&& (!channel->hiddenPreHistory()
|
||||
|| channel->canEditPreHistoryHidden()));
|
||||
|
||||
if (const auto chat = *_linkedChatSavedValue) {
|
||||
*box = Ui::show(
|
||||
EditLinkedChatBox(channel, chat, callback),
|
||||
EditLinkedChatBox(channel, chat, canEdit, callback),
|
||||
LayerOption::KeepOther);
|
||||
return;
|
||||
} else if (_linkedChatsRequestId) {
|
||||
} else if (!canEdit || _linkedChatsRequestId) {
|
||||
return;
|
||||
} else if (channel->isMegagroup()) {
|
||||
// Restore original linked channel.
|
||||
|
@ -779,16 +786,12 @@ void Controller::fillManageSection() {
|
|||
: false;
|
||||
}();
|
||||
|
||||
const auto canEditLinkedChat = [&] {
|
||||
const auto canViewOrEditLinkedChat = [&] {
|
||||
return !isChannel
|
||||
? false
|
||||
: channel->isBroadcast()
|
||||
? channel->canEditInformation()
|
||||
: (channel->linkedChat()
|
||||
&& channel->canPinMessages()
|
||||
&& (channel->amCreator() || channel->adminRights() != 0)
|
||||
&& (!channel->hiddenPreHistory()
|
||||
|| channel->canEditPreHistoryHidden()));
|
||||
: channel->linkedChat()
|
||||
? true
|
||||
: (channel->isBroadcast() && channel->canEditInformation());
|
||||
}();
|
||||
|
||||
AddSkip(_controls.buttonsLayout, 0);
|
||||
|
@ -798,7 +801,7 @@ void Controller::fillManageSection() {
|
|||
} else if (canEditInviteLink) {
|
||||
fillInviteLinkButton();
|
||||
}
|
||||
if (canEditLinkedChat) {
|
||||
if (canViewOrEditLinkedChat) {
|
||||
fillLinkedChatButton();
|
||||
}
|
||||
if (canEditSignatures) {
|
||||
|
@ -810,7 +813,7 @@ void Controller::fillManageSection() {
|
|||
if (canEditPreHistoryHidden
|
||||
|| canEditSignatures
|
||||
|| canEditInviteLink
|
||||
|| canEditLinkedChat
|
||||
|| canViewOrEditLinkedChat
|
||||
|| canEditUsername) {
|
||||
AddSkip(
|
||||
_controls.buttonsLayout,
|
||||
|
|
Loading…
Reference in New Issue