diff --git a/src/domain/CallLog.ts b/src/domain/CallLog.ts index 575ffe2c..e679346d 100644 --- a/src/domain/CallLog.ts +++ b/src/domain/CallLog.ts @@ -216,7 +216,10 @@ export default class CallLog { isIncoming(session: Session): boolean { if (this.callDirection === 'internal') { - return session.hasExtension(this.destination.plainExtension) || session.hasExtension(this.requested.extension); + return session.hasExtension(this.destination.plainExtension) + || session.hasExtension(this.requested.extension) + || session.uuid === this.destination.uuid + || session.uuid === this.requested.uuid; } return this.callDirection === 'inbound'; diff --git a/src/domain/__tests__/CallLog.test.ts b/src/domain/__tests__/CallLog.test.ts index bc5e9fb1..7f8472c4 100644 --- a/src/domain/__tests__/CallLog.test.ts +++ b/src/domain/__tests__/CallLog.test.ts @@ -127,6 +127,18 @@ describe('CallLog Domain', () => { }); expect(destinationCallLog.isIncomingAndForwarded(BOB_SESSION)).toBe(true); + // When destination is set to the same user with a changed extension + const destinationExtensionChangedCallLog = CallLog.parse({ + ...CALL_LOG_RESPONSE, + destination_extension: `${CALL_LOG_RESPONSE.requested_extension}9`, + destination_name: CALL_LOG_RESPONSE.requested_name, + destination_user_uuid: CALL_LOG_RESPONSE.requested_user_uuid, + requested_extension: `${CALL_LOG_RESPONSE.destination_extension}9`, + requested_name: CALL_LOG_RESPONSE.destination_name, + requested_user_uuid: CALL_LOG_RESPONSE.destination_user_uuid, + }); + expect(destinationExtensionChangedCallLog.isIncomingAndForwarded(BOB_SESSION)).toBe(true); + // When call direction is inbound const inboundCallLog = CallLog.parse({ ...CALL_LOG_RESPONSE, call_direction: 'inbound' }); expect(inboundCallLog.isIncomingAndForwarded(BOB_SESSION)).toBe(true);