/// <summary> Adds participants to a thread. If participants already exist, no change occurs. </summary> /// <param name="participant"> Participants to add to a chat thread. </param> /// <param name="cancellationToken"> The cancellation token to use. </param> /// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception> public virtual Response <AddChatParticipantsResult> AddParticipant(ChatParticipant participant, CancellationToken cancellationToken = default) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ChatThreadClient)}.{nameof(AddParticipant)}"); scope.Start(); try { return(_chatThreadRestClient.AddChatParticipants(Id, new[] { participant.ToChatParticipantInternal() }, cancellationToken)); } catch (Exception ex) { scope.Failed(ex); throw; } }
/// <summary> Adds participants to a thread. If participants already exist, no change occurs. </summary> /// <param name="participant"> Participants to add to a chat thread. </param> /// <param name="cancellationToken"> The cancellation token to use. </param> /// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception> public virtual Response AddParticipant(ChatParticipant participant, CancellationToken cancellationToken = default) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ChatThreadClient)}.{nameof(AddParticipant)}"); scope.Start(); try { Response <AddChatParticipantsResult> addChatParticipantsResult = _chatThreadRestClient.AddChatParticipants(Id, new[] { participant.ToChatParticipantInternal() }, cancellationToken); if (addChatParticipantsResult.Value.InvalidParticipants.Count > 0) { throw _clientDiagnostics.CreateRequestFailedException(addChatParticipantsResult.GetRawResponse()); } return(addChatParticipantsResult.GetRawResponse()); } catch (Exception ex) { scope.Failed(ex); throw; } }