Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Room Endpoint Call Issues #25928

Merged
merged 6 commits into from
Jun 27, 2022
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
8 changes: 6 additions & 2 deletions apps/meteor/app/api/server/v1/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from '@rocket.chat/rest-typings';

import { Rooms, Subscriptions, Messages } from '../../../models/server';
import { hasPermission, hasAllPermission } from '../../../authorization/server';
import { hasPermission } from '../../../authorization/server';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
import { API } from '../api';
import { Team } from '../../../../server/sdk';
Expand Down Expand Up @@ -454,7 +454,7 @@ API.v1.addRoute(
},
{
async post() {
if (!hasAllPermission(this.userId, ['create-team', 'edit-room'])) {
if (!hasPermission(this.userId, 'create-team')) {
return API.v1.unauthorized();
}

Expand All @@ -464,6 +464,10 @@ API.v1.addRoute(
return API.v1.failure('The parameter "channelId" or "channelName" is required');
}

if (!hasPermission(this.userId, 'edit-room', channelId)) {
return API.v1.unauthorized();
}

const room = findChannelByIdOrName({
params: {
roomId: channelId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ const RoomInfoWithData = ({ rid, openEditing, onClickBack, onEnterRoom, resetSta
const dispatchToastMessage = useToastMessageDispatch();
const setModal = useSetModal();
const closeModal = useMutableCallback(() => setModal());
const deleteRoom = useEndpoint('POST', room.t === 'c' ? 'channels.delete' : 'groups.delete');
const deleteRoom = useEndpoint('POST', room.t === 'c' ? '/v1/channels.delete' : '/v1/groups.delete');
const hideRoom = useMethod('hideRoom');
const leaveRoom = useMethod('leaveRoom');
const router = useRoute('home');

const moveChannelToTeam = useEndpointActionExperimental('POST', 'teams.addRooms', t('Rooms_added_successfully'));
const moveChannelToTeam = useEndpointActionExperimental('POST', '/v1/teams.addRooms', t('Rooms_added_successfully'));
const convertRoomToTeam = useEndpointActionExperimental(
'POST',
type === 'c' ? 'channels.convertToTeam' : 'groups.convertToTeam',
type === 'c' ? '/v1/channels.convertToTeam' : '/v1/groups.convertToTeam',
t('Success'),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const RoomActions = ({ room, reload }) => {
const canEditTeamChannel = usePermission('edit-team-channel', rid);
const canRemoveTeamChannel = usePermission('remove-team-channel', rid);

const updateRoomEndpoint = useEndpointActionExperimental('POST', 'teams.updateRoom');
const removeRoomEndpoint = useEndpointActionExperimental('POST', 'teams.removeRoom', t('Room_has_been_removed'));
const updateRoomEndpoint = useEndpointActionExperimental('POST', '/v1/teams.updateRoom');
const removeRoomEndpoint = useEndpointActionExperimental('POST', '/v1/teams.removeRoom', t('Room_has_been_removed'));
const deleteRoomEndpoint = useEndpointActionExperimental(
'POST',
room.t === 'c' ? 'channels.delete' : 'groups.delete',
room.t === 'c' ? '/v1/channels.delete' : '/v1/groups.delete',
t('Room_has_been_deleted'),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ const TeamsInfoWithLogic = ({ room, openEditing }) => {
const setModal = useSetModal();
const closeModal = useMutableCallback(() => setModal());

const deleteTeam = useEndpointActionExperimental('POST', 'teams.delete');
const leaveTeam = useEndpointActionExperimental('POST', 'teams.leave');
const convertTeamToChannel = useEndpointActionExperimental('POST', 'teams.convertToChannel');
const deleteTeam = useEndpointActionExperimental('POST', '/v1/teams.delete');
const leaveTeam = useEndpointActionExperimental('POST', '/V1/teams.leave');
const convertTeamToChannel = useEndpointActionExperimental('POST', '/v1/teams.convertToChannel');

const hideTeam = useMethod('hideRoom');

Expand Down