Skip to content

Commit

Permalink
Merge branch 'develop' into chore/bump-pdfworker
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo authored Oct 12, 2024
2 parents 0b05ffc + 00cdca7 commit f0029ad
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
14 changes: 7 additions & 7 deletions apps/meteor/ee/app/api-enterprise/server/voip-freeswitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ API.v1.addRoute(
const { username, type = 'all' } = this.queryParams;

const extensions = await wrapExceptions(() => VoipFreeSwitch.getExtensionList()).catch(() => {
throw new Error('Failed to load extension list.');
throw new Error('error-loading-extension-list');
});

if (type === 'all') {
Expand Down Expand Up @@ -71,7 +71,7 @@ API.v1.addRoute(

const existingUser = extension && (await Users.findOneByFreeSwitchExtension(extension, { projection: { _id: 1 } }));
if (existingUser && existingUser._id !== user._id) {
throw new Error('Extension not available.');
throw new Error('error-extension-not-available');
}

if (extension && user.freeSwitchExtension === extension) {
Expand All @@ -92,7 +92,7 @@ API.v1.addRoute(
const { extension, group } = this.queryParams;

if (!extension) {
throw new Error('Invalid params');
throw new Error('error-invalid-params');
}

const extensionData = await wrapExceptions(() => VoipFreeSwitch.getExtensionDetails({ extension, group })).suppress(() => undefined);
Expand All @@ -118,23 +118,23 @@ API.v1.addRoute(
const { userId } = this.queryParams;

if (!userId) {
throw new Error('Invalid params.');
throw new Error('error-invalid-params');
}

const user = await Users.findOneById(userId, { projection: { freeSwitchExtension: 1 } });
if (!user) {
throw new Error('User not found.');
throw new Error('error-user-not-found');
}

const { freeSwitchExtension: extension } = user;

if (!extension) {
throw new Error('Extension not assigned.');
throw new Error('error-extension-not-assigned');
}

const extensionData = await wrapExceptions(() => VoipFreeSwitch.getExtensionDetails({ extension })).suppress(() => undefined);
if (!extensionData) {
return API.v1.notFound();
return API.v1.notFound('error-registration-not-found');
}
const password = await wrapExceptions(() => VoipFreeSwitch.getUserPassword(extension)).suppress(() => undefined);

Expand Down
7 changes: 5 additions & 2 deletions packages/i18n/src/locales/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2215,6 +2215,11 @@
"error-contact-sent-last-message-so-cannot-place-on-hold": "You cannot place chat on-hold, when the Contact has sent the last message",
"error-unserved-rooms-cannot-be-placed-onhold": "Room cannot be placed on hold before being served",
"error-timeout": "The request has timed out",
"error-loading-extension-list": "Failed to load extension list",
"error-registration-not-found": "Registration information not found",
"error-extension-not-available": "Extension not available",
"error-user-not-found": "User not found",
"error-extension-not-assigned": "Extension not assigned",
"Workspace_exceeded_MAC_limit_disclaimer": "The workspace has exceeded the monthly limit of active contacts. Talk to your workspace admin to address this issue.",
"You_do_not_have_permission_to_do_this": "You do not have permission to do this",
"You_do_not_have_permission_to_execute_this_command": "You do not have enough permissions to execute command: `/{{command}}`",
Expand Down Expand Up @@ -4460,7 +4465,6 @@
"Registration_status": "Registration status",
"Registration_Succeeded": "Registration Succeeded",
"Registration_via_Admin": "Registration via Admin",
"Registration_information_not_found": "Registration information not found",
"Regular_Expressions": "Regular Expressions",
"Reject_call": "Reject call",
"Release": "Release",
Expand Down Expand Up @@ -5729,7 +5733,6 @@
"User_uploaded_a_file_to_you": "<strong>{{username}}</strong> sent you a file",
"User_uploaded_file": "Uploaded a file",
"User_uploaded_image": "Uploaded an image",
"User_extension_not_found": "User extension not found",
"user-generate-access-token": "User Generate Access Token",
"user-generate-access-token_description": "Permission for users to generate access tokens",
"UserData_EnableDownload": "Enable User Data Download",
Expand Down
7 changes: 5 additions & 2 deletions packages/i18n/src/locales/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,11 @@
"error-you-are-last-owner": "Você é o último proprietário da sala. Defina um novo proprietário antes de sair.",
"error-cannot-place-chat-on-hold": "Você não pode colocar a conversa em espera",
"error-timeout": "A solicitação atingiu o tempo limite",
"error-loading-extension-list": "Falha ao carregar a lista de extensões",
"error-registration-not-found": "Informações de registro não encontradas",
"error-extension-not-available": "Extensão não disponível",
"error-user-not-found": "Usuário não encontrado",
"error-extension-not-assigned": "Extensão não atribuida",
"Errors_and_Warnings": "Erros e avisos",
"Esc_to": "Esc para",
"Estimated_wait_time": "Tempo estimado de espera (tempo em minutos)",
Expand Down Expand Up @@ -3564,7 +3569,6 @@
"Registration": "Registro",
"Registration_Succeeded": "Registrado com sucesso",
"Registration_via_Admin": "Registro via admin",
"Registration_information_not_found": "Informações de registro não encontradas",
"Regular_Expressions": "Expressões regulares",
"Reject_call": "Rejeitar chamada",
"Release": "Versão",
Expand Down Expand Up @@ -4607,7 +4611,6 @@
"User_uploaded_a_file_to_you": "<strong>{{username}}</strong> enviou um arquivo para você",
"User_uploaded_file": "Carregou um arquivo",
"User_uploaded_image": "Carregou uma imagem",
"User_extension_not_found": "Extensão do usuário não encontrada",
"user-generate-access-token": "Usuário pode gerar token de acesso",
"user-generate-access-token_description": "Permissão para usuários gerarem tokens de acesso",
"UserData_EnableDownload": "Ativar o download de dados do usuário",
Expand Down
2 changes: 0 additions & 2 deletions packages/i18n/src/locales/se.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -4465,7 +4465,6 @@
"Registration_status": "Registration status",
"Registration_Succeeded": "Registration Succeeded",
"Registration_via_Admin": "Registration via Admin",
"Registration_information_not_found": "Registration information not found",
"Regular_Expressions": "Regular Expressions",
"Reject_call": "Reject call",
"Release": "Release",
Expand Down Expand Up @@ -5734,7 +5733,6 @@
"User_uploaded_a_file_to_you": "<strong>{{username}}</strong> sent you a file",
"User_uploaded_file": "Uploaded a file",
"User_uploaded_image": "Uploaded an image",
"User_extension_not_found": "User extension not found",
"user-generate-access-token": "User Generate Access Token",
"user-generate-access-token_description": "Permission for users to generate access tokens",
"UserData_EnableDownload": "Enable User Data Download",
Expand Down
14 changes: 5 additions & 9 deletions packages/ui-voip/src/hooks/useVoipClient.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useUser, useSetting, useEndpoint } from '@rocket.chat/ui-contexts';
import { useUser, useEndpoint, useSetting } from '@rocket.chat/ui-contexts';
import { useQuery } from '@tanstack/react-query';
import { useEffect, useRef } from 'react';

Expand Down Expand Up @@ -31,30 +31,26 @@ export const useVoipClient = ({ autoRegister = true }: VoipClientParams): VoipCl
}

if (!userId) {
throw Error('User_not_found');
throw Error('error-user-not-found');
}

const registrationInfo = await getRegistrationInfo({ userId })
.then((registration) => {
if (!registration) {
throw Error();
throw Error('error-registration-not-found');
}

return registration;
})
.catch(() => {
throw Error('Registration_information_not_found');
.catch((e) => {
throw Error(e.error || 'error-registration-not-found');
});

const {
extension: { extension },
credentials: { websocketPath, password },
} = registrationInfo;

if (!extension) {
throw Error('User_extension_not_found');
}

const config = {
iceServers,
authUserName: extension,
Expand Down

0 comments on commit f0029ad

Please sign in to comment.