Skip to content

Commit fb0acf6

Browse files
pierre-lehnen-rcggazzo
authored andcommitted
chore!: remove old voip permissions (#37672)
1 parent 83a5057 commit fb0acf6

File tree

21 files changed

+73
-119
lines changed

21 files changed

+73
-119
lines changed

.changeset/chilly-cobras-look.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@rocket.chat/i18n': major
3+
'@rocket.chat/meteor': major
4+
---
5+
6+
Removes deprecated VoIP permissions

.changeset/curly-bats-wink.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@rocket.chat/model-typings': major
3+
'@rocket.chat/core-typings': major
4+
'@rocket.chat/rest-typings': major
5+
'@rocket.chat/ui-contexts': major
6+
'@rocket.chat/ui-voip': major
7+
'@rocket.chat/models': major
8+
'@rocket.chat/i18n': major
9+
'@rocket.chat/meteor': major
10+
'@rocket.chat/apps-engine': minor
11+
'@rocket.chat/core-services': minor
12+
'@rocket.chat/message-types': minor
13+
'@rocket.chat/ddp-client': minor
14+
---
15+
16+
Removes deprecated VoIP from Omnichannel

.changeset/four-timers-enjoy.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@rocket.chat/model-typings': major
3+
'@rocket.chat/core-typings': major
4+
'@rocket.chat/rest-typings': major
5+
'@rocket.chat/models': major
6+
'@rocket.chat/i18n': major
7+
'@rocket.chat/meteor': major
8+
'@rocket.chat/core-services': minor
9+
---
10+
11+
Removes Deprecated FreeSwitch integration

apps/meteor/app/api/server/lib/users.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ export async function findPaginatedUsersByStatus({
169169
}
170170

171171
const canSeeAllUserInfo = await hasPermissionAsync(uid, 'view-full-other-user-info');
172-
const canSeeExtension = canSeeAllUserInfo || (await hasPermissionAsync(uid, 'view-user-voip-extension'));
173172

174173
const projection = {
175174
name: 1,
@@ -183,7 +182,7 @@ export async function findPaginatedUsersByStatus({
183182
type: 1,
184183
reason: 1,
185184
federated: 1,
186-
...(canSeeExtension ? { freeSwitchExtension: 1 } : {}),
185+
freeSwitchExtension: 1,
187186
};
188187

189188
if (searchTerm?.trim()) {

apps/meteor/app/api/server/v1/im.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { openRoom } from '../../../../server/lib/openRoom';
2222
import { createDirectMessage } from '../../../../server/methods/createDirectMessage';
2323
import { hideRoomMethod } from '../../../../server/methods/hideRoom';
2424
import { canAccessRoomIdAsync } from '../../../authorization/server/functions/canAccessRoom';
25-
import { hasAtLeastOnePermissionAsync, hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
25+
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
2626
import { saveRoomSettings } from '../../../channel-settings/server/methods/saveRoomSettings';
2727
import { getRoomByNameOrIdWithOptionToJoin } from '../../../lib/server/functions/getRoomByNameOrIdWithOptionToJoin';
2828
import { getChannelHistory } from '../../../lib/server/methods/getChannelHistory';
@@ -385,12 +385,6 @@ API.v1.addRoute(
385385
...(status && { status: { $in: status } }),
386386
};
387387

388-
const canSeeExtension = await hasAtLeastOnePermissionAsync(
389-
this.userId,
390-
['view-full-other-user-info', 'view-user-voip-extension'],
391-
room._id,
392-
);
393-
394388
const options: FindOptions<IUser> = {
395389
projection: {
396390
_id: 1,
@@ -400,7 +394,7 @@ API.v1.addRoute(
400394
statusText: 1,
401395
utcOffset: 1,
402396
federated: 1,
403-
...(canSeeExtension && { freeSwitchExtension: 1 }),
397+
freeSwitchExtension: 1,
404398
},
405399
skip: offset,
406400
limit: count,

apps/meteor/app/api/server/v1/users.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ API.v1.addRoute(
326326
validateCustomFields(this.bodyParams.customFields);
327327
}
328328

329-
if (this.bodyParams.freeSwitchExtension && !(await canEditExtension(this.userId, this.bodyParams.freeSwitchExtension))) {
329+
if (this.bodyParams.freeSwitchExtension && !(await canEditExtension(this.bodyParams.freeSwitchExtension))) {
330330
return API.v1.failure('Setting user voice call extension is not allowed', 'error-action-not-allowed');
331331
}
332332

apps/meteor/app/authorization/server/constant/permissions.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,6 @@ export const permissions = [
211211
{ _id: 'remove-closed-livechat-room', roles: ['livechat-manager', 'admin'] },
212212
{ _id: 'remove-livechat-department', roles: ['livechat-manager', 'admin'] },
213213

214-
// Allow managing team collab voip extensions
215-
{ _id: 'manage-voip-extensions', roles: ['admin'] },
216-
// Allow viewing the extension number of other users
217-
{ _id: 'view-user-voip-extension', roles: ['admin', 'user'] },
218-
// Allow viewing details of an extension
219-
{ _id: 'view-voip-extension-details', roles: ['admin', 'user'] },
220-
221214
// New Media calls permissions
222215
{ _id: 'allow-internal-voice-calls', roles: ['admin', 'user'] },
223216
{ _id: 'allow-external-voice-calls', roles: ['admin', 'user'] },

apps/meteor/app/lib/server/functions/getFullUserData.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const defaultFields = {
2121
avatarETag: 1,
2222
federated: 1,
2323
statusLivechat: 1,
24+
freeSwitchExtension: 1,
2425
} as const;
2526

2627
const fullFields = {
@@ -34,7 +35,6 @@ const fullFields = {
3435
requirePasswordChangeReason: 1,
3536
roles: 1,
3637
importIds: 1,
37-
freeSwitchExtension: 1,
3838
} as const;
3939

4040
let publicCustomFields: Record<string, 0 | 1> = {};
@@ -85,7 +85,6 @@ export async function getFullUserDataByIdOrUsernameOrImportId(
8585
(searchType === 'username' && searchValue === caller.username) ||
8686
(searchType === 'importId' && caller.importIds?.includes(searchValue));
8787
const canViewAllInfo = !!myself || (await hasPermissionAsync(userId, 'view-full-other-user-info'));
88-
const canViewExtension = !!myself || (await hasPermissionAsync(userId, 'view-user-voip-extension'));
8988

9089
// Only search for importId if the user has permission to view the import id
9190
if (searchType === 'importId' && !canViewAllInfo) {
@@ -97,7 +96,6 @@ export async function getFullUserDataByIdOrUsernameOrImportId(
9796
const options = {
9897
projection: {
9998
...fields,
100-
...(canViewExtension && { freeSwitchExtension: 1 }),
10199
...(myself && { services: 1 }),
102100
},
103101
};

apps/meteor/app/lib/server/functions/saveUser/validateUserEditing.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,11 @@ const isEditingUserRoles = (previousRoles: IUser['roles'], newRoles?: IUser['rol
1212
(newRoles.some((item) => !previousRoles.includes(item)) || previousRoles.some((item) => !newRoles.includes(item)));
1313
const isEditingField = (previousValue?: string, newValue?: string) => typeof newValue !== 'undefined' && newValue !== previousValue;
1414

15-
export const canEditExtension = async (userId: string, newExtension?: string) => {
15+
export const canEditExtension = async (newExtension?: string) => {
1616
if (!settings.get('VoIP_TeamCollab_Enabled')) {
1717
return false;
1818
}
1919

20-
if (!(await hasPermissionAsync(userId, 'manage-voip-extensions'))) {
21-
return false;
22-
}
23-
2420
if (newExtension && (await Users.findOneByFreeSwitchExtension(newExtension, { projection: { _id: 1 } }))) {
2521
throw new MeteorError('error-extension-not-available', 'Extension is already assigned to another user');
2622
}
@@ -117,7 +113,7 @@ export async function validateUserEditing(userId: IUser['_id'], userData: Update
117113

118114
if (
119115
isEditingField(user.freeSwitchExtension ?? '', userData.freeSwitchExtension) &&
120-
!(await canEditExtension(userId, userData.freeSwitchExtension))
116+
!(await canEditExtension(userData.freeSwitchExtension))
121117
) {
122118
throw new MeteorError('error-action-not-allowed', 'Edit user voice call extension is not allowed', {
123119
method: 'insertOrUpdateUser',

apps/meteor/client/views/admin/users/AdminUserForm.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import AdminUserSetRandomPasswordContent from './AdminUserSetRandomPasswordConte
3737
import AdminUserSetRandomPasswordRadios from './AdminUserSetRandomPasswordRadios';
3838
import PasswordFieldSkeleton from './PasswordFieldSkeleton';
3939
import { useSmtpQuery } from './hooks/useSmtpQuery';
40-
import { useVoipExtensionPermission } from './useVoipExtensionPermission';
40+
import { useShowVoipExtension } from './useShowVoipExtension';
4141
import { validateEmail } from '../../../../lib/emailValidator';
4242
import { parseCSV } from '../../../../lib/utils/parseCSV';
4343
import UserAvatarEditor from '../../../components/avatar/UserAvatarEditor';
@@ -123,7 +123,7 @@ const AdminUserForm = ({ userData, onReload, context, refetchUserFormData, roleD
123123
mode: 'onBlur',
124124
});
125125

126-
const canManageVoipExtension = useVoipExtensionPermission();
126+
const showVoipExtension = useShowVoipExtension();
127127

128128
const { avatar, username, setRandomPassword, password, name: userFullName } = watch();
129129

@@ -341,7 +341,7 @@ const AdminUserForm = ({ userData, onReload, context, refetchUserFormData, roleD
341341
</FieldError>
342342
)}
343343
</Field>
344-
{canManageVoipExtension && (
344+
{showVoipExtension && (
345345
<Field>
346346
<FieldLabel htmlFor={voiceExtensionId}>{t('Voice_call_extension')}</FieldLabel>
347347
<FieldRow>

0 commit comments

Comments
 (0)