Chore: Migrate REST API - removeUserFromRoom to Typescript (#3837)

This commit is contained in:
Gleidson Daniel Silva 2022-03-07 09:44:11 -03:00 committed by GitHub
parent 256bf0eaee
commit 82439159a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 4 deletions

View File

@ -52,6 +52,9 @@ export type ChannelsEndpoints = {
'channels.convertToTeam': { 'channels.convertToTeam': {
POST: (params: { channelId: string; channelName: string }) => { team: ITeam }; POST: (params: { channelId: string; channelName: string }) => { team: ITeam };
}; };
'channels.kick': {
POST: (params: { roomId: string; userId: string }) => {};
};
'channels.delete': { 'channels.delete': {
POST: (params: { roomId: string }) => {}; POST: (params: { roomId: string }) => {};
}; };

View File

@ -46,6 +46,9 @@ export type GroupsEndpoints = {
'groups.convertToTeam': { 'groups.convertToTeam': {
POST: (params: { roomId: string; roomName: string }) => { team: ITeam }; POST: (params: { roomId: string; roomName: string }) => { team: ITeam };
}; };
'groups.kick': {
POST: (params: { roomId: string; userId: string }) => {};
};
'groups.delete': { 'groups.delete': {
POST: (params: { roomId: string }) => {}; POST: (params: { roomId: string }) => {};
}; };

View File

@ -38,6 +38,9 @@ export type ImEndpoints = {
messages: IMessageFromServer[]; messages: IMessageFromServer[];
}; };
}; };
'im.kick': {
POST: (params: { roomId: string; userId: string }) => {};
};
'im.delete': { 'im.delete': {
POST: (params: { roomId: string }) => {}; POST: (params: { roomId: string }) => {};
}; };

View File

@ -514,10 +514,8 @@ export const toggleRoomModerator = ({
return sdk.post(`${roomTypeToApiType(t)}.removeModerator`, { roomId, userId }); return sdk.post(`${roomTypeToApiType(t)}.removeModerator`, { roomId, userId });
}; };
export const removeUserFromRoom = ({ roomId, t, userId }: { roomId: string; t: SubscriptionType; userId: string }): any => export const removeUserFromRoom = ({ roomId, t, userId }: { roomId: string; t: RoomTypes; userId: string }) =>
// RC 0.48.0 // RC 0.48.0
// TODO: missing definitions from server
// @ts-ignore
sdk.post(`${roomTypeToApiType(t)}.kick`, { roomId, userId }); sdk.post(`${roomTypeToApiType(t)}.kick`, { roomId, userId });
export const ignoreUser = ({ rid, userId, ignore }: { rid: string; userId: string; ignore: boolean }): any => export const ignoreUser = ({ rid, userId, ignore }: { rid: string; userId: string; ignore: boolean }): any =>

View File

@ -28,6 +28,7 @@ import { goRoom, TGoRoomItem } from '../../utils/goRoom';
import { showConfirmationAlert, showErrorAlert } from '../../utils/info'; import { showConfirmationAlert, showErrorAlert } from '../../utils/info';
import log from '../../utils/log'; import log from '../../utils/log';
import scrollPersistTaps from '../../utils/scrollPersistTaps'; import scrollPersistTaps from '../../utils/scrollPersistTaps';
import { RoomTypes } from '../../lib/rocketchat/methods/roomTypeToApiType';
import styles from './styles'; import styles from './styles';
const PAGE_SIZE = 25; const PAGE_SIZE = 25;
@ -590,7 +591,8 @@ class RoomMembersView extends React.Component<IRoomMembersViewProps, IRoomMember
try { try {
const { room, members, membersFiltered } = this.state; const { room, members, membersFiltered } = this.state;
const userId = selectedUser._id; const userId = selectedUser._id;
await RocketChat.removeUserFromRoom({ roomId: room.rid, t: room.t, userId }); // TODO: interface SubscriptionType on IRoom is wrong
await RocketChat.removeUserFromRoom({ roomId: room.rid, t: room.t as RoomTypes, userId });
const message = I18n.t('User_has_been_removed_from_s', { s: RocketChat.getRoomTitle(room) }); const message = I18n.t('User_has_been_removed_from_s', { s: RocketChat.getRoomTitle(room) });
EventEmitter.emit(LISTENER, { message }); EventEmitter.emit(LISTENER, { message });
this.setState({ this.setState({