Skip to content

Commit

Permalink
use sipheaders and voipheaders for transfer (#34190)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyw-msft authored Feb 15, 2023
1 parent fa8a2cf commit f52cd65
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,6 @@ public partial class TransferToParticipantOptions
public TransferToParticipantOptions(Azure.Communication.CallAutomation.CallInvite callInvite) { }
public Azure.Communication.CallAutomation.CallInvite CallInvite { get { throw null; } }
public string OperationContext { get { throw null; } set { } }
public string UserToUserInformation { get { throw null; } set { } }
}
public partial class UnmuteParticipantsOptions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,17 @@ private static TransferToParticipantRequestInternal CreateTransferToParticipantR
TransferToParticipantRequestInternal request = new TransferToParticipantRequestInternal(CommunicationIdentifierSerializer.Serialize(options.CallInvite.Target));

request.TransfereeCallerId = options.CallInvite.SourceCallerIdNumber == null ? null : new PhoneNumberIdentifierModel(options.CallInvite.SourceCallerIdNumber.PhoneNumber);
if (options.UserToUserInformation != null && options.UserToUserInformation.Length > CallAutomationConstants.InputValidation.StringMaxLength)

foreach (var sipHeader in options.CallInvite.SipHeaders)
{
throw new ArgumentException(CallAutomationErrorMessages.UserToUserInformationExceedsMaxLength);
request.CustomContext.SipHeaders.Add(sipHeader.Key, sipHeader.Value);
}
// TODO: update logic
// else
// {
// request.UserToUserInformation = options.UserToUserInformation;
// }

foreach (var voipHeader in options.CallInvite.VoipHeaders)
{
request.CustomContext.SipHeaders.Add(voipHeader.Key, voipHeader.Value);
}

if (options.OperationContext != null && options.OperationContext.Length > CallAutomationConstants.InputValidation.StringMaxLength)
{
throw new ArgumentException(CallAutomationErrorMessages.OperationContextExceedsMaxLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ public TransferToParticipantOptions(CallInvite callInvite)
/// </summary>
public CallInvite CallInvite { get; }

/// <summary>
/// The UserToUserInformation.
/// </summary>
public string UserToUserInformation { get; set; }

/// <summary>
/// The operationContext for this transfer call.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,6 @@ public void TransferCallToParticipant_ExceedsMaxOperationContextLength(CallInvit
Assert.True(ex?.Message.Contains(CallAutomationErrorMessages.OperationContextExceedsMaxLength));
}

[TestCaseSource(nameof(TestData_TransferCallToParticipant))]
public void TransferCallToParticipant_ExceedsMaxUserToUserInformationLengthLength(CallInvite callInvite)
{
var callConnection = CreateMockCallConnection(202);

var options = new TransferToParticipantOptions(callInvite)
{
UserToUserInformation = new string('a', 1 + CallAutomationConstants.InputValidation.StringMaxLength)
};
ArgumentException? ex = Assert.Throws<ArgumentException>(() => callConnection.TransferCallToParticipant(options));
Assert.NotNull(ex);
Assert.True(ex?.Message.Contains(CallAutomationErrorMessages.UserToUserInformationExceedsMaxLength));
}

[TestCaseSource(nameof(TestData_AddOrRemoveParticipant))]
public async Task AddParticipantsAsync_202Accepted(CommunicationIdentifier participantToAdd)
{
Expand Down Expand Up @@ -575,7 +561,8 @@ private CallConnection CreateMockCallConnection(int responseCode, string? respon
{
new object?[]
{
new CallInvite(new CommunicationUserIdentifier("userId"))
new CallInvite(new CommunicationUserIdentifier("userId")){
SipHeaders = {{ "key1", "value1" }}}
},
};
}
Expand Down

0 comments on commit f52cd65

Please sign in to comment.