Skip to content

Commit 6640946

Browse files
[Bugfix] CallAdapter id checking (#3972)
* add mocks (not working) * add throw conditions to wrong kinds of identifiers passed to create * Change files * Duplicate change files for beta release * fix cc * Update packages/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.ts Co-authored-by: James Burnside <2684369+JamesBurnside@users.noreply.github.com> Signed-off-by: Donald McEachern <94866715+dmceachernmsft@users.noreply.github.com> * oops * oops2 * fix audio context sound testing --------- Signed-off-by: Donald McEachern <94866715+dmceachernmsft@users.noreply.github.com> Co-authored-by: James Burnside <2684369+JamesBurnside@users.noreply.github.com>
1 parent b3cdd69 commit 6640946

3 files changed

Lines changed: 33 additions & 6 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "Bugfix",
5+
"comment": "Introduce blocking error when giving wrong kind of identifier to createAzureCommunicationCallAdapter",
6+
"packageName": "@azure/communication-react",
7+
"email": "94866715+dmceachernmsft@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "Bugfix",
5+
"comment": "Introduce blocking error when giving wrong kind of identifier to createAzureCommunicationCallAdapter",
6+
"packageName": "@azure/communication-react",
7+
"email": "94866715+dmceachernmsft@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}

packages/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,13 @@ import {
9898
CommunicationTokenCredential,
9999
CommunicationUserIdentifier,
100100
CommunicationIdentifier,
101-
MicrosoftTeamsUserIdentifier
101+
MicrosoftTeamsUserIdentifier,
102+
isMicrosoftTeamsUserIdentifier
102103
} from '@azure/communication-common';
104+
/* @conditional-compile-remove(teams-identity-support) */ /* @conditional-compile-remove(PSTN-calls) */
105+
import { isCommunicationUserIdentifier } from '@azure/communication-common';
103106
/* @conditional-compile-remove(PSTN-calls) */
104-
import {
105-
isCommunicationUserIdentifier,
106-
isPhoneNumberIdentifier,
107-
PhoneNumberIdentifier
108-
} from '@azure/communication-common';
107+
import { isPhoneNumberIdentifier, PhoneNumberIdentifier } from '@azure/communication-common';
109108
import { ParticipantSubscriber } from './ParticipantSubcriber';
110109
import { AdapterError } from '../../common/adapters';
111110
import { DiagnosticsForwarder } from './DiagnosticsForwarder';
@@ -1452,6 +1451,11 @@ export const createAzureCommunicationCallAdapter = async ({
14521451
/* @conditional-compile-remove(PSTN-calls) */ alternateCallerId,
14531452
/* @conditional-compile-remove(video-background-effects) */ options
14541453
}: AzureCommunicationCallAdapterArgs): Promise<CallAdapter> => {
1454+
if (isMicrosoftTeamsUserIdentifier(userId)) {
1455+
throw new Error(
1456+
'Microsoft Teams user identifier is not supported by AzureCommunicationCallAdapter. Instead use TeamsCallAdapter.'
1457+
);
1458+
}
14551459
return _createAzureCommunicationCallAdapterInner({
14561460
userId,
14571461
displayName,
@@ -1521,6 +1525,11 @@ export const createTeamsCallAdapter = async ({
15211525
locator,
15221526
options
15231527
}: TeamsCallAdapterArgs): Promise<TeamsCallAdapter> => {
1528+
if (isCommunicationUserIdentifier(userId)) {
1529+
throw new Error(
1530+
'Communication User identifier is not supported by TeamsCallAdapter, please use our AzureCommunicationCallAdapter.'
1531+
);
1532+
}
15241533
const callClient = _createStatefulCallClientInner(
15251534
{
15261535
userId

0 commit comments

Comments
 (0)