diff --git a/apps/meteor/ee/app/api-enterprise/server/voip-freeswitch.ts b/apps/meteor/ee/app/api-enterprise/server/voip-freeswitch.ts index b4857896e01d..6cadec3c6dba 100644 --- a/apps/meteor/ee/app/api-enterprise/server/voip-freeswitch.ts +++ b/apps/meteor/ee/app/api-enterprise/server/voip-freeswitch.ts @@ -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') { @@ -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) { @@ -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); @@ -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); diff --git a/packages/i18n/src/locales/en.i18n.json b/packages/i18n/src/locales/en.i18n.json index b89b760caadf..a5cb3f542715 100644 --- a/packages/i18n/src/locales/en.i18n.json +++ b/packages/i18n/src/locales/en.i18n.json @@ -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}}`", @@ -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", @@ -5729,7 +5733,6 @@ "User_uploaded_a_file_to_you": "{{username}} 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", diff --git a/packages/i18n/src/locales/pt-BR.i18n.json b/packages/i18n/src/locales/pt-BR.i18n.json index 4d986be29219..e1402ee57941 100644 --- a/packages/i18n/src/locales/pt-BR.i18n.json +++ b/packages/i18n/src/locales/pt-BR.i18n.json @@ -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)", @@ -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", @@ -4607,7 +4611,6 @@ "User_uploaded_a_file_to_you": "{{username}} 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", diff --git a/packages/i18n/src/locales/se.i18n.json b/packages/i18n/src/locales/se.i18n.json index b890eb5b10f0..36363716b8fd 100644 --- a/packages/i18n/src/locales/se.i18n.json +++ b/packages/i18n/src/locales/se.i18n.json @@ -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", @@ -5734,7 +5733,6 @@ "User_uploaded_a_file_to_you": "{{username}} 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", diff --git a/packages/ui-voip/src/hooks/useVoipClient.tsx b/packages/ui-voip/src/hooks/useVoipClient.tsx index 37715ea918dd..e4aad0f4919b 100644 --- a/packages/ui-voip/src/hooks/useVoipClient.tsx +++ b/packages/ui-voip/src/hooks/useVoipClient.tsx @@ -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'; @@ -31,19 +31,19 @@ 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 { @@ -51,10 +51,6 @@ export const useVoipClient = ({ autoRegister = true }: VoipClientParams): VoipCl credentials: { websocketPath, password }, } = registrationInfo; - if (!extension) { - throw Error('User_extension_not_found'); - } - const config = { iceServers, authUserName: extension,