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

[IMPROVE] VoIP admin page cleanup: remove unused settings #25993

Merged
merged 11 commits into from
Jun 29, 2022
17 changes: 0 additions & 17 deletions apps/meteor/app/lib/server/startup/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3201,7 +3201,6 @@ settingsRegistry.addGroup('Call_Center', function () {
this.add('VoIP_Enabled', false, {
type: 'boolean',
public: true,
alert: 'Experimental_Feature_Alert',
enableQuery: {
_id: 'Livechat_enabled',
value: true,
Expand All @@ -3216,22 +3215,6 @@ settingsRegistry.addGroup('Call_Center', function () {
},
});
this.section('Server_Configuration', function () {
this.add('VoIP_Server_Host', '', {
type: 'string',
public: true,
enableQuery: {
_id: 'VoIP_Enabled',
value: true,
},
});
this.add('VoIP_Server_Websocket_Port', 0, {
type: 'int',
public: true,
enableQuery: {
_id: 'VoIP_Enabled',
value: true,
},
});
this.add('VoIP_Server_Name', '', {
type: 'string',
public: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const empty = {};

const isSignedResponse = (data: any): data is { result: string } => typeof data?.result === 'string';

// Currently we only support the websocket connection and the SIP proxy connection being from the same host,
// we need to add a new setting for SIP proxy if we want to support different hosts for them.
export const useVoipClient = (): UseVoipClientResult => {
const [voipEnabled, setVoipEnabled] = useSafely(useState(useSetting('VoIP_Enabled')));
const voipRetryCount = useSetting('VoIP_Retry_Count');
Expand Down Expand Up @@ -57,17 +59,17 @@ export const useVoipClient = (): UseVoipClientResult => {

const {
extensionDetails: { extension, password },
host,
callServerConfig: { websocketPath },
} = parsedData;

(async (): Promise<void> => {
try {
const wsURL = new URL(websocketPath);
const subscription = await membership({ extension });
client = await SimpleVoipUser.create(
extension,
password,
host,
wsURL.host,
websocketPath,
iceServers,
Number(voipRetryCount),
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -4860,7 +4860,7 @@
"VoIP_Server_Host": "Server Host",
"VoIP_Server_Websocket_Port": "Websocket Port",
"VoIP_Server_Name": "Server Name",
"VoIP_Server_Websocket_Path": "Websocket Path",
"VoIP_Server_Websocket_Path": "Websocket URL",
"VoIP_Retry_Count": "Retry Count",
"VoIP_Retry_Count_Description": "Defines the number of times the client will try to reconnect to the VoIP server if the connection is lost.",
"VoIP_Management_Server": "VoIP Management Server",
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -4748,7 +4748,7 @@
"VoIP_Server_Host": "Hoste do servidor",
"VoIP_Server_Websocket_Port": "Porta do webSocket",
"VoIP_Server_Name": "Nome do servidor",
"VoIP_Server_Websocket_Path": "Caminho do webSocket",
"VoIP_Server_Websocket_Path": "URL do webSocket",
"VoIP_Management_Server": "Servidor de gerenciamento de VoIP",
"VoIP_Management_Server_Host": "Host de servidor",
"VoIP_Management_Server_Port": "Porta do servidor",
Expand Down
2 changes: 0 additions & 2 deletions apps/meteor/server/services/voip/lib/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ export function getServerConfigDataFromSettings(type: ServerType): IVoipCallServ
case ServerType.CALL_SERVER: {
const serverCofig: IVoipCallServerConfig = {
type: ServerType.CALL_SERVER,
host: settings.get<string>('VoIP_Server_Host'),
name: settings.get<string>('VoIP_Server_Name'),
configData: {
websocketPort: Number(settings.get<number>('VoIP_Server_Websocket_Port')),
websocketPath: settings.get<string>('VoIP_Server_Websocket_Path'),
},
};
Expand Down
1 change: 0 additions & 1 deletion apps/meteor/server/services/voip/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ export class VoipService extends ServiceClassInternal implements IVoipService {
}

const result = {
host: config.host,
callServerConfig: config.configData,
extensionDetails: endpointDetails.result,
};
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/server/startup/migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ import './v268';
import './v269';
import './v270';
import './v271';
import './v272';
import './xrun';
14 changes: 14 additions & 0 deletions apps/meteor/server/startup/migrations/v272.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Settings } from '@rocket.chat/models';

import { addMigration } from '../../lib/migrations';

addMigration({
version: 272,
async up() {
await Settings.deleteMany({
_id: {
$in: ['VoIP_Server_Host', 'VoIP_Server_Websocket_Port'],
},
});
},
});
2 changes: 1 addition & 1 deletion packages/core-typings/src/IVoipExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ export const isIExtensionDetails = (prop: any): prop is IExtensionDetails =>
prop.extension !== undefined && prop.password !== undefined && prop.authtype !== undefined && prop.state !== undefined;

export const isIRegistrationInfo = (prop: any): prop is IRegistrationInfo =>
prop.hasOwnProperty('host') && prop.hasOwnProperty('callServerConfig') && prop.hasOwnProperty('extensionDetails');
prop.hasOwnProperty('callServerConfig') && prop.hasOwnProperty('extensionDetails');
KevLehman marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 2 additions & 3 deletions packages/core-typings/src/IVoipServerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export enum ServerType {

export interface IVoipServerConfigBase {
type: ServerType;
host: string;
name: string;
}

Expand All @@ -18,6 +17,7 @@ export interface IVoipCallServerConfig extends IVoipServerConfigBase {

export interface IVoipManagementServerConfig extends IVoipServerConfigBase {
type: ServerType.MANAGEMENT;
host: string;
configData: IManagementConfigData;
}

Expand All @@ -27,5 +27,4 @@ export interface IManagementConfigData {
password: string;
}

export const isICallServerConfigData = (obj: any): obj is ICallServerConfigData =>
Number.isInteger(obj.websocketPort) && String(obj.websocketPath) === obj.websocketPath;
export const isICallServerConfigData = (obj: any): obj is ICallServerConfigData => String(obj.websocketPath) === obj.websocketPath;
2 changes: 0 additions & 2 deletions packages/core-typings/src/voip/IRegistrationInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

export interface ICallServerConfigData {
websocketPort: number;
websocketPath: string;
}
export interface IExtensionDetails {
Expand All @@ -16,7 +15,6 @@ export interface IExtensionDetails {
state: string;
}
export interface IRegistrationInfo {
host: string;
callServerConfig: ICallServerConfigData;
extensionDetails: IExtensionDetails;
}