Browse Source

Restrict toggling some public permissions

master
Eduard Kuzmenko 2 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 {
'send_messages': ['send_media', 'send_stickers', 'send_polls', 'embed_links'] '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 defaultBannedRights = chat.default_banned_rights;
const rights = options.participant ? appChatsManager.combineParticipantBannedRights(options.chatId, options.participant.banned_rights) : defaultBannedRights; 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) { for(const info of this.v) {
const mainFlag = info.flags[0]; const mainFlag = info.flags[0];
info.checkboxField = new CheckboxField({ info.checkboxField = new CheckboxField({
@ -67,8 +68,17 @@ export class ChatPermissions {
withRipple: true withRipple: true
}); });
// @ts-ignore if((
if(options.participant && defaultBannedRights.pFlags[mainFlag]) { 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; info.checkboxField.input.disabled = true;
/* options.listenerSetter.add(info.checkboxField.input)('change', (e) => { /* options.listenerSetter.add(info.checkboxField.input)('change', (e) => {
@ -82,7 +92,7 @@ export class ChatPermissions {
}); */ }); */
attachClickEvent(info.checkboxField.label, (e) => { attachClickEvent(info.checkboxField.label, (e) => {
toast(I18n.format('UserRestrictionsDisabled', true)); toast(I18n.format(restrictionText, true));
}, {listenerSetter: options.listenerSetter}); }, {listenerSetter: options.listenerSetter});
} }

1
src/lang.ts

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

Loading…
Cancel
Save