Skip to content

Commit

Permalink
Chore: Server API types - teams.updateRoom (#3774)
Browse files Browse the repository at this point in the history
* chore: type the API call `teams.updateRoom`

* chore: creating the interface `IServerTeamUpdateRoom`

* chore: minor tweak after merge
  • Loading branch information
AlexAlexandre authored Mar 3, 2022
1 parent 7de686b commit 214cf52
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
14 changes: 14 additions & 0 deletions app/definitions/ITeam.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IRocketChatRecord } from './IRocketChatRecord';
import { IUser } from './IUser';
import { IServerRoomItem } from './IRoom';

export enum TEAM_TYPE {
PUBLIC = 0,
Expand Down Expand Up @@ -46,3 +47,16 @@ export interface ITeamStats {
totalTeams: number;
teamStats: Array<ITeamStatData>;
}

export interface IServerTeamUpdateRoom
extends Omit<
IServerRoomItem,
'topic' | 'joinCodeRequired' | 'description' | 'jitsiTimeout' | 'usersCount' | 'e2eKeyId' | 'avatarETag'
> {
broadcast: boolean;
msgs: number;
default: boolean;
sysMes: boolean;
teamId: string;
teamDefault: boolean;
}
5 changes: 4 additions & 1 deletion app/definitions/rest/v1/teams.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { IRoom } from '../../IRoom';
import { ITeam, TEAM_TYPE } from '../../ITeam';
import { IServerTeamUpdateRoom, ITeam, TEAM_TYPE } from '../../ITeam';

export type TeamsEndpoints = {
'teams.removeRoom': {
POST: (params: { roomId: string; teamId: string }) => { room: IRoom };
};
'teams.updateRoom': {
POST: (params: { roomId: string; isDefault: boolean }) => { room: IServerTeamUpdateRoom };
};
'teams.convertToChannel': {
POST: (params: { teamId: string; roomsToRemove?: string[] }) => {};
};
Expand Down
2 changes: 1 addition & 1 deletion app/lib/methods/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { E2E_PRIVATE_KEY, E2E_PUBLIC_KEY, E2E_RANDOM_PASSWORD_KEY } from '../enc
import UserPreferences from '../userPreferences';
import { ICertificate, IRocketChat } from '../../definitions';

async function removeServerKeys({ server, userId }: { server: string; userId: string | null }) {
async function removeServerKeys({ server, userId }: { server: string; userId?: string | null }) {
await UserPreferences.removeItem(`${RocketChat.TOKEN_KEY}-${server}`);
if (userId) {
await UserPreferences.removeItem(`${RocketChat.TOKEN_KEY}-${userId}`);
Expand Down
4 changes: 1 addition & 3 deletions app/lib/rocketchat/services/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,8 @@ export const removeTeamMember = ({ teamId, userId, rooms }: { teamId: string; us
...(rooms?.length && { rooms })
});

export const updateTeamRoom = ({ roomId, isDefault }: { roomId: string; isDefault: boolean }): any =>
export const updateTeamRoom = ({ roomId, isDefault }: { roomId: string; isDefault: boolean }) =>
// RC 3.13.0
// TODO: missing definitions from server
// @ts-ignore
sdk.post('teams.updateRoom', { roomId, isDefault });

export const deleteTeam = ({ teamId, roomsToRemove }: { teamId: string; roomsToRemove: string[] }): any =>
Expand Down

0 comments on commit 214cf52

Please sign in to comment.