Browse Source

Restrict toggling some public permissions

master
Eduard Kuzmenko 3 years ago
parent
commit
9dd8db8d61
  1. 18
      src/components/sidebarRight/tabs/groupPermissions.ts
  2. 1
      src/lang.ts

18
src/components/sidebarRight/tabs/groupPermissions.ts

@ -54,10 +54,11 @@ export class ChatPermissions { @@ -54,10 +54,11 @@ export class ChatPermissions {
'send_messages': ['send_media', 'send_stickers', 'send_polls', 'embed_links']
};
const chat: Chat.chat = appChatsManager.getChat(options.chatId);
const chat: Chat.chat | Chat.channel = appChatsManager.getChat(options.chatId);
const defaultBannedRights = chat.default_banned_rights;
const rights = options.participant ? appChatsManager.combineParticipantBannedRights(options.chatId, options.participant.banned_rights) : defaultBannedRights;
const restrictionText: LangPackKey = options.participant ? 'UserRestrictionsDisabled' : 'EditCantEditPermissionsPublic';
for(const info of this.v) {
const mainFlag = info.flags[0];
info.checkboxField = new CheckboxField({
@ -67,8 +68,17 @@ export class ChatPermissions { @@ -67,8 +68,17 @@ export class ChatPermissions {
withRipple: true
});
// @ts-ignore
if(options.participant && defaultBannedRights.pFlags[mainFlag]) {
if((
options.participant &&
defaultBannedRights.pFlags[mainFlag as keyof typeof defaultBannedRights['pFlags']]
) || (
(chat as Chat.channel).username &&
(
info.flags.includes('pin_messages') ||
info.flags.includes('change_info')
)
)
) {
info.checkboxField.input.disabled = true;
/* options.listenerSetter.add(info.checkboxField.input)('change', (e) => {
@ -82,7 +92,7 @@ export class ChatPermissions { @@ -82,7 +92,7 @@ export class ChatPermissions {
}); */
attachClickEvent(info.checkboxField.label, (e) => {
toast(I18n.format('UserRestrictionsDisabled', true));
toast(I18n.format(restrictionText, true));
}, {listenerSetter: options.listenerSetter});
}

1
src/lang.ts

@ -680,6 +680,7 @@ const lang = { @@ -680,6 +680,7 @@ const lang = {
"SendMessageAsTitle": "Send message as...",
"Devices": "Devices",
"LanguageName": "English",
"EditCantEditPermissionsPublic": "This permission is not available in public groups.",
// * macos
"AccountSettings.Filters": "Chat Folders",

Loading…
Cancel
Save