Skip to content

Commit

Permalink
chore: rename VoIP service to VoipAsterisk (#32377)
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-lehnen-rc authored May 8, 2024
1 parent dd0bbce commit 5d1cb28
Show file tree
Hide file tree
Showing 22 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/apps/meteor/server/models @RocketChat/Architecture
apps/meteor/server/startup/migrations @RocketChat/Architecture
/apps/meteor/packages/rocketchat-livechat @RocketChat/omnichannel
/apps/meteor/server/services/voip @RocketChat/omnichannel
/apps/meteor/server/services/voip-asterisk @RocketChat/omnichannel
/apps/meteor/server/services/omnichannel-voip @RocketChat/omnichannel
/apps/meteor/server/features/EmailInbox @RocketChat/omnichannel
/apps/meteor/ee/app/canned-responses @RocketChat/omnichannel
Expand Down
12 changes: 6 additions & 6 deletions apps/meteor/app/api/server/v1/voip/extensions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Voip } from '@rocket.chat/core-services';
import { VoipAsterisk } from '@rocket.chat/core-services';
import type { IVoipExtensionBase } from '@rocket.chat/core-typings';
import { Users } from '@rocket.chat/models';
import { Match, check } from 'meteor/check';
Expand All @@ -14,7 +14,7 @@ API.v1.addRoute(
{ authRequired: true, permissionsRequired: ['manage-voip-call-settings'] },
{
async get() {
const version = await Voip.getConnectorVersion();
const version = await VoipAsterisk.getConnectorVersion();
return API.v1.success(version);
},
},
Expand All @@ -26,7 +26,7 @@ API.v1.addRoute(
{ authRequired: true, permissionsRequired: ['manage-voip-call-settings'] },
{
async get() {
const list = await Voip.getExtensionList();
const list = await VoipAsterisk.getExtensionList();
const result = list.result as IVoipExtensionBase[];
return API.v1.success({ extensions: result });
},
Expand All @@ -48,7 +48,7 @@ API.v1.addRoute(
extension: String,
}),
);
const endpointDetails = await Voip.getExtensionDetails(this.queryParams);
const endpointDetails = await VoipAsterisk.getExtensionDetails(this.queryParams);
return API.v1.success({ ...endpointDetails.result });
},
},
Expand All @@ -68,7 +68,7 @@ API.v1.addRoute(
extension: String,
}),
);
const endpointDetails = await Voip.getRegistrationInfo(this.queryParams);
const endpointDetails = await VoipAsterisk.getRegistrationInfo(this.queryParams);
const encKey = settings.get<string>('VoIP_JWT_Secret');
if (!encKey) {
logger.warn('No JWT keys set. Sending registration info as plain text');
Expand Down Expand Up @@ -111,7 +111,7 @@ API.v1.addRoute(
return API.v1.notFound('Extension not found');
}

const endpointDetails = await Voip.getRegistrationInfo({ extension });
const endpointDetails = await VoipAsterisk.getRegistrationInfo({ extension });
const encKey = settings.get<string>('VoIP_JWT_Secret');
if (!encKey) {
logger.warn('No JWT keys set. Sending registration info as plain text');
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/api/server/v1/voip/queues.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Voip } from '@rocket.chat/core-services';
import { VoipAsterisk } from '@rocket.chat/core-services';
import type { IVoipConnectorResult, IQueueSummary, IQueueMembershipDetails, IQueueMembershipSubscription } from '@rocket.chat/core-typings';
import { Match, check } from 'meteor/check';

Expand All @@ -9,7 +9,7 @@ API.v1.addRoute(
{ authRequired: true, permissionsRequired: ['inbound-voip-calls'] },
{
async get() {
const queueSummary = await Voip.getQueueSummary();
const queueSummary = await VoipAsterisk.getQueueSummary();
return API.v1.success({ summary: queueSummary.result as IQueueSummary[] });
},
},
Expand All @@ -26,7 +26,7 @@ API.v1.addRoute(
extension: String,
}),
);
const membershipDetails: IVoipConnectorResult = await Voip.getQueuedCallsForThisExtension(this.queryParams);
const membershipDetails: IVoipConnectorResult = await VoipAsterisk.getQueuedCallsForThisExtension(this.queryParams);
return API.v1.success(membershipDetails.result as IQueueMembershipDetails);
},
},
Expand All @@ -43,7 +43,7 @@ API.v1.addRoute(
extension: String,
}),
);
const membershipDetails: IVoipConnectorResult = await Voip.getQueueMembership(this.queryParams);
const membershipDetails: IVoipConnectorResult = await VoipAsterisk.getQueueMembership(this.queryParams);
return API.v1.success(membershipDetails.result as IQueueMembershipSubscription);
},
},
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/app/api/server/v1/voip/server-connection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Voip } from '@rocket.chat/core-services';
import { VoipAsterisk } from '@rocket.chat/core-services';
import { Match, check } from 'meteor/check';

