Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use sipheaders and voipheaders for transfer #34190

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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