Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions app/api/server/v1/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,6 @@ API.v1.addRoute('teams.create', { authRequired: true }, {
},
});

API.v1.addRoute('teams.addRoom', { authRequired: true }, {
post() {
const { roomId, teamId, teamName, isDefault } = this.bodyParams;

const team = teamId ? Promise.await(Team.getOneById(teamId)) : Promise.await(Team.getOneByName(teamName));
if (!team) {
return API.v1.failure('team-does-not-exist');
}

if (!hasPermission(this.userId, 'add-team-channel', team.roomId)) {
return API.v1.unauthorized();
}

const room = Promise.await(Team.addRoom(this.userId, roomId, team._id, isDefault));

return API.v1.success({ room });
},
});

API.v1.addRoute('teams.addRooms', { authRequired: true }, {
post() {
const { rooms, teamId, teamName } = this.bodyParams;
Expand Down
4 changes: 2 additions & 2 deletions client/views/room/contextualBar/Info/RoomInfo/RoomInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const RoomInfoWithData = ({
const leaveRoom = useMethod('leaveRoom');
const router = useRoute('home');

const moveChannelToTeam = useEndpointActionExperimental('POST', 'teams.addRoom', t('Success'));
const moveChannelToTeam = useEndpointActionExperimental('POST', 'teams.addRooms', t('Success'));
const convertRoomToTeam = useEndpointActionExperimental(
'POST',
type === 'c' ? 'channels.convertToTeam' : 'groups.convertToTeam',
Expand Down Expand Up @@ -303,7 +303,7 @@ const RoomInfoWithData = ({
const onMoveToTeam = useMutableCallback(async () => {
const onConfirm = async (teamId) => {
try {
await moveChannelToTeam({ roomId: rid, teamId });
await moveChannelToTeam({ rooms: [rid], teamId });
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
} finally {
Expand Down
1 change: 0 additions & 1 deletion server/sdk/types/ITeamService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export interface ITeamInfo extends ITeam {

export interface ITeamService {
create(uid: string, params: ITeamCreateParams): Promise<ITeam>;
addRoom(uid: string, rid: string, teamId: string, isDefault: boolean): Promise<IRoom>;
addRooms(uid: string, rooms: Array<string>, teamId: string): Promise<Array<IRoom>>;
removeRoom(uid: string, rid: string, teamId: string, canRemoveAnyRoom: boolean): Promise<IRoom>;
listRooms(uid: string, teamId: string, getAllRooms: boolean, allowPrivateTeam: boolean, pagination: IPaginationOptions, queryOptions: IQueryOptions<IRoom>): Promise<IRecordsWithTotal<IRoom>>;
Expand Down
35 changes: 0 additions & 35 deletions server/services/team/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,41 +242,6 @@ export class TeamService extends ServiceClass implements ITeamService {
return this.TeamModel.findByIds(ids, options).toArray();
}

async addRoom(uid: string, rid: string, teamId: string, isDefault = false): Promise<IRoom> {
if (!teamId) {
throw new Error('missing-teamId');
}
if (!rid) {
throw new Error('missing-roomId');
}
if (!uid) {
throw new Error('missing-userId');
}
// at this point, we already checked for the permission
// so we just need to check if the user can see the room
const room = await this.RoomsModel.findOneById(rid);
const user = await this.Users.findOneById(uid);
const canSeeRoom = await canAccessRoom(room, user);
if (!canSeeRoom) {
throw new Error('invalid-room');
}

const team = await this.TeamModel.findOneById(teamId, { projection: { _id: 1 } });
if (!team) {
throw new Error('invalid-team');
}
if (room.teamId) {
throw new Error('room-already-on-team');
}

room.teamId = teamId;
room.teamDefault = !!isDefault;
this.RoomsModel.setTeamById(room._id, teamId, isDefault);
return {
...room,
};
}

async addRooms(uid: string, rooms: Array<string>, teamId: string): Promise<Array<IRoom>> {
if (!teamId) {
throw new Error('missing-teamId');
Expand Down
Loading