pull/1819/head
Brice-W 4 years ago
parent 2c6821097d
commit d8fa73d393

@ -169,7 +169,9 @@ export const MessageContextMenu = (props: PropsForMessageContextMenu) => {
</>
) : null}
{weAreAdmin && isPublic ? <Item onClick={onBan}>{window.i18n('banUser')}</Item> : null}
{weAreAdmin && isPublic ? <Item onClick={onBanAndDeleteAll}>{window.i18n('banUserAndDeleteAll')}</Item> : null}
{weAreAdmin && isPublic ? (
<Item onClick={onBanAndDeleteAll}>{window.i18n('banUserAndDeleteAll')}</Item>
) : null}
{weAreAdmin && isOpenGroupV2 ? (
<Item onClick={onUnban}>{window.i18n('unbanUser')}</Item>
) : null}

@ -10,7 +10,11 @@ import { ToastUtils } from '../session/utils';
import { updateConfirmModal } from '../state/ducks/modalDialog';
export function banUser(userToBan: string, conversationId: string, deleteAllMessages: boolean = false) {
export function banUser(
userToBan: string,
conversationId: string,
deleteAllMessages: boolean = false
) {
let pubKeyToBan: PubKey;
try {
pubKeyToBan = PubKey.cast(userToBan);
@ -24,8 +28,10 @@ export function banUser(userToBan: string, conversationId: string, deleteAllMess
window.inboxStore?.dispatch(updateConfirmModal(null));
};
const title = (deleteAllMessages) ? window.i18n('banUserAndDeleteAll') : window.i18n('banUser');
const message = (deleteAllMessages) ? window.i18n('banUserAndDeleteAllConfirm') : window.i18n('banUserConfirm');
const title = deleteAllMessages ? window.i18n('banUserAndDeleteAll') : window.i18n('banUser');
const message = deleteAllMessages
? window.i18n('banUserAndDeleteAllConfirm')
: window.i18n('banUserConfirm');
const confirmationModalProps = {
title: title,
@ -43,7 +49,11 @@ export function banUser(userToBan: string, conversationId: string, deleteAllMess
if (!roomInfos) {
window.log.warn('banUser room not found');
} else {
success = await ApiV2.banUser(pubKeyToBan, _.pick(roomInfos, 'serverUrl', 'roomId'), deleteAllMessages);
success = await ApiV2.banUser(
pubKeyToBan,
_.pick(roomInfos, 'serverUrl', 'roomId'),
deleteAllMessages
);
}
} else {
throw new Error('V1 opengroup are not supported');

@ -268,7 +268,7 @@ export const banUser = async (
deleteAllMessages: boolean
): Promise<boolean> => {
const queryParams = { public_key: userToBan.key };
const endPoint = (deleteAllMessages) ? 'ban_and_delete_all' : 'block_list';
const endPoint = deleteAllMessages ? 'ban_and_delete_all' : 'block_list';
const request: OpenGroupV2Request = {
method: 'POST',
room: roomInfos.roomId,

Loading…
Cancel
Save