Skip to content

Commit

Permalink
Merge pull request #795 from wazo-platform/WDA-2380-robust-call-log-i…
Browse files Browse the repository at this point in the history
…ncoming

[WDA-2380] Internal CallLog, also check current user uuid for direction
  • Loading branch information
bogue authored Dec 10, 2024
2 parents 9dd1b6f + c4df783 commit c59aff7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/domain/CallLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
12 changes: 12 additions & 0 deletions src/domain/__tests__/CallLog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c59aff7

Please sign in to comment.