import { API } from '../../api';
Expand All @@ -18,7 +18,7 @@ API.v1.addRoute(
}),
);
const { host, port, username, password } = this.queryParams;
return API.v1.success(await Voip.checkManagementConnection(host, port, username, password));
return API.v1.success(await VoipAsterisk.checkManagementConnection(host, port, username, password));
},
},
);
Expand Down Expand Up @@ -53,7 +53,7 @@ API.v1.addRoute(
}
}

return API.v1.success(await Voip.checkCallserverConnection(socketUrl));
return API.v1.success(await VoipAsterisk.checkCallserverConnection(socketUrl));
},
},
);
8 changes: 4 additions & 4 deletions apps/meteor/app/voip/server/startup.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Voip } from '@rocket.chat/core-services';
import { VoipAsterisk } from '@rocket.chat/core-services';

import { settings } from '../../settings/server';

settings.watch('VoIP_Enabled', async (value: boolean) => {
try {
if (value) {
await Voip.init();
await VoipAsterisk.init();
} else {
await Voip.stop();
await VoipAsterisk.stop();
}
} catch (e) {
// do nothing
Expand All @@ -21,7 +21,7 @@ settings.changeMultiple(
// So to avoid stopping/starting voip too often, we debounce the call and restart 1 second after the last setting has reached us.
if (settings.get('VoIP_Enabled')) {
try {
await Voip.refresh();
await VoipAsterisk.refresh();
} catch (e) {
// do nothing
}
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/server/services/omnichannel-voip/service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IOmnichannelVoipService, FindVoipRoomsParams } from '@rocket.chat/core-services';
import { api, ServiceClassInternal, Voip } from '@rocket.chat/core-services';
import { api, ServiceClassInternal, VoipAsterisk } from '@rocket.chat/core-services';
import type {
IVoipExtensionBase,
IVoipExtensionWithAgentInfo,
Expand Down Expand Up @@ -197,7 +197,7 @@ export class OmnichannelVoipService extends ServiceClassInternal implements IOmn
}

async getFreeExtensions(): Promise<string[]> {
const allExtensions = await Voip.getExtensionList();
const allExtensions = await VoipAsterisk.getExtensionList();
const allocatedExtensions = await this.getAllocatedExtesionAllocationData({
extension: 1,
});
Expand Down Expand Up @@ -349,8 +349,8 @@ export class OmnichannelVoipService extends ServiceClassInternal implements IOmn
}

async getExtensionListWithAgentData(): Promise<IVoipExtensionWithAgentInfo[]> {
const { result: extensions } = await Voip.getExtensionList();
const summary = await (await Voip.cachedQueueDetails())();
const { result: extensions } = await VoipAsterisk.getExtensionList();
const summary = await (await VoipAsterisk.cachedQueueDetails())();
const allocatedExtensions = await this.getAllocatedExtesionAllocationData({
extension: 1,
_id: 1,
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/server/services/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { UiKitCoreAppService } from './uikit-core-app/service';
import { UploadService } from './upload/service';
import { UserService } from './user/service';
import { VideoConfService } from './video-conference/service';
import { VoipService } from './voip/service';
import { VoipAsteriskService } from './voip-asterisk/service';

export const registerServices = async (): Promise<void> => {
const { db } = MongoInternals.defaultRemoteCollectionDriver().mongo;
Expand All @@ -46,7 +46,7 @@ export const registerServices = async (): Promise<void> => {
api.registerService(new NPSService());
api.registerService(new RoomService());
api.registerService(new SAUMonitorService());
api.registerService(new VoipService(db));
api.registerService(new VoipAsteriskService(db));
api.registerService(new OmnichannelService());
api.registerService(new OmnichannelVoipService());
api.registerService(new TeamService());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import { CommandHandler } from './connector/asterisk/CommandHandler';
import { Commands } from './connector/asterisk/Commands';
import { getServerConfigDataFromSettings, voipEnabled } from './lib/Helper';

export class VoipService extends ServiceClassInternal implements IVoipService {
protected name = 'voip';
export class VoipAsteriskService extends ServiceClassInternal implements IVoipService {
protected name = 'voip-asterisk';

private logger: Logger;

Expand All @@ -33,7 +33,7 @@ export class VoipService extends ServiceClassInternal implements IVoipService {
constructor(db: Db) {
super();

this.logger = new Logger('VoIPService');
this.logger = new Logger('VoIPAsteriskService');
this.commandHandler = new CommandHandler(db);
if (!voipEnabled()) {
this.logger.warn({ msg: 'Voip is not enabled. Cant start the service' });
Expand All @@ -45,48 +45,48 @@ export class VoipService extends ServiceClassInternal implements IVoipService {
}

async init(): Promise<void> {
this.logger.info('Starting VoIP service');
this.logger.info('Starting VoIP Asterisk service');
if (this.active) {
this.logger.warn({ msg: 'VoIP service already started' });
this.logger.warn({ msg: 'VoIP Asterisk service already started' });
return;
}

try {
await this.commandHandler.initConnection(CommandType.AMI);
this.active = true;
void api.broadcast('connector.statuschanged', true);
this.logger.info('VoIP service started');
this.logger.info('VoIP Asterisk service started');
} catch (err) {
this.logger.error({ msg: 'Error initializing VOIP service', err });
this.logger.error({ msg: 'Error initializing VOIP Asterisk service', err });
}
}

async stop(): Promise<void> {
this.logger.info('Stopping VoIP service');
this.logger.info('Stopping VoIP Asterisk service');
if (!this.active) {
this.logger.warn({ msg: 'VoIP service already stopped' });
this.logger.warn({ msg: 'VoIP Asterisk service already stopped' });
return;
}

try {
this.commandHandler.stop();
this.active = false;
void api.broadcast('connector.statuschanged', false);
this.logger.info('VoIP service stopped');
this.logger.info('VoIP Asterisk service stopped');
} catch (err) {
this.logger.error({ msg: 'Error stopping VoIP service', err });
this.logger.error({ msg: 'Error stopping VoIP Asterisk service', err });
}
}

async refresh(): Promise<void> {
this.logger.info('Restarting VoIP service due to settings changes');
this.logger.info('Restarting VoIP Asterisk service due to settings changes');
try {
// Disable voip service
await this.stop();
// To then restart it
await this.init();
} catch (err) {
this.logger.error({ msg: 'Error refreshing VoIP service', err });
this.logger.error({ msg: 'Error refreshing VoIP Asterisk service', err });
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core-services/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export const Team = proxifyWithWait<ITeamService>('team');
export const MessageReads = proxifyWithWait<IMessageReadsService>('message-reads');
export const Room = proxifyWithWait<IRoomService>('room');
export const Media = proxifyWithWait<IMediaService>('media');
export const Voip = proxifyWithWait<IVoipService>('voip');
export const VoipAsterisk = proxifyWithWait<IVoipService>('voip-asterisk');
export const LivechatVoip = proxifyWithWait<IOmnichannelVoipService>('omnichannel-voip');
export const Analytics = proxifyWithWait<IAnalyticsService>('analytics');
export const LDAP = proxifyWithWait<ILDAPService>('ldap');
Expand Down

0 comments on commit 5d1cb28

Please sign in to comment